Skip to content

[ENH] add example of forking using github repos #4413

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 1 commit into from
May 6, 2025
Merged

Conversation

jairad26
Copy link
Contributor

@jairad26 jairad26 commented Apr 30, 2025

Description of changes

This PR adds an example notebook to show forking usage with github repos and branching. It creates a custom chunker using tree sitter to generate embeddable chunks of code, and a github helper to pull file info, track diffs between branches. it then uses chroma cloud to index and adds a github repo into a collection, and based on the branch provided creates a fork of the collection, calculates the diff between the original branch and the new branch, deletes chunks from the new branch that correspond to the diffed files, and rechunks and reinserts them.

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 section?

Copy link
Contributor Author

jairad26 commented Apr 30, 2025

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)

@jairad26 jairad26 force-pushed the jai/fork-notebook branch 3 times, most recently from 4142605 to 1ab410d Compare April 30, 2025 23:47
@jairad26 jairad26 marked this pull request as ready for review May 1, 2025 16:58
@jairad26 jairad26 changed the base branch from jai/df-query-res to graphite-base/4413 May 5, 2025 16:56
@jairad26 jairad26 force-pushed the graphite-base/4413 branch from a5eb712 to dd6d176 Compare May 5, 2025 16:56
@jairad26 jairad26 force-pushed the jai/fork-notebook branch from 1ab410d to b0e30ac Compare May 5, 2025 16:56
@jairad26 jairad26 changed the base branch from graphite-base/4413 to main May 5, 2025 16:56
@jairad26 jairad26 force-pushed the jai/fork-notebook branch 2 times, most recently from be5bb4d to 64bbb43 Compare May 5, 2025 20:08
@jairad26 jairad26 force-pushed the jai/fork-notebook branch from 64bbb43 to c54e0ca Compare May 6, 2025 01:52
@HammadB HammadB merged commit a5d64e2 into main May 6, 2025
71 checks passed
"metadata": {},
"source": [
"## Forking\n",
"ChromaDB now supports forking. Below is an example using forking to chunk and embed a github repo, fork off of the collection for a new github branch, and apply diffs to the new branch."
Copy link
Collaborator

Choose a reason for hiding this comment

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

ChromaDB -> Chroma

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also worth mentioning this is only supported in Distributed Chroma / Chroma Cloud.

"source": [
"\n",
"PY_LANGUAGE = get_language(\"python\")\n",
"REPO_OWNER = \"jairad26\"\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

bit strange to have your personal repo here

"REPO_OWNER = \"jairad26\"\n",
"REPO_NAME = \"Django-WebApp\"\n",
"EXISTING_BRANCH = \"main\"\n",
"NEW_BRANCH = \"test1\"\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we call this demo etc instead?

"cell_type": "markdown",
"metadata": {},
"source": [
"### Chunker and Github Helpers\n",
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 collapse / hide this region by default?

" \"file_path\": file_path,\n",
" \"size\": chunk[\"size\"],\n",
" # \"node_types\": str([n[\"type\"] for n in chunk[\"nodes\"]]),\n",
" # \"node_names\": str([n[\"name\"] for n in chunk[\"nodes\"] if n[\"name\"]]),\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

there is a bunch of commented out code here?

"name": "stdout",
"output_type": "stream",
"text": [
" metadata document distance\n",
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 make this output more legible?

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