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

JS client parity and broken out tests #292

Merged
merged 16 commits into from
Apr 18, 2023
Merged

JS client parity and broken out tests #292

merged 16 commits into from
Apr 18, 2023

Conversation

jeffchuber
Copy link
Contributor

@jeffchuber jeffchuber commented Apr 4, 2023

This PR adds full JS client parity with the python client and also breaks out tests into individual files.

Should likely be landed after #297 - so that CI can pick up the tests

After merge, a separate PR will be created to bump the npm version number and cut a new release.

bin/js-test Outdated Show resolved Hide resolved
@jeffchuber jeffchuber changed the title [Draft] try gh actions js tests JS client parity and broken out tests Apr 11, 2023
@jeffchuber jeffchuber requested a review from HammadB April 11, 2023 05:04
@@ -70,6 +70,7 @@ def __init__(self, settings):
self.router.add_api_route("/api/v1", self.root, methods=["GET"])
self.router.add_api_route("/api/v1/reset", self.reset, methods=["POST"])
self.router.add_api_route("/api/v1/version", self.version, methods=["GET"])
self.router.add_api_route("/api/v1/heartbeat", self.heartbeat, methods=["GET"])
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 an explicit url for this to make it easy for our OpenAPI spec to pick it up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the python frontend is still using the "old" route... self.router.add_api_route("/api/v1", self.root, methods=["GET"]), but we could move it over to the new one as well. perhaps it makes sense to do that in this PR? Though having isolation b/t JS and python changes is nice.

"db:clean": "cd ../.. && docker-compose -f docker-compose-js-tests.yml down --volumes",
"db:run": "cd ../.. && docker-compose -f docker-compose-js-tests.yml up --detach && sleep 5",
"db:clean": "cd ../.. && docker-compose -f docker-compose.test.yml down --volumes",
"db:run": "cd ../.. && docker-compose -f docker-compose.test.yml up --detach && sleep 5",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we removed an "extra" docker file, but didnt fix this up.

Copy link
Contributor

@levand levand left a comment

Choose a reason for hiding this comment

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

Thanks for doing these!

IMO (as discussed yesterday) these kind of tests are sufficient for giving confidence that the JS API is talking to the backend successfully.

public async query(
query_embeddings: number[] | number[][] | undefined,
n_results: number = 10,
where?: object,
query_text?: string | string[],
query_text?: string | string[], // TODO: should be named query_texts to match python API
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we complete this TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this would cause a breaking change in the API, and I was trying to constrain this diff to have no breaking changes.

I think we will soon move over to object-based inputs, eg as laid out here #254, and i was planning on making that change then.

thoughts?

}

public async persist() {
throw new Error("Not implemented in JS client")
Copy link
Collaborator

Choose a reason for hiding this comment

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

If a user is connected to a backend with duckdb+parquet, do we want this to work?

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 don't think right now since that is not a formal path we want to support (standing up in-memory chroma as a backend service). What do you think?

const collection = await chroma.createCollection('test')
await collection.add(IDS, EMBEDDINGS)
const count = await collection.count()
expect(count).toBe(3)
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we get the embeddings and verify their contents?

const embedding = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const metadata = { test: 'test' }
await collection.add(id, embedding, metadata)
const count = await collection.count()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we get the embeddings and verify their contents?

await chroma.reset()
const collection = await chroma.createCollection('test')
expect(collection).toBeDefined()
expect(collection).toHaveProperty('name')
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we verify the name is correct?

const collection = await chroma.createCollection('test')
expect(collection).toBeDefined()
expect(collection).toHaveProperty('name')
let collections = await chroma.listCollections()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we test non-null metadata?

Copy link
Collaborator

@HammadB HammadB left a comment

Choose a reason for hiding this comment

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

My main feedback here is that the tests should verify the value of returned results not simply their existence.

@jeffchuber jeffchuber requested a review from HammadB April 15, 2023 04:59
@jeffchuber
Copy link
Contributor Author

@HammadB i went through every test and added verification of values for every test

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.

3 participants