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] Use optional repeated string for query metadata ids argument #2820

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Sicheng-Pan
Copy link
Contributor

@Sicheng-Pan Sicheng-Pan commented Sep 18, 2024

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • Update the type of the ids argument for QueryMetadataRequest from repeated string to optional repeated string. This matches the input type of the query node, which is Option<Vec<String>>.
    • Regenerate Python bindings for the updated type. Updated Python client to use the updated type.
  • New functionality: N/A

Test plan

Tested with existing tests

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Documentation Changes

All user facing APIs remain unchanged.

Copy link

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

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @Sicheng-Pan and the rest of your teammates on Graphite Graphite

Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@Sicheng-Pan Sicheng-Pan changed the title Use optional repeated string for query metadata ids argument [] Use optional repeated string for query metadata ids argument Sep 18, 2024
@Sicheng-Pan Sicheng-Pan changed the title [] Use optional repeated string for query metadata ids argument [BUG] Use optional repeated string for query metadata ids argument Sep 18, 2024
Copy link
Contributor Author

Sicheng-Pan commented Sep 18, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @Sicheng-Pan and the rest of your teammates on Graphite Graphite

@Sicheng-Pan Sicheng-Pan marked this pull request as ready for review September 18, 2024 23:29
@@ -81,6 +81,12 @@ def get_metadata(
) -> Sequence[MetadataEmbeddingRecord]:
"""Query for embedding metadata."""

if limit is not None and limit < 0:
raise ValueError("Limit cannot be negative")
Copy link
Collaborator

@HammadB HammadB Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer a ChromaError with a specific error code, otherwise this manifests as a 500

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a new OutOfBoundError for this scenario

@@ -847,3 +848,508 @@ def test_0dim_embedding_validation() -> None:
with pytest.raises(ValueError) as e:
validate_embeddings(embds)
assert "Expected each embedding in the embeddings to be a non-empty list" in str(e)


def test_integrated(client: ClientAPI) -> None:
Copy link
Collaborator

@HammadB HammadB Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this new test exercising? can we add some documentation around the specific case / is it needed? Was this test breaking before, can we maybe add a more simple reproduction?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a second thought, this test was too complex and was initially a generated test case. It was introduced to debug a previous PR. I'll remove it for now.

@@ -130,6 +130,10 @@ message MetadataEmbeddingRecord {
UpdateMetadata metadata = 2;
}

message UserIds {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: comment what user ids means

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments

@@ -114,7 +114,7 @@ message QueryMetadataRequest {
string segment_id = 1;
Where where = 2;
WhereDocument where_document = 3;
repeated string ids = 4;
optional UserIds ids = 4;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is but is there anywhere else we expect option<vec>? from a proto? we should make the same change elsewhere then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've noticed that GetVectorsRequest and QueryVectorsRequest accept a sequence of string ids, similar to QueryMetadataRequest. In the frontend, get_vectors and query_vectors in grpc_sement.py accepts Optional[Sequence[str]] for these fields, but the caller of these methods explicitly check for the case of empty ids, and the query node is expecting Vec<String> as inputs. I'm unsure whether we should convert these into optional fields as well.

idl/makefile Outdated
@@ -1,5 +1,8 @@
.PHONY: proto

PROTOC_GEN_GO_BIN_PATH := $(if $(shell which protoc-gen-go),$(shell which protoc-gen-go),"${GOPATH}/bin/protoc-gen-go")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: prefer isolated changes to their own PRs as a general practice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isolated the changes in a stacked PR

@Sicheng-Pan Sicheng-Pan force-pushed the 09-18-use_optional_repeated_string_for_query_metadata_ids_argument branch from b456470 to af1fbcf Compare September 19, 2024 20:03
@Sicheng-Pan Sicheng-Pan force-pushed the 09-18-use_optional_repeated_string_for_query_metadata_ids_argument branch from af1fbcf to 087bc97 Compare September 19, 2024 23:55
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

Successfully merging this pull request may close these issues.

2 participants