Skip to content

feat: support build unknown type with annotation#205

Closed
aftersnow wants to merge 13 commits intomainfrom
support-build-unknown-type-with-annotation
Closed

feat: support build unknown type with annotation#205
aftersnow wants to merge 13 commits intomainfrom
support-build-unknown-type-with-annotation

Conversation

@aftersnow
Copy link
Contributor

No description provided.

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.

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 modelfile generation 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 a modelspec.AnnotationMediaTypeUntested=true annotation, indicating their inferred type, allowing for more flexible and robust modelfile creation.
  • Support for File-Specific Annotations (Flags): The MODEL and CODE commands within a modelfile now support --label flags (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 modelfile generation.
  • 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-types Flag: The command-line flag --ignore-unrecognized-file-types has 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 inspect command's output for model artifact layers now includes a new Flags field, 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

  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.

@aftersnow aftersnow changed the title Support build unknown type with annotation feat: support build unknown type with annotation Jun 17, 2025
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 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.

Choose a reason for hiding this comment

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

medium

This TODO comment highlights an important consideration for a follow-up: when overwriting an existing layer during an attach operation, the existing annotations/flags on that layer should ideally be preserved or merged with any new flags specified for the attachment.

aftersnow added 13 commits June 17, 2025 21:50
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>
@aftersnow aftersnow force-pushed the support-build-unknown-type-with-annotation branch from d47e03b to e4465cd Compare June 17, 2025 13:52
@aftersnow
Copy link
Contributor Author

close this and use #203

@aftersnow aftersnow closed this Jun 18, 2025
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.

1 participant

Comments