Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Commit b9e81cf

Browse files
committed
rm: show untagged model information
Signed-off-by: Dorin Geman <[email protected]>
1 parent 301126a commit b9e81cf

File tree

21 files changed

+248
-119
lines changed

21 files changed

+248
-119
lines changed

commands/rm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func newRemoveCmd() *cobra.Command {
2929
}
3030
response, err := desktopClient.Remove(args, force)
3131
if response != "" {
32-
cmd.Println(response)
32+
cmd.Print(response)
3333
}
3434
if err != nil {
3535
err = handleClientError(err, "Failed to remove model")

desktop/desktop.go

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"strings"
1313
"time"
1414

15+
"github.com/docker/model-distribution/distribution"
1516
"github.com/docker/model-runner/pkg/inference"
1617
dmrm "github.com/docker/model-runner/pkg/inference/models"
1718
"github.com/docker/model-runner/pkg/inference/scheduling"
@@ -429,20 +430,34 @@ func (c *Client) Remove(models []string, force bool) (string, error) {
429430
}
430431
defer resp.Body.Close()
431432

432-
if resp.StatusCode != http.StatusOK {
433+
var bodyStr string
434+
body, err := io.ReadAll(resp.Body)
435+
if err != nil {
436+
bodyStr = fmt.Sprintf("(failed to read response body: %v)", err)
437+
} else {
438+
bodyStr = string(body)
439+
}
440+
441+
if resp.StatusCode == http.StatusOK {
442+
var deleteResponse distribution.DeleteModelResponse
443+
if err := json.Unmarshal(body, &deleteResponse); err != nil {
444+
modelRemoved += fmt.Sprintf("Model %s removed successfully, but failed to parse response: %v\n", model, err)
445+
} else {
446+
for _, msg := range deleteResponse {
447+
if msg.Untagged != nil {
448+
modelRemoved += fmt.Sprintf("Untagged: %s\n", *msg.Untagged)
449+
}
450+
if msg.Deleted != nil {
451+
modelRemoved += fmt.Sprintf("Deleted: %s\n", *msg.Deleted)
452+
}
453+
}
454+
}
455+
} else {
433456
if resp.StatusCode == http.StatusNotFound {
434457
return modelRemoved, fmt.Errorf("no such model: %s", model)
435458
}
436-
var bodyStr string
437-
body, err := io.ReadAll(resp.Body)
438-
if err != nil {
439-
bodyStr = fmt.Sprintf("(failed to read response body: %v)", err)
440-
} else {
441-
bodyStr = string(body)
442-
}
443459
return modelRemoved, fmt.Errorf("removing %s failed with status %s: %s", model, resp.Status, bodyStr)
444460
}
445-
modelRemoved += fmt.Sprintf("Model %s removed successfully\n", model)
446461
}
447462
return modelRemoved, nil
448463
}

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ require (
1111
github.com/docker/docker v28.2.2+incompatible
1212
github.com/docker/go-connections v0.5.0
1313
github.com/docker/go-units v0.5.0
14-
github.com/docker/model-distribution v0.0.0-20250627163720-aff34abcf3e0
15-
github.com/docker/model-runner v0.0.0-20250627142917-26a0a73fbbc0
14+
github.com/docker/model-distribution v0.0.0-20250710123110-a633223e127e
15+
github.com/docker/model-runner v0.0.0-20250711130825-8907b3ddf82e
1616
github.com/google/go-containerregistry v0.20.6
1717
github.com/mattn/go-isatty v0.0.17
1818
github.com/nxadm/tail v1.4.8

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ github.com/docker/go-metrics v0.0.1/go.mod h1:cG1hvH2utMXtqgqqYE9plW6lDxS3/5ayHz
7878
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
7979
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
8080
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE=
81-
github.com/docker/model-distribution v0.0.0-20250627163720-aff34abcf3e0 h1:bve4JZI06Admw+NewtPfrpJXsvRnGKTQvBOEICNC1C0=
82-
github.com/docker/model-distribution v0.0.0-20250627163720-aff34abcf3e0/go.mod h1:dThpO9JoG5Px3i+rTluAeZcqLGw8C0qepuEL4gL2o/c=
83-
github.com/docker/model-runner v0.0.0-20250627142917-26a0a73fbbc0 h1:yajuhlGe1xhpWW3eMehQi2RrqiBQiGoi6c6OWiPxMaQ=
84-
github.com/docker/model-runner v0.0.0-20250627142917-26a0a73fbbc0/go.mod h1:vZJiUZH/7O1CyNsEGi1o4khUT4DVRjcwluuamU9fhuM=
81+
github.com/docker/model-distribution v0.0.0-20250710123110-a633223e127e h1:qBkjP4A20f3RXvtstitIPiStQ4p+bK8xcjosrXLBQZ0=
82+
github.com/docker/model-distribution v0.0.0-20250710123110-a633223e127e/go.mod h1:dThpO9JoG5Px3i+rTluAeZcqLGw8C0qepuEL4gL2o/c=
83+
github.com/docker/model-runner v0.0.0-20250711130825-8907b3ddf82e h1:oafd84kAFBgv/DAYgtXGLkC1KmRpDN+7G3be5+2+hA0=
84+
github.com/docker/model-runner v0.0.0-20250711130825-8907b3ddf82e/go.mod h1:QmSoUNAbqolMY1Aq9DaC+sR/M/OPga0oCT/DBA1z9ow=
8585
github.com/dvsekhvalnov/jose2go v0.0.0-20170216131308-f21a8cedbbae/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM=
8686
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
8787
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=

vendor/github.com/docker/model-distribution/builder/builder.go

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/model-distribution/distribution/client.go

Lines changed: 35 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/model-distribution/internal/partial/partial.go

Lines changed: 14 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/model-distribution/internal/progress/reporter.go

Lines changed: 28 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/model-distribution/internal/store/index.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/model-distribution/internal/store/model.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)