Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't write .lock file when loading from an existing collection #765

Open
jonas-nothnagel opened this issue Sep 2, 2024 · 2 comments
Open

Comments

@jonas-nothnagel
Copy link

jonas-nothnagel commented Sep 2, 2024

I have stored a qdrant collection locally on my computer to access it for testing purposes. I am building a chatbot app in gradio and it requires to load the app.py many times to develop it in iterations.

However, every time I load the collection a .lock file is automatically created which I have to manually delete each time when loading app again for my application. Otherwise I run into following error:

RuntimeError: Storage folder qdrant/ is already accessed by another instance of Qdrant client. If you require concurrent access, use Qdrant server instead.

The code to load the collection is as follows:

vectors = QdrantVectorStore.from_existing_collection(
    path="qdrant/", 
    collection_name="uganda-documents",
    
    embedding = HuggingFaceEmbeddings(
        model_kwargs = {'device': device},
        encode_kwargs = {'normalize_embeddings': bool(int(config.get('retriever','NORMALIZE')))},
        model_name=config.get('retriever','MODEL')
    )
)

I would like to either automatically delete the .lock file or to not create it at all in the first place. Is this possible within Qdrant or do I have to build a manual work around?

I know I could simply add something like a os.remove("qdrant/.lock") but it seems not very intuitive.

@generall generall transferred this issue from qdrant/qdrant Sep 3, 2024
@joein
Copy link
Member

joein commented Sep 17, 2024

Hi @jonas-nothnagel, sorry for the late response

I am not an expert of gradio, but if it works in a similar way to streamlit, then you would either have a shared object, which is created only once or you can use .close()

If the former approach is possible, I think it would be preferable

@nikitaCodeSave
Copy link

lock_file = os.path.join(self.db_dir, ".lock")
if os.path.exists(lock_file):
     os.remove(lock_file)

 os.makedirs(self.db_dir, exist_ok=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants