Skip to content

[ENH] Bundle CLI in JS client #4200

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

Merged
merged 23 commits into from
Apr 8, 2025
Merged

[ENH] Bundle CLI in JS client #4200

merged 23 commits into from
Apr 8, 2025

Conversation

itaismith
Copy link
Contributor

@itaismith itaismith commented Apr 7, 2025

Description of changes

The rust/js_bindings crate is a napi project exposing the CLI entry point in src/lib.rs.

Inside this crate there is also an npm directory defining platform specific packages for these JS bindings. Note that every package specifies the platform it supports. These packages are published by the build-js-bindings.yml workflow.

Our main JS client, clients/js/packages/chromadb, specifies all platforms as optional dependencies. When npm install chromadbing, the correct optional dependency will be installed. There, bindings.ts exposes that package to cli.ts, where we wrap the entry point.

Follow up work:

  • Script for better local dev experience.
  • Update JS release runbook for updating bindings versions.

Test plan

How are these changes tested?

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

Documentation Changes

Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs repository?

Copy link

github-actions bot commented Apr 7, 2025

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)

@itaismith itaismith requested a review from codetheweb April 7, 2025 22:58
Copy link
Contributor

@codetheweb codetheweb left a comment

Choose a reason for hiding this comment

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

how do we plan on versioning the bindings packages?

@itaismith
Copy link
Contributor Author

@codetheweb I think for versioning, we should follow the same schema for the python bindings if any. The plan is to create the full set of bindings for JS too eventually

@itaismith itaismith requested a review from codetheweb April 8, 2025 06:58
@codetheweb
Copy link
Contributor

@codetheweb I think for versioning, we should follow the same schema for the python bindings if any. The plan is to create the full set of bindings for JS too eventually

Ok, should the version for each platform package (e.x. rust/js_bindings/npm/darwin-arm64/package.json) be set to the same version as chromadb then? Is the plan to manually update each platform package before publishing? Maybe we should document that somewhere.

@codetheweb
Copy link
Contributor

@codetheweb I think for versioning, we should follow the same schema for the python bindings if any. The plan is to create the full set of bindings for JS too eventually

Ok, should the version for each platform package (e.x. rust/js_bindings/npm/darwin-arm64/package.json) be set to the same version as chromadb then? Is the plan to manually update each platform package before publishing? Maybe we should document that somewhere.

Never mind, sorry. Just saw your follow-up task in OP.

@itaismith
Copy link
Contributor Author

@codetheweb I think for versioning, we should follow the same schema for the python bindings if any. The plan is to create the full set of bindings for JS too eventually

Ok, should the version for each platform package (e.x. rust/js_bindings/npm/darwin-arm64/package.json) be set to the same version as chromadb then? Is the plan to manually update each platform package before publishing? Maybe we should document that somewhere.

Never mind, sorry. Just saw your follow-up task in OP.

It's ok, we'll work it out on the remix

uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
Copy link
Contributor

Choose a reason for hiding this comment

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

did using our rust setup action not work here? we should ideally use it not just for dry but also because it reads from rust-toolchain.toml as the source of truth for the toolchain version
it also uses sccache so you don't need to handle caching (not entirely convinced the cache action setup here is correct)

@itaismith itaismith merged commit 3f21885 into main Apr 8, 2025
82 checks passed
philipkiely-baseten pushed a commit to philipkiely-baseten/chroma that referenced this pull request Apr 8, 2025
## Description of changes

The `rust/js_bindings` crate is a `napi` project exposing the CLI entry
point in
[`src/lib.rs`](https://github.com/chroma-core/chroma/blob/main/rust/js_bindings/src/lib.rs).

Inside this crate there is also an `npm` directory defining platform
specific packages for these JS bindings. Note that every package
specifies the platform it supports. These packages are published by the
`build-js-bindings.yml` workflow.

Our main JS client, `clients/js/packages/chromadb`, specifies all
platforms as optional dependencies. When `npm install chromadb`ing, the
correct optional dependency will be installed. There, `bindings.ts`
exposes that package to `cli.ts`, where we wrap the entry point.

Follow up work:
- Script for better local dev experience.
- Update JS release runbook for updating bindings versions.

## Test plan
*How are these changes tested?*

- [ ] Tests pass locally with `pytest` for python, `yarn test` for js,
`cargo test` for rust

## 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)?*
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