chroma-core / chroma

the AI-native open-source embedding database
https://www.trychroma.com/
Apache License 2.0
15.69k stars 1.32k forks source link

[Bug]: Client connection #1296

Open sadihasanov opened 1 year ago

sadihasanov commented 1 year ago

What happened?

Hi everyone, I am not sure whether this is a bug but I couldn't find any information on this matter and its behavior is pretty weird.

I have my FastAPI app and I have a config file where I start the Chroma client and then just import it across the app. I use following method to connect the client: client = chromadb.HttpClient(os.environ.get("VECTOR_DB_URL"), settings=Settings(chroma_client_auth_provider="chromadb.auth.token.TokenAuthClientProvider", chroma_client_auth_credentials=os.environ.get("VECTOR_DB_API_KEY")))

When I run it locally, it connects to Chroma that is hosted on DigitalOcean. When I try to run the docker image, I get the error.

If I go to vector_db_url/api/v1/heartbeat I get the response, so the link is valid and this error does not occur when running locally. Any ideas why this could be thrown and what is the solution?

Versions

Chroma 0.4.15

Relevant log output

2023-10-26 18:05:52 Traceback (most recent call last):
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/site-packages/chromadb/api/fastapi.py", line 588, in raise_chroma_error
2023-10-26 18:05:52     resp.raise_for_status()
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
2023-10-26 18:05:52     raise HTTPError(http_error_msg, response=self)
2023-10-26 18:05:52 requests.exceptions.HTTPError: 404 Client Error: Not Found for url: {vector_url_on_digitalocean (replaced original url)}
2023-10-26 18:05:52 
2023-10-26 18:05:52 During handling of the above exception, another exception occurred:
2023-10-26 18:05:52 
2023-10-26 18:05:52 Traceback (most recent call last):
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/site-packages/chromadb/api/client.py", line 402, in _validate_tenant_database
2023-10-26 18:05:52     self._admin_client.get_tenant(name=tenant)
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/site-packages/chromadb/api/client.py", line 439, in get_tenant
2023-10-26 18:05:52     return self._server.get_tenant(name=name)
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/site-packages/chromadb/telemetry/opentelemetry/__init__.py", line 127, in wrapper
2023-10-26 18:05:52     return f(*args, **kwargs)
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/site-packages/chromadb/api/fastapi.py", line 194, in get_tenant
2023-10-26 18:05:52     raise_chroma_error(resp)
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/site-packages/chromadb/api/fastapi.py", line 590, in raise_chroma_error
2023-10-26 18:05:52     raise (Exception(resp.text))
2023-10-26 18:05:52 Exception: {"detail":"Not Found"}
2023-10-26 18:05:52 
2023-10-26 18:05:52 During handling of the above exception, another exception occurred:
2023-10-26 18:05:52 
2023-10-26 18:05:52 Traceback (most recent call last):
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
2023-10-26 18:05:52     self.run()
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/multiprocessing/process.py", line 108, in run
2023-10-26 18:05:52     self._target(*self._args, **self._kwargs)
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/site-packages/uvicorn/_subprocess.py", line 76, in subprocess_started
2023-10-26 18:05:52     target(sockets=sockets)
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/site-packages/uvicorn/server.py", line 61, in run
2023-10-26 18:05:52     return asyncio.run(self.serve(sockets=sockets))
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
2023-10-26 18:05:52     return loop.run_until_complete(main)
2023-10-26 18:05:52   File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/site-packages/uvicorn/server.py", line 68, in serve
2023-10-26 18:05:52     config.load()
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/site-packages/uvicorn/config.py", line 467, in load
2023-10-26 18:05:52     self.loaded_app = import_from_string(self.app)
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/site-packages/uvicorn/importer.py", line 21, in import_from_string
2023-10-26 18:05:52     module = importlib.import_module(module_str)
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
2023-10-26 18:05:52     return _bootstrap._gcd_import(name[level:], package, level)
2023-10-26 18:05:52   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2023-10-26 18:05:52   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2023-10-26 18:05:52   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
2023-10-26 18:05:52   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
2023-10-26 18:05:52   File "<frozen importlib._bootstrap_external>", line 850, in exec_module
2023-10-26 18:05:52   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
2023-10-26 18:05:52   File "/app/main.py", line 10, in <module>
2023-10-26 18:05:52     from routes import pydocument, knowledgebase
2023-10-26 18:05:52   File "/app/routes/__init__.py", line 1, in <module>
2023-10-26 18:05:52     from .pydocument.controller import router as pydocument
2023-10-26 18:05:52   File "/app/routes/pydocument/controller.py", line 10, in <module>
2023-10-26 18:05:52     from routes.pydocument.helpers.get_prompt import single_document_prompt, questionnaire_prompts, multiple_document_prompt, knowledgebase_chat, questionnaire_excel
2023-10-26 18:05:52   File "/app/routes/pydocument/helpers/get_prompt.py", line 8, in <module>
2023-10-26 18:05:52     from chroma.config import client, collection
2023-10-26 18:05:52   File "/app/chroma/config.py", line 9, in <module>
2023-10-26 18:05:52     client = chromadb.HttpClient(os.environ.get("VECTOR_DB_URL"), settings=Settings(chroma_client_auth_provider="chromadb.auth.token.TokenAuthClientProvider",
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/site-packages/chromadb/__init__.py", line 174, in HttpClient
2023-10-26 18:05:52     return ClientCreator(tenant=tenant, database=database, settings=settings)
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/site-packages/chromadb/api/client.py", line 138, in __init__
2023-10-26 18:05:52     self._validate_tenant_database(tenant=tenant, database=database)
2023-10-26 18:05:52   File "/usr/local/lib/python3.9/site-packages/chromadb/api/client.py", line 404, in _validate_tenant_database
2023-10-26 18:05:52     raise ValueError(
2023-10-26 18:05:52 ValueError: Could not connect to tenant default_tenant. Are you sure it exists?
HammadB commented 1 year ago

Are your running the 0.4.15 server too? This seems like you upgraded the client without upgrading the server

sadihasanov commented 1 year ago

I believe server is running at 0.4.15. Just pushed the updated image today. I'll check in with the team to confirm this and come back to you

yackermann commented 1 year ago

Can confirm

Python package: chromadb==0.4.15 Docker image: 0.4.15

HammadB commented 1 year ago

Are you able to pull down the SQLite file from your DO instance and check to see if the table "tenants" is populated?

uncvrd commented 1 year ago

So I'm not sure if this is helpful but I got this error when i tried connecting to my database using the wrong port (for example, I had my docker port as 8001:8000 and was accidentally attempting to connect to 8000 instead of 8001)