-
Notifications
You must be signed in to change notification settings - Fork 94
feat: migrate legacy hf.co tags to huggingface.co during client initialization #645
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
Conversation
Summary of ChangesHello @ilopezluna, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where models pulled with the legacy Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces an automatic migration of legacy hf.co/ tags to the canonical huggingface.co/ format upon client initialization. This is a valuable fix to prevent cache misses for models downloaded before the normalization was in place. The implementation is clean, with the migration logic well-encapsulated in client.migrateHFTags and store.MigrateTags. The accompanying tests are thorough, covering migration scenarios and ensuring idempotency. I have a couple of minor suggestions to improve the test code's clarity and maintainability.
| migrated, err := s.MigrateTags(func(tag string) string { | ||
| if rest, found := strings.CutPrefix(tag, "hf.co/"); found { | ||
| return "huggingface.co/" + rest | ||
| } | ||
| return tag | ||
| }) | ||
| if err != nil { | ||
| t.Fatalf("MigrateTags failed: %v", err) | ||
| } | ||
|
|
||
| if migrated != 1 { | ||
| t.Errorf("Expected 1 migrated tag, got %d", migrated) | ||
| } | ||
|
|
||
| // Verify the model can be found with the new tag | ||
| if _, err := s.Read("huggingface.co/testorg/testmodel:latest"); err != nil { | ||
| t.Fatalf("Failed to read model with migrated tag: %v", err) | ||
| } | ||
|
|
||
| // Verify the old tag no longer works | ||
| if _, err := s.Read("hf.co/testorg/testmodel:latest"); !errors.Is(err, store.ErrModelNotFound) { | ||
| t.Errorf("Expected ErrModelNotFound for old tag, got: %v", err) | ||
| } | ||
|
|
||
| // Verify the non-HF model is unaffected | ||
| if _, err := s.Read("ai/some-model:latest"); err != nil { | ||
| t.Fatalf("Non-HF model should be unaffected: %v", err) | ||
| } | ||
|
|
||
| // Running migration again should be a no-op | ||
| migrated2, err := s.MigrateTags(func(tag string) string { | ||
| if rest, found := strings.CutPrefix(tag, "hf.co/"); found { | ||
| return "huggingface.co/" + rest | ||
| } | ||
| return tag | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've left some high level feedback:
- The hf.co → huggingface.co transformation logic is now duplicated between
normalizeModelNameandmigrateHFTags; consider factoring this into a shared helper to keep the normalization behavior consistent over time. - Running
MigrateTagson every client initialization will scan the entire index each time; if the index can be large, you may want a cheap early-exit heuristic (e.g., skip if no tags start withhf.co/or record a one-time migration marker) to avoid repeated full scans.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The hf.co → huggingface.co transformation logic is now duplicated between `normalizeModelName` and `migrateHFTags`; consider factoring this into a shared helper to keep the normalization behavior consistent over time.
- Running `MigrateTags` on every client initialization will scan the entire index each time; if the index can be large, you may want a cheap early-exit heuristic (e.g., skip if no tags start with `hf.co/` or record a one-time migration marker) to avoid repeated full scans.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
doringeman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had both the hf.co and huggingface.co models and now I still have both:
huggingface.co/mlx-community/llama-3.2-1b-instruct-4bit 193.15M mixed f130735e0846 12 days ago 695.28MB
huggingface.co/mlx-community/llama-3.2-1b-instruct-4bit 193.15M mixed ce26d33680f4 12 days ago 695.28MB
doringeman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chatted on Zoom, the above is a different issue.
LGTM!
@doringeman Added new issue found here |
Models pulled with
hf.co/before the normalization fix in #617 were stored with un-normalized tags, causing cache misses and duplicate downloads. This adds an automatic tag migration on client startup that rewriteshf.co/→huggingface.co/in the store index, so previously-pulled models are found by the cache check.