feat: support build unknown type with annotation#205
feat: support build unknown type with annotation#205
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @aftersnow, 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 significantly enhances the modelfile generation process by introducing intelligent classification and annotation support for previously unrecognized file types. It also formalizes the ability to attach custom metadata to individual files within the modelfile and strengthens workspace validation with new size and file count limits. These changes aim to make modelfile creation more robust, flexible, and informative.
Highlights
- Enhanced Modelfile Generation for Unknown File Types: The
modelfilegeneration logic has been significantly improved to handle files with unrecognized extensions. Instead of failing or ignoring them, the system now intelligently classifies them: files larger than 128MB are treated as model weights, and smaller ones as code. Both receive amodelspec.AnnotationMediaTypeUntested=trueannotation, indicating their inferred type, allowing for more flexible and robustmodelfilecreation. - Support for File-Specific Annotations (Flags): The
MODELandCODEcommands within amodelfilenow support--labelflags (e.g.,MODEL --label=key=value path/to/file). These annotations are parsed, stored, and then attached to the corresponding OCI descriptor layers during the build process, providing richer metadata for individual files. - Improved Workspace Validation and Limits: New validation checks have been added to ensure the workspace is a valid, non-empty directory and not a symbolic link. Furthermore, hard limits are introduced for the total workspace size (8TB), single file size (128GB), and file count (1024 files) to prevent potential resource exhaustion during
modelfilegeneration. - Expanded File Type Recognition: The internal lists of recognized file patterns for configurations, models, and code have been substantially expanded. This includes a wide array of new extensions for various ML frameworks (PyTorch, TensorFlow, GGML), programming languages, build tools, and document types, improving automatic classification accuracy.
- Deprecation of
ignore-unrecognized-file-typesFlag: The command-line flag--ignore-unrecognized-file-typeshas been deprecated. The new intelligent classification and annotation system for unknown file types renders this flag obsolete, simplifying the user experience. - Enhanced Inspection Output: The
inspectcommand's output for model artifact layers now includes a newFlagsfield, which displays any associated annotations (excluding internal metadata), providing more comprehensive information about the built artifacts.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| 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 issue 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 is currently in preview and 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 to provide feedback.
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
-
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. ↩
There was a problem hiding this comment.
Code Review
This pull request significantly enhances modctl by adding support for annotations (flags) on MODEL and CODE entries in the Modelfile, vastly expanding the range of recognized file types for automatic Modelfile generation, and introducing robust workspace validation including size and file count limits. The handling of unrecognized files is now more intelligent, classifying them and marking them as untested. The deprecation of the ignore-unrecognized-file-types flag is a sensible step forward.
| pb.Start() | ||
| defer pb.Stop() | ||
|
|
||
| // TODO: Copy old flags to the new layer. |
There was a problem hiding this comment.
Signed-off-by: Zhao Chen <zhaochen.zju@gmail.com>
Signed-off-by: Zhao Chen <zhaochen.zju@gmail.com>
Signed-off-by: Zhao Chen <zhaochen.zju@gmail.com>
Signed-off-by: Zhao Chen <zhaochen.zju@gmail.com>
Signed-off-by: Zhao Chen <zhaochen.zju@gmail.com>
Signed-off-by: Zhao Chen <zhaochen.zju@gmail.com>
Added validation in the workspace generation process to enforce limits on single file size (128GB), maximum file count (1024), and total workspace size (8TB). Included unit tests to verify these constraints. Signed-off-by: Zhao Chen <zhaochen.zju@gmail.com>
Updated the model and code processors to accept and utilize file flags, allowing for more flexible processing of model and code files. This includes modifications to the builder interface and related tests to accommodate the new flags functionality. Signed-off-by: Zhao Chen <zhaochen.zju@gmail.com>
Implemented functionality to add an "untested" flag for files processed in the workspace based on their size. Updated the modelfile generation to include these flags in the output, enhancing the tracking of file types. Added unit tests to verify the correct assignment of flags for large and small files. Signed-off-by: Zhao Chen <zhaochen.zju@gmail.com>
Signed-off-by: Zhao Chen <zhaochen.zju@gmail.com>
Signed-off-by: Zhao Chen <zhaochen.zju@gmail.com>
Modified the command parsing logic to only accept --label flags, treating other flags as regular arguments. Updated related unit tests to reflect changes in flag handling and ensure accurate extraction of flag values. Signed-off-by: Zhao Chen <zhaochen.zju@gmail.com>
Signed-off-by: Zhao Chen <zhaochen.zju@gmail.com>
d47e03b to
e4465cd
Compare
|
close this and use #203 |
No description provided.