-
Notifications
You must be signed in to change notification settings - Fork 120
refactor: normalize ModelPack config to Docker format in API responses #875
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,9 +3,29 @@ package models | |
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/docker/model-runner/pkg/distribution/modelpack" | ||
| "github.com/docker/model-runner/pkg/distribution/types" | ||
| ) | ||
|
|
||
| // normalizeConfig converts a ModelPack config to Docker format types.Config | ||
| // so that the API wire format is always consistent. This ensures clients | ||
| // don't need to understand both config formats. | ||
| func normalizeConfig(cfg types.ModelConfig) types.ModelConfig { | ||
| if cfg == nil { | ||
| return nil | ||
| } | ||
| if _, ok := cfg.(*modelpack.Model); ok { | ||
| return &types.Config{ | ||
| Format: cfg.GetFormat(), | ||
| Parameters: cfg.GetParameters(), | ||
| Quantization: cfg.GetQuantization(), | ||
| Architecture: cfg.GetArchitecture(), | ||
| Size: cfg.GetSize(), | ||
| } | ||
|
Comment on lines
+18
to
+24
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The return &types.Config{
Format: cfg.GetFormat(),
Parameters: cfg.GetParameters(),
Quantization: cfg.GetQuantization(),
Architecture: cfg.GetArchitecture(),
Size: cfg.GetSize(),
ContextSize: cfg.GetContextSize(),
}References
|
||
| } | ||
| return cfg | ||
| } | ||
|
|
||
| func ToModel(m types.Model) (*Model, error) { | ||
| desc, err := m.Descriptor() | ||
| if err != nil { | ||
|
|
@@ -31,7 +51,7 @@ func ToModel(m types.Model) (*Model, error) { | |
| ID: id, | ||
| Tags: m.Tags(), | ||
| Created: created, | ||
| Config: cfg, | ||
| Config: normalizeConfig(cfg), | ||
| }, nil | ||
| } | ||
|
|
||
|
|
@@ -62,6 +82,6 @@ func ToModelFromArtifact(artifact types.ModelArtifact) (*Model, error) { | |
| ID: id, | ||
| Tags: nil, // Remote models don't have local tags | ||
| Created: created, | ||
| Config: cfg, | ||
| Config: normalizeConfig(cfg), | ||
| }, nil | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.