Skip to content

[ENH] CLI Browse command #4431

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 10 commits into from
May 5, 2025
Merged

[ENH] CLI Browse command #4431

merged 10 commits into from
May 5, 2025

Conversation

itaismith
Copy link
Contributor

@itaismith itaismith commented May 3, 2025

Description of changes

Adding the chroma browse [collection name] command for a TUI app to browse collections.

Arguments:

  • collection_name (required) - the collection to browse
  • --local - find the collection in a local Chroma server. The CLI will try to connect to a Chroma server on localhost:8000, or stand up a local Chroma frontend if chroma.config.yaml is found in the current working directory.
  • path - data path for local Chroma.
  • config - path for a config file for local Chroma.
  • host - Chroma host with the collection.
  • db - the name of the DB with the collection.

If "local" arguments are not provided, the CLI will assume this is a Cloud collection. If in this case db is not provided, the CLI prompts the user for selecting the DB with the collection.

The code for the TUI app is under rust/cli/tui/collection_browser. The main files are:

  • app_state.rs - defines the state of the app. It also has functions that handle actions sent by the event handler, that should modify the state of the app.
  • events.rs - contains the event handling code in response to different key events, using a sender-receiver pattern. The next method uses tokio::select to handle both UI events and asynchronous operations (loading records, submitting queries). This pattern allows asynchronous operations to not block the UI.
  • mod.rs - contains the main app loop. On every iteration, we handle incoming events, fire asynchronous tasks, and draw the UI.

Test plan

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

Documentation Changes

In a separate PR

Copy link

github-actions bot commented May 3, 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 force-pushed the itai/cli-browser branch from 7f3ad1a to b203660 Compare May 3, 2025 05:04
@itaismith itaismith requested a review from codetheweb May 3, 2025 05:04
@itaismith itaismith force-pushed the itai/cli-browser branch from 412e817 to cace3a2 Compare May 4, 2025 23:05
@itaismith itaismith merged commit 7057b2d into main May 5, 2025
70 checks passed
warpbuild-benchmark-bot bot added a commit to WarpBuilds/chroma that referenced this pull request May 5, 2025
documents: Option<Vec<Option<String>>>,
uris: Option<Vec<Option<String>>>,
metadatas: Option<Vec<Option<Metadata>>>,
pub ids: Vec<String>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are these made pub?

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 am constructing this payload for the CLI client's add requests. I can convert to using a new function instead.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't expose these as pub. It deviates from other payloads. If you want to reuse this struct outside this crate please add a new() function that can package it for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. I'll issue a fix shortly

Inventrohyder pushed a commit to Inventrohyder/chroma that referenced this pull request Aug 5, 2025
## Description of changes

Adding the `chroma browse [collection name]` command for a TUI app to
browse collections.

Arguments:
* `collection_name` (required) - the collection to browse
* `--local` - find the collection in a local Chroma server. The CLI will
try to connect to a Chroma server on localhost:8000, or stand up a local
Chroma frontend if `chroma.config.yaml` is found in the current working
directory.
* `path` - data path for local Chroma.
* `config` - path for a config file for local Chroma.
* `host` - Chroma host with the collection.
* `db` - the name of the DB with the collection.

If "local" arguments are not provided, the CLI will assume this is a
Cloud collection. If in this case `db` is not provided, the CLI prompts
the user for selecting the DB with the collection.

The code for the TUI app is under `rust/cli/tui/collection_browser`. The
main files are:
* `app_state.rs` - defines the state of the app. It also has functions
that handle actions sent by the event handler, that should modify the
state of the app.
* `events.rs` - contains the event handling code in response to
different key events, using a sender-receiver pattern. The `next` method
uses `tokio::select` to handle both UI events and asynchronous
operations (loading records, submitting queries). This pattern allows
asynchronous operations to not block the UI.
* `mod.rs` - contains the main app loop. On every iteration, we handle
incoming events, fire asynchronous tasks, and draw the UI.

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

## Documentation Changes
In a separate PR
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