From 8d95844c0e4fe986466f9172328a2a2f47a57e9b Mon Sep 17 00:00:00 2001 From: Trayan Azarov Date: Wed, 14 Feb 2024 22:14:08 +0200 Subject: [PATCH] fix: Addressed comments - Removed commented out code - Added clarification for to_thread usage --- chromadb/server/fastapi/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/chromadb/server/fastapi/__init__.py b/chromadb/server/fastapi/__init__.py index b416ef2ff66..07811a7ed79 100644 --- a/chromadb/server/fastapi/__init__.py +++ b/chromadb/server/fastapi/__init__.py @@ -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 @@ -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 @@ -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( @@ -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))