Skip to content

Commit

Permalink
fix: Addressed comments
Browse files Browse the repository at this point in the history
- Removed commented out code
- Added clarification for to_thread usage
  • Loading branch information
tazarov committed Feb 14, 2024
1 parent a1ddd69 commit 8d95844
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions chromadb/server/fastapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from typing import Any, Callable, Dict, List, Sequence, Optional, cast
import fastapi
import orjson
from anyio import to_thread
from anyio import (
to_thread,
) # this is used to transform sync code to async. By default, AnyIO uses 40 threads pool
from fastapi import FastAPI as _FastAPI, Response, Request
from fastapi.responses import JSONResponse

Expand Down Expand Up @@ -49,8 +51,6 @@
UpdateEmbedding,
)

# from starlette.requests import Request

import logging

from chromadb.server.fastapi.utils import fastapi_json_response, string_to_uuid as _uuid
Expand Down Expand Up @@ -515,7 +515,7 @@ async def add(self, request: Request, collection_id: str) -> None:
attributes=attr_from_collection_lookup(collection_id_arg="collection_id"),
),
)
async def update(self, request: Request, collection_id:str) -> None:
async def update(self, request: Request, collection_id: str) -> None:
raw_body = await request.body()
add = UpdateEmbedding.model_validate(orjson.loads(raw_body))
await to_thread.run_sync(
Expand All @@ -537,7 +537,7 @@ async def update(self, request: Request, collection_id:str) -> None:
attributes=attr_from_collection_lookup(collection_id_arg="collection_id"),
),
)
async def upsert(self, request: Request, collection_id:str) -> None:
async def upsert(self, request: Request, collection_id: str) -> None:
raw_body = await request.body()
collection_id = request.path_params.get("collection_id")
upsert = AddEmbedding.model_validate(orjson.loads(raw_body))
Expand Down

0 comments on commit 8d95844

Please sign in to comment.