Skip to content

Commit 0e9ebc9

Browse files
committed
fix(lint): resolve GCI import formatting and ModelConfig interface issues
- Fix GCI import formatting in modelpack package (remove extra blank lines, sort alphabetically) - Update list.go to use ModelConfig getter methods instead of direct field access - Fix list_test.go to use pointer receiver (&types.Config) to satisfy ModelConfig interface
1 parent 89379b0 commit 0e9ebc9

File tree

5 files changed

+18
-21
lines changed

5 files changed

+18
-21
lines changed

cmd/cli/commands/list.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/docker/model-runner/cmd/cli/commands/formatter"
1515
"github.com/docker/model-runner/cmd/cli/desktop"
1616
"github.com/docker/model-runner/cmd/cli/pkg/standalone"
17+
"github.com/docker/model-runner/pkg/distribution/types"
1718
dmrm "github.com/docker/model-runner/pkg/inference/models"
1819
"github.com/olekukonko/tablewriter"
1920
"github.com/spf13/cobra"
@@ -258,10 +259,10 @@ func appendRow(table *tablewriter.Table, tag string, model dmrm.Model) {
258259
// Strip default "ai/" prefix and ":latest" tag for display
259260
displayTag := stripDefaultsFromModelName(tag)
260261
contextSize := ""
261-
if model.Config.ContextSize != nil {
262-
contextSize = fmt.Sprintf("%d", *model.Config.ContextSize)
263-
} else if model.Config.GGUF != nil {
264-
if v, ok := model.Config.GGUF["llama.context_length"]; ok {
262+
if model.Config.GetContextSize() != nil {
263+
contextSize = fmt.Sprintf("%d", *model.Config.GetContextSize())
264+
} else if dockerConfig, ok := model.Config.(*types.Config); ok && dockerConfig.GGUF != nil {
265+
if v, ok := dockerConfig.GGUF["llama.context_length"]; ok {
265266
if parsed, err := strconv.ParseUint(v, 10, 64); err == nil {
266267
contextSize = fmt.Sprintf("%d", parsed)
267268
} else {
@@ -272,13 +273,13 @@ func appendRow(table *tablewriter.Table, tag string, model dmrm.Model) {
272273

273274
table.Append([]string{
274275
displayTag,
275-
model.Config.Parameters,
276-
model.Config.Quantization,
277-
model.Config.Architecture,
276+
model.Config.GetParameters(),
277+
model.Config.GetQuantization(),
278+
model.Config.GetArchitecture(),
278279
model.ID[7:19],
279280
units.HumanDuration(time.Since(time.Unix(model.Created, 0))) + " ago",
280281
contextSize,
281-
model.Config.Size,
282+
model.Config.GetSize(),
282283
})
283284
}
284285

cmd/cli/commands/list_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func testModel(id string, tags []string, created int64) dmrm.Model {
1515
ID: id,
1616
Tags: tags,
1717
Created: created,
18-
Config: types.Config{
18+
Config: &types.Config{
1919
Parameters: "7B",
2020
Quantization: "Q4_0",
2121
Architecture: "llama",
@@ -177,7 +177,7 @@ func TestListModelsSingleModel(t *testing.T) {
177177
ID: "sha256:123456789012345678901234567890123456789012345678901234567890abcd",
178178
Tags: []string{"single:latest"},
179179
Created: 1000,
180-
Config: types.Config{
180+
Config: &types.Config{
181181
Parameters: "7B",
182182
Quantization: "Q4_0",
183183
Architecture: "llama",
@@ -234,7 +234,7 @@ func TestPrettyPrintModelsWithSortedInput(t *testing.T) {
234234
ID: "sha256:123456789012345678901234567890123456789012345678901234567890abcd",
235235
Tags: []string{"ai/apple:latest"},
236236
Created: 1000,
237-
Config: types.Config{
237+
Config: &types.Config{
238238
Parameters: "7B",
239239
Quantization: "Q4_0",
240240
Architecture: "llama",
@@ -245,7 +245,7 @@ func TestPrettyPrintModelsWithSortedInput(t *testing.T) {
245245
ID: "sha256:223456789012345678901234567890123456789012345678901234567890abcd",
246246
Tags: []string{"ai/banana:v1"},
247247
Created: 2000,
248-
Config: types.Config{
248+
Config: &types.Config{
249249
Parameters: "13B",
250250
Quantization: "Q4_K_M",
251251
Architecture: "llama",
@@ -282,7 +282,7 @@ func TestPrettyPrintModelsWithMultipleTags(t *testing.T) {
282282
ID: "sha256:123456789012345678901234567890123456789012345678901234567890abcd",
283283
Tags: []string{"qwen3:8B-Q4_K_M", "qwen3:latest", "qwen3:0.6B-F16"},
284284
Created: 1000,
285-
Config: types.Config{
285+
Config: &types.Config{
286286
Parameters: "8B",
287287
Quantization: "Q4_K_M",
288288
Architecture: "qwen3",

pkg/distribution/modelpack/convert.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ import (
55
"fmt"
66
"strings"
77

8-
"github.com/opencontainers/go-digest"
9-
10-
v1 "github.com/docker/model-runner/pkg/go-containerregistry/pkg/v1"
11-
128
"github.com/docker/model-runner/pkg/distribution/types"
9+
v1 "github.com/docker/model-runner/pkg/go-containerregistry/pkg/v1"
10+
"github.com/opencontainers/go-digest"
1311
)
1412

1513
// IsModelPackMediaType checks if the given media type indicates a CNCF ModelPack format.

pkg/distribution/modelpack/convert_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import (
55
"testing"
66
"time"
77

8-
"github.com/opencontainers/go-digest"
9-
108
"github.com/docker/model-runner/pkg/distribution/types"
9+
"github.com/opencontainers/go-digest"
1110
)
1211

1312
func TestIsModelPackMediaType(t *testing.T) {

pkg/distribution/modelpack/types.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ import (
1414
"strings"
1515
"time"
1616

17-
"github.com/opencontainers/go-digest"
18-
1917
"github.com/docker/model-runner/pkg/distribution/types"
18+
"github.com/opencontainers/go-digest"
2019
)
2120

2221
const (

0 commit comments

Comments
 (0)