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

Commit 16a3ce0

Browse files
author
Piotr Stankiewicz
committed
Allow unloading multiple models at once
Adapt CLI to docker/model-runner#56 Signed-off-by: Piotr Stankiewicz <[email protected]>
1 parent d2088f4 commit 16a3ce0

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

commands/unload.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,12 @@ func newUnloadCmd() *cobra.Command {
1212
var all bool
1313
var backend string
1414

15-
cmdArgs := "(MODEL [--backend BACKEND] | --all)"
15+
cmdArgs := "(MODEL [MODEL ...] [--backend BACKEND] | --all)"
1616
c := &cobra.Command{
1717
Use: "unload " + cmdArgs,
1818
Short: "Unload running models",
19-
RunE: func(cmd *cobra.Command, args []string) error {
20-
var model string
21-
if len(args) > 0 {
22-
model = args[0]
23-
}
24-
unloadResp, err := desktopClient.Unload(desktop.UnloadRequest{All: all, Backend: backend, Model: model})
19+
RunE: func(cmd *cobra.Command, models []string) error {
20+
unloadResp, err := desktopClient.Unload(desktop.UnloadRequest{All: all, Backend: backend, Models: models})
2521
if err != nil {
2622
err = handleClientError(err, "Failed to unload models")
2723
return handleNotRunningError(err)
@@ -58,9 +54,6 @@ func newUnloadCmd() *cobra.Command {
5854
"See 'docker model unload --help' for more information.",
5955
)
6056
}
61-
if len(args) > 1 {
62-
return fmt.Errorf("too many arguments, expected " + cmdArgs)
63-
}
6457
return nil
6558
}
6659
c.Flags().BoolVar(&all, "all", false, "Unload all running models")

desktop/desktop.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,9 @@ func (c *Client) DF() (DiskUsage, error) {
501501

502502
// UnloadRequest to be imported from docker/model-runner when https://github.com/docker/model-runner/pull/46 is merged.
503503
type UnloadRequest struct {
504-
All bool `json:"all"`
505-
Backend string `json:"backend"`
506-
Model string `json:"model"`
504+
All bool `json:"all"`
505+
Backend string `json:"backend"`
506+
Models []string `json:"models"`
507507
}
508508

509509
// UnloadResponse to be imported from docker/model-runner when https://github.com/docker/model-runner/pull/46 is merged.

docs/reference/docker_model_unload.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
command: docker model unload
22
short: Unload running models
33
long: Unload running models
4-
usage: docker model unload (MODEL [--backend BACKEND] | --all)
4+
usage: docker model unload (MODEL [MODEL ...] [--backend BACKEND] | --all)
55
pname: docker model
66
plink: docker_model.yaml
77
options:

0 commit comments

Comments
 (0)