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

[Bug]: client/server mode RuntimeError: coroutine raised StopIteration #2213

Closed
iessi12 opened this issue May 16, 2024 · 7 comments
Closed
Labels
bug Something isn't working

Comments

@iessi12
Copy link

iessi12 commented May 16, 2024

What happened?

It is used in client/server mode.

        client = chromadb.HttpClient(
            host="x.x.x.x",
            port=8000,
            settings=Settings(
                anonymized_telemetry=False,
            ),
        )

    db = Chroma(
        embedding_function=embeddings,
        client=client,
        collection_metadata={"hnsw:space": "cosine"},
    )

After creating a collection with db.add_documents(), I get an error when deleting it with db.delete_collection().
When I delete it, db._collection.count() is set to 0, but I still get an error.

RuntimeError: coroutine raised StopIteration

Versions

client
Chroma 0.5.0
Python 3.11.9
langchain 0.1.13

server
Chroma 0.5.0
Python 3.11.9

Relevant log output

No response

@iessi12 iessi12 added the bug Something isn't working label May 16, 2024
@sanketkedia
Copy link
Contributor

sanketkedia commented May 16, 2024

@iessi12 can you provide a minimal repro of this. I would like to repro and debug. I can't repro locally

@iessi12
Copy link
Author

iessi12 commented May 16, 2024

Now you can reproduce it.

print(f"before delete collection count:{db._collection.count()}")
db.delete_collection()
print(f"after delete collection count:{db._collection.count()}")

It seems that calling db._collection.count() after db.delete_collection() causes an error.

@tazarov
Copy link
Contributor

tazarov commented May 17, 2024

hey @iessi12, ok I see where the issues are. One is on Chroma side and another in Langchain🦜🔗.

The problem with Langchain🦜🔗 and the fact that a reference to the original collection, including its id (UUIDv4), is kept even after a delete_colection() call. So a subsequent call to count() results in a query to Chroma with a collection ID that doesn't exist.

The above leads to the problem in Chroma and it is more related to validation rather than an actual functional error.

We'll fix both of these ASAP. Thank you for reporting this.

@tazarov
Copy link
Contributor

tazarov commented May 17, 2024

The second problem with the validation was addressed already in #2048 (not in 0.5.0 release)

@sanketkedia
Copy link
Contributor

Nice! Thanks @iessi12 for reporting and @tazarov for fixing this promptly. Closing this GHI then.

@iessi12
Copy link
Author

iessi12 commented May 17, 2024

I appreciate your cooperation.

baskaryan pushed a commit to langchain-ai/langchain that referenced this issue May 20, 2024
…llection (#21817)

**Description**:

- Reference to `Collection` object is set to `None` when deleting a
collection `delete_collection()`
- Added utility method `reset_collection()` to allow recreating the
collection
- Moved collection creation out of `__init__` into
`__ensure_collection()` to be reused by object init and
`reset_collection()`
- `_collection` is now a property to avoid breaking changes

**Issues**: 

- chroma-core/chroma#2213

**Twitter**: @t_azarov
hinthornw pushed a commit to langchain-ai/langchain that referenced this issue Jun 20, 2024
…llection (#21817)

**Description**:

- Reference to `Collection` object is set to `None` when deleting a
collection `delete_collection()`
- Added utility method `reset_collection()` to allow recreating the
collection
- Moved collection creation out of `__init__` into
`__ensure_collection()` to be reused by object init and
`reset_collection()`
- `_collection` is now a property to avoid breaking changes

**Issues**: 

- chroma-core/chroma#2213

**Twitter**: @t_azarov
@tdgadwani
Copy link

Hi community ,
facing the same issue while adding documents to the collection can someone please help me through out this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants