Skip to content

Commit

Permalink
Finish merged TODO to merge in thin client (#658)
Browse files Browse the repository at this point in the history
## Description of changes
#629 was left unfinished, this completes the merge to support thin
client error'ing.

## Test plan
Existing tests

## Documentation Changes
None required.
  • Loading branch information
HammadB authored Jun 2, 2023
1 parent 75f5a81 commit 9f54534
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions chromadb/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ def __init__(self, settings: Settings):
self._instances = {}
self._running = False

if is_thin_client:
# The thin client is a system with only the API component
if self.settings["chroma_api_impl"] != "chromadb.api.fastapi.FastAPI":
raise RuntimeError(
"Chroma is running in http-only client mode, and can only be run with 'chromadb.api.fastapi.FastAPI' or 'rest' as the chroma_api_impl. \
see https://docs.trychroma.com/usage-guide?lang=py#using-the-python-http-only-client for more information."
)

def instance(self, type: Type[T]) -> T:
"""Return an instance of the component type specified. If the system is running,
the component will be started as well."""
Expand Down Expand Up @@ -177,26 +185,3 @@ def get_class(fqn: str, type: Type[T]) -> Type[T]:
def get_fqn(cls: Type[T]) -> str:
"""Given a class, return its fully qualified name"""
return f"{cls.__module__}.{cls.__name__}"


# TODO: merge this in properly
# def get_db(self) -> chromadb.db.DB:
# if is_thin_client:
# raise RuntimeError(
# "Chroma is running in http-only client mode, and cannot directly access the database. \
# See https://docs.trychroma.com/usage-guide?lang=py#using-the-python-http-only-client for more information."
# )

# if self.db is None:
# self.db = self._instantiate("chroma_db_impl")
# return self.db

# def get_api(self) -> chromadb.api.API:
# if is_thin_client and (
# self.settings["chroma_api_impl"] != "chromadb.api.fastapi.FastAPI"
# ):
# print(self.settings["chroma_api_impl"])
# raise RuntimeError(
# "Chroma is running in http-only client mode, and can only be run with 'chromadb.api.fastapi.FastAPI' or 'rest' as the chroma_api_impl. \
# see https://docs.trychroma.com/usage-guide?lang=py#using-the-python-http-only-client for more information."
# )

0 comments on commit 9f54534

Please sign in to comment.