Hello everyone, I am having some trouble to deploy my django app. The application runs smoothly locally but when I run it on a GCP VM I am getting some problem with the Chroma DB and I get the following error. ''' ValueError: Could not connect to tenant default_tenant. Are you sure it exists? ‘’’. I have tried to find a solution for this but I was not able to find it. Does anyone know what might be the issue or can advise me on any reference to solve this problem?
I did not attach any code here as I am not sure what I should include here to get a better help. It is my first deployment to production.
#Problem to deploy a Django App with Chroma DB
49 messages · Page 1 of 1 (latest)
Can you share the complete error traceback, as well as the code that establishes the connection to Chroma?
I am new at this forum and I cannot find the option to attach my files with the complete error traceback and the functions related to the issue. Can you advise me on how to attach these files here as they are too long for the chat?
You can paste the text, click the little + icon, and choose "upload your message as a file", or upload a file directly from the plus.
When I click the plus sign I have only the options 'Create Poll' and 'Use Apps'.
Oh, sorry... use an external service 😅 https://paste.pythondiscord.com/ is a good one.
Us mods have a few extra powers 🙂
Many thanks, I will try it here
I have pasted my python functions related to the issue and named as ''python functions related to the issue'. I am not sure if you can see it after I have pasted my code or if I need to share some link with you. Below my pasted code I have the following: 'Filename: python functions related to the issue. Size: 3kb. View raw, copy, hex, or download this file. Report this file.'
You need to share the link.
I will do the same for the error traceback
Here you have the complete error traceback: https://paste.pythondiscord.com/55XA
Many thanks for your support.
Does the directory LRS_vectorstore_dir exist on the server?
(N.B. by convention, constants should be capitalized, so LRS_VECTORSTORE_DIR would be preferable).
The LRS_vectorstore_dir is a variable in my cache_manager.py file, which include the following:
LRS_pdfdata_dir = "/Users/mrp/Documents/My_Projects/TESTS_TEMPLATES/WebApplication_ChatBot/Tests/Django_Projects/webapps/researcher_assistant/database/LRS/pdf_data"
LRS_vectorstore_dir = "/Users/mrp/Documents/My_Projects/TESTS_TEMPLATES/WebApplication_ChatBot/Tests/Django_Projects/webapps/researcher_assistant/database/LRS/vectorstore"
LRS_chat_history_dir = "/Users/mrp/Documents/My_Projects/TESTS_TEMPLATES/WebApplication_ChatBot/Tests/Django_Projects/webapps/researcher_assistant/database/LRS/chat_history"
The folder exist on the server
Are you developing on Mac and deploying on Linux?
I am sorry, but the paths shown above is in my application running locally. Below you have the paths are as follow in my application at GCP:
LRS_pdfdata_dir = "/home/mrp/webapps/researcher_assistant/database/LRS/pdf_data"
LRS_vectorstore_dir = "/home/mrp/webapps/researcher_assistant/database/LRS/vectorstore"
LRS_chat_history_dir = "/home/mrp/webapps/researcher_assistant/database/LRS/chat_history"
Yeah, that sounds better 🙂
Yes, developing on Mac but deploying on a GCP VM using Ubuntu
Ok. Can you add a print to make sure the path is correct (/home/, not /Users/):
def load_data_LRS(username):
read_path = f"{LRS_pdfdata_dir}/{username}"
write_path = f"{LRS_vectorstore_dir}/{username}"
+ print(LRS_vectorstore_dir)
if os.path.exists(write_path):
shutil.rmtree(write_path)
When adding the print statement, I have got the following:
'Creating models...
/home/mrp/webapps/researcher_assistant/database/LRS/vectorstore
Ignoring wrong pointing object 799 0 (offset 0)
Internal Server Error: /chat_with_files/
Traceback (most recent call last):
File "/home/mrp/env/rap/lib/python3.8/site-packages/chromadb/api/client.py", line 371, in _validate_tenant_database'
You have ssh access into the machine? Does ls /home/mrp/webapps/researcher_assistant/database/LRS/vectorstore work?
I am running this code using the 'python manage.py runserver 0.0.0.0:8000' as I have allowed the TCP 8000 port. I am running the code using the ssh of my GCP VM. But I do not have ssh access on my terminal.
The command ls /home/mrp/webapps/researcher_assistant/database/LRS/vectorstore works normally. When I start the application, I can see the folder with the username as well as the chroma DB within the vectorstore. However, when I try to execute the function again as an user, I see that the folder is empty.
If you run ls -lh /home/mrp/webapps/researcher_assistant/database/LRS/, does it show vectorstore as being owned by the mrp` user?
Yes. I get the following: drwxrwxr-x 2 mrp mrp 4.0K Jul 19 16:22 vectorstore
Hmm... all this looks correct. Maybe username is blank? Let's check that next.
def load_data_LRS(username):
read_path = f"{LRS_pdfdata_dir}/{username}"
write_path = f"{LRS_vectorstore_dir}/{username}"
- print(LRS_vectorstore_dir)
+ print(write_path)
if os.path.exists(write_path):
shutil.rmtree(write_path)
It also prints the folder as shown below:
Creating models...
/home/mrp/webapps/researcher_assistant/database/LRS/vectorstore/mariorope
Ignoring wrong pointing object 799 0 (offset 0)
Internal Server Error: /chat_with_files/
Traceback (most recent call last):
File "/home/mrp/env/rap/lib/python3.8/site-packages/chromadb/api/client.py", line 371, in _validate_tenant_database
the functions to create the Chroma DB are called in the function 'chat_with_files' that is in my views.py. If you want to see this function too, I can prepare another file with it, although I guess the problem is happening on one of the functions provided previously.
The problem is obiously at https://paste.pythondiscord.com/55XA#1L65-L65.
self._conn = sqlite3.connect(
sqlite3.OperationalError: unable to open database file
Sadly, it doesn't tell us much.
vectordb = Chroma.from_documents(documents=docs, embedding=embeddings, persist_directory=write_path) is the line that fails...
But if the fie doesn't exist, sqlite.connect should create it.
Just tested that in the REPL... unless it's changed across python versions.
I completely agree with what you said. For me the problem is with the Chroma DB. But I thought that it could be some misconfig on my django settings, or something else. When I run it locally, the application just creates a new sqlite connection and everything goes as I want. This happens only when running on the VM. I am trying to find a solution for this for about 3 days but I was not able to figure out the solution yet.
It's tricky, because Sqlite doesn't say why it can't open the DB.
Chroma is, at heart, just an extension of sqlite...
If the vectorstore directory exists, and the permissions are right, and the username is not blank, it should not fail 🤔
df -h ~/ does show that you have enough free space?
I think so. Here is the result of the command above:
(rap) mrp@researcher-assistant-platform-server:~/webapps/researcher_assistant/utils$ df -h ~/
Filesystem Size Used Avail Use% Mounted on
/dev/root 9.6G 5.0G 4.6G 52% /
Yeah... Hmm.
I gotta go run some errands, but I'll see if anything comes to mind 🙂
Many thanks for your help. I will try to ask something in the ChromaDB support as well to see if someone have run into this problem. Otherwise, I will try to use another database and see if it works too. Please let me know if you figure out something later on. Again, many many thanks for your support.
One idea would be to open write_path for writing, and seeing if you get a more descriptive error message.
I will also try this and I will let you know the results here later on. Thanks a lot!