-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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] Fix test flakiness #1765
[BUG] Fix test flakiness #1765
Conversation
Current dependencies on/for this PR: This stack of pull requests is managed by Graphite. |
Please tag your PR title with one of: [ENH | BUG | DOC | TST | BLD | PERF | TYP | CLN | CHORE]. See https://docs.trychroma.com/contributing#contributing-code-and-ideas |
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
Please tag your PR title with one of: [ENH | BUG | DOC | TST | BLD | PERF | TYP | CLN | CHORE]. See https://docs.trychroma.com/contributing#contributing-code-and-ideas |
2 similar comments
Please tag your PR title with one of: [ENH | BUG | DOC | TST | BLD | PERF | TYP | CLN | CHORE]. See https://docs.trychroma.com/contributing#contributing-code-and-ideas |
Please tag your PR title with one of: [ENH | BUG | DOC | TST | BLD | PERF | TYP | CLN | CHORE]. See https://docs.trychroma.com/contributing#contributing-code-and-ideas |
Please tag your PR title with one of: [ENH | BUG | DOC | TST | BLD | PERF | TYP | CLN | CHORE]. See https://docs.trychroma.com/contributing#contributing-code-and-ideas |
Please tag your PR title with one of: [ENH | BUG | DOC | TST | BLD | PERF | TYP | CLN | CHORE]. See https://docs.trychroma.com/contributing#contributing-code-and-ideas |
f8fee20
to
b7cbc61
Compare
if coll.name not in self.model: | ||
with pytest.raises(Exception): | ||
c = self.api.get_collection(name=coll.name) | ||
return multiple() | ||
|
||
c = self.api.get_collection(name=coll.name) | ||
_metadata: Optional[Mapping[str, Any]] = coll.metadata | ||
print("before API:", c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a print here
c.modify(metadata=_metadata, name=_name) | ||
c = self.api.get_collection(name=coll.name) | ||
print("after API:", c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a print here - please remove
@@ -236,18 +236,29 @@ def embedding_function_strategy( | |||
|
|||
|
|||
@dataclass | |||
class Collection: | |||
class ExternalCollection: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you document internal vs external?
## Description of changes *Summarize the changes made by this PR.* - Improvements & Bug fixes - Fix test flakiness mentioned in chroma-core#1716 and seen after. The problem was subtle: - There are three places Collection state is stored: in Hypothesis's Bundle (== test data ~randomly generated according to our models), in our test's `.model` field, and in Chroma itself. - Each test step gets a random Collection from the Bundle. Our test code is responsible for doing stuff with it, modifying the test model, executing operations on Chroma itself, and verifying that model state matches Chroma's state. - Hypothesis's Bundle has (but no longer will once this PR lands) a full Collection model with all internal bookeeping, incl UUID and other fields. So we could have two Collections in the Bundle with the same name but different UUIDs or other fields. In our test's model and in Chroma, there would only be one Collection. - The bug arose when we updated metadata on one Bundle collection, on our model, and in Chroma; then tried to read metadata from another Bundle collection with the same name but different metadata. The fix to this was to read expected collection metadata from our test model, not from the Bundle. I changed line 204 to `_metadata = self.model[coll.name]` instead of `_metadata = coll.metadata`. - To save people others this grief in the future, I created a new `ExternalCollection` model which only contains externally visible Collection data. This simplifies Bundle state for this test and should make it easier to reason about in the future. - I also added the previously failing test cases to protect us from regressions. Since the model is much simpler now they don't give us much, but I feel better knowing they're there and laying the pattern for us to add future test cases. ## Test plan *How are these changes tested?* - [x] Tests pass locally with `pytest` for python, `yarn test` for js ## Documentation Changes *Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the [docs repository](https://github.com/chroma-core/docs)?*
Description of changes
Summarize the changes made by this PR.
The problem was subtle:
.model
field, and in Chroma itself._metadata = self.model[coll.name]
instead of_metadata = coll.metadata
.ExternalCollection
model which only contains externally visible Collection data. This simplifies Bundle state for this test and should make it easier to reason about in the future.Test plan
How are these changes tested?
pytest
for python,yarn test
for jsDocumentation Changes
Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs repository?