feat: add support for Safetensors model format error handling#191
feat: add support for Safetensors model format error handling#191ilopezluna merged 2 commits intomainfrom
Conversation
Reviewer's GuideThis PR enforces explicit rejection of Safetensors format in the model distribution client by introducing a new ErrUnsupportedFormat, extending compatibility checks in checkCompat, and adding a dedicated test to verify error handling when pulling safetensors models. Class diagram for updated error handling in model distribution clientclassDiagram
class ModelArtifact {
+Config() ModelConfig
}
class ModelConfig {
+Format: string
}
class Client {
+checkCompat(image: ModelArtifact) error
}
ModelArtifact --> ModelConfig : Config()
Client --> ModelArtifact : checkCompat(image)
Client ..> ErrUnsupportedFormat
class ErrUnsupportedFormat {
<<error>>
}
Flow diagram for Safetensors format rejection in checkCompatflowchart TD
A["checkCompat(image)"] --> B["Read manifest.Config.MediaType"]
B --> C{"MediaType == MediaTypeModelConfigV01?"}
C -- No --> D["Return ErrUnsupportedMediaType"]
C -- Yes --> E["image.Config()"]
E --> F{"config.Format == FormatSafetensors?"}
F -- Yes --> G["Return ErrUnsupportedFormat"]
F -- No --> H["Return nil (success)"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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 enhances the model distribution client by implementing explicit error handling for unsupported Highlights
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.
Pull Request Overview
This pull request adds explicit error handling for unsupported Safetensors model formats in the model distribution client. The implementation ensures that attempts to pull Safetensors models are properly rejected with a clear error message, improving the robustness of the model distribution system.
- Introduces a new error constant
ErrUnsupportedFormatwith a clear message about Safetensors format support - Adds format validation in the
checkCompatfunction to reject Safetensors models - Includes comprehensive test coverage for the new error handling behavior
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/distribution/distribution/errors.go | Adds new error constant for unsupported Safetensors format |
| pkg/distribution/distribution/client.go | Implements format validation to reject Safetensors models in checkCompat function |
| pkg/distribution/distribution/client_test.go | Adds test case to verify proper error handling when pulling Safetensors models |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| config, err := image.Config() | ||
| if err != nil { | ||
| return fmt.Errorf("reading model config: %w", err) | ||
| } |
There was a problem hiding this comment.
[nitpick] The config is retrieved and parsed even when it may not be needed. Consider checking if the config has already been retrieved earlier in the call chain to avoid redundant operations.
There was a problem hiding this comment.
Code Review
This pull request effectively adds error handling for unsupported Safetensors model formats. The changes are clear and well-contained, introducing a new error type and a check in the checkCompat function. A comprehensive test case has been added to validate that pulling a Safetensors model correctly returns the new ErrUnsupportedFormat error. My review includes a minor suggestion to make the test assertion more concise.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This pull request adds explicit handling and error messaging for unsupported
Safetensorsmodel formats in the model distribution client. It ensures that attempts to pullSafetensorsmodels are properly rejected and tested, improving clarity and robustness around supported model types.Summary by Sourcery
Reject safetensors models when pulling via the distribution client by introducing ErrUnsupportedFormat and add tests to validate this behavior
Enhancements:
Tests: