Skip to content

Conversation

@avinashsingh77
Copy link
Contributor

@avinashsingh77 avinashsingh77 commented Nov 11, 2025

This PR adds support for providing model_url to modctl modelfile generate
Tests added, run output:

go test ./pkg/hfhub -v
=== RUN   TestParseModelURL
=== RUN   TestParseModelURL/full_URL
=== RUN   TestParseModelURL/full_URL_with_trailing_slash
=== RUN   TestParseModelURL/short_form
=== RUN   TestParseModelURL/http_URL
=== RUN   TestParseModelURL/invalid_format_-_missing_repo
=== RUN   TestParseModelURL/invalid_format_-_only_owner
=== RUN   TestParseModelURL/empty_URL
=== RUN   TestParseModelURL/URL_with_spaces_(trimmed)
--- PASS: TestParseModelURL (0.00s)
    --- PASS: TestParseModelURL/full_URL (0.00s)
    --- PASS: TestParseModelURL/full_URL_with_trailing_slash (0.00s)
    --- PASS: TestParseModelURL/short_form (0.00s)
    --- PASS: TestParseModelURL/http_URL (0.00s)
    --- PASS: TestParseModelURL/invalid_format_-_missing_repo (0.00s)
    --- PASS: TestParseModelURL/invalid_format_-_only_owner (0.00s)
    --- PASS: TestParseModelURL/empty_URL (0.00s)
    --- PASS: TestParseModelURL/URL_with_spaces_(trimmed) (0.00s)
PASS
ok      github.com/modelpack/modctl/pkg/hfhub   (cached)

Closes #308

@gemini-code-assist
Copy link

Summary of Changes

Hello @avinashsingh77, 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 introduces a significant new capability to the modctl tool, allowing users to generate modelfiles directly from models hosted on Hugging Face Hub. By providing a --model_url flag to the modctl modelfile generate command, users can now specify a Hugging Face model, which the tool will automatically download and then use to create the modelfile. This integration simplifies the workflow for developers leveraging Hugging Face models, making it easier to manage and deploy them within the modctl ecosystem.

Highlights

  • Hugging Face Model URL Support: The modctl modelfile generate command now supports generating modelfiles directly from Hugging Face model URLs, using a new --model_url flag.
  • Flexible Input: Users can provide either a local directory path or a Hugging Face model URL (e.g., "owner/repo" or full "https://huggingface.co/owner/repo" format).
  • Hugging Face Integration: A new pkg/hfhub package has been introduced to handle parsing Hugging Face URLs, checking user authentication, and downloading models using the huggingface-cli tool.
  • Command Line Enhancements: The generate command's usage, short description, long description, and examples have been updated to reflect the new functionality, and argument validation now accommodates the optional path when --model_url is used.
  • Robust URL Parsing: Comprehensive unit tests have been added for the ParseModelURL function, ensuring correct handling of various URL formats and edge cases.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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 a valuable feature for generating a modelfile directly from a Hugging Face model URL. The implementation is well-structured, primarily by leveraging the huggingface-cli tool. My review focuses on enhancing user experience, ensuring proper resource management, and improving code clarity. I've suggested making the <path> argument and the --model_url flag mutually exclusive to prevent user confusion, adding cleanup for temporary directories, refining output handling within the hfhub package, and simplifying test logic for better maintainability.

Copy link
Member

@chlins chlins left a comment

Choose a reason for hiding this comment

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

Can we abstract a generic interface for the download part, and then support different drivers or vendors? Because in addition to Hugging Face, there are also model hubs like ModelScope.

@avinashsingh77
Copy link
Contributor Author

avinashsingh77 commented Nov 19, 2025 via email

avinashsingh77 and others added 3 commits November 24, 2025 15:26
Signed-off-by: Avinash Singh <avinashsingh.rcoem@gmail.com>
Signed-off-by: Avinash Singh <avinashsingh.rcoem@gmail.com>
Signed-off-by: Avinash Singh <avinashsingh.rcoem@gmail.com>
@avinashsingh77
Copy link
Contributor Author

@chlins Implemented a provider interface and added providers for HuggingFace and ModelScope as suggested. Does it look okay now?

@avinashsingh77 avinashsingh77 changed the title Add support for modelFile generate via HF model_url Add support for modelFile generate via model providers model_url Nov 24, 2025
@chlins
Copy link
Member

chlins commented Nov 25, 2025

@chlins Implemented a provider interface and added providers for HuggingFace and ModelScope as suggested. Does it look okay now?

@avinashsingh77 Great work! thanks for adding the provider interface with HuggingFace and ModelScope implementations. I'll take a look at the changes in a bit and share my thoughts.

avinashsingh77 and others added 2 commits November 26, 2025 18:33
Signed-off-by: Avinash Singh <avinashsingh.rcoem@gmail.com>
@chlins chlins mentioned this pull request Dec 1, 2025
Signed-off-by: Avinash Singh <avinashsingh.rcoem@gmail.com>
Copy link
Member

@chlins chlins left a comment

Choose a reason for hiding this comment

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

lgtm

@chlins chlins merged commit eac4ac9 into modelpack:main Dec 16, 2025
5 of 8 checks passed
@avinashsingh77 avinashsingh77 deleted the add-hf-support branch December 18, 2025 09:33
avinashsingh77 added a commit to avinashsingh77/modctl that referenced this pull request Dec 22, 2025
…elpack#329)

* Add support for HF model_url

Signed-off-by: Avinash Singh <avinashsingh.rcoem@gmail.com>

* optimise as per gemini's review

Signed-off-by: Avinash Singh <avinashsingh.rcoem@gmail.com>

* add modelprovider interface and providers

Signed-off-by: Avinash Singh <avinashsingh.rcoem@gmail.com>

* optimise code

Signed-off-by: Avinash Singh <avinashsingh.rcoem@gmail.com>

* add optional param for download-dir

Signed-off-by: Avinash Singh <avinashsingh.rcoem@gmail.com>

---------

Signed-off-by: Avinash Singh <avinashsingh.rcoem@gmail.com>
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.

Support converting from huggingface URL

2 participants