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

Commit 22de2db

Browse files
committed
rm: show untagged model information
Signed-off-by: Dorin Geman <[email protected]>
1 parent 9c96344 commit 22de2db

File tree

21 files changed

+248
-120
lines changed

21 files changed

+248
-120
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 & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"time"
1414

1515
"github.com/docker/go-units"
16-
16+
"github.com/docker/model-distribution/distribution"
1717
"github.com/docker/model-runner/pkg/inference"
1818
dmrm "github.com/docker/model-runner/pkg/inference/models"
1919
"github.com/docker/model-runner/pkg/inference/scheduling"
@@ -443,20 +443,34 @@ func (c *Client) Remove(models []string, force bool) (string, error) {
443443
}
444444
defer resp.Body.Close()
445445

446-
if resp.StatusCode != http.StatusOK {
446+
var bodyStr string
447+
body, err := io.ReadAll(resp.Body)
448+
if err != nil {
449+
bodyStr = fmt.Sprintf("(failed to read response body: %v)", err)
450+
} else {
451+
bodyStr = string(body)
452+
}
453+
454+
if resp.StatusCode == http.StatusOK {
455+
var deleteResponse distribution.DeleteModelResponse
456+
if err := json.Unmarshal(body, &deleteResponse); err != nil {
457+
modelRemoved += fmt.Sprintf("Model %s removed successfully, but failed to parse response: %v\n", model, err)
458+
} else {
459+
for _, msg := range deleteResponse {
460+
if msg.Untagged != nil {
461+
modelRemoved += fmt.Sprintf("Untagged: %s\n", *msg.Untagged)
462+
}
463+
if msg.Deleted != nil {
464+
modelRemoved += fmt.Sprintf("Deleted: %s\n", *msg.Deleted)
465+
}
466+
}
467+
}
468+
} else {
447469
if resp.StatusCode == http.StatusNotFound {
448470
return modelRemoved, fmt.Errorf("no such model: %s", model)
449471
}
450-
var bodyStr string
451-
body, err := io.ReadAll(resp.Body)
452-
if err != nil {
453-
bodyStr = fmt.Sprintf("(failed to read response body: %v)", err)
454-
} else {
455-
bodyStr = string(body)
456-
}
457472
return modelRemoved, fmt.Errorf("removing %s failed with status %s: %s", model, resp.Status, bodyStr)
458473
}
459-
modelRemoved += fmt.Sprintf("Model %s removed successfully\n", model)
460474
}
461475
return modelRemoved, nil
462476
}

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)