-
Notifications
You must be signed in to change notification settings - Fork 79
Add reinstall-runner command implementation #232
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package commands | ||
|
|
||
| import ( | ||
| "github.com/docker/model-runner/cmd/cli/commands/completion" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func newReinstallRunner() *cobra.Command { | ||
| var port uint16 | ||
| var host string | ||
| var gpuMode string | ||
| var doNotTrack bool | ||
| c := &cobra.Command{ | ||
| Use: "reinstall-runner", | ||
| Short: "Reinstall Docker Model Runner (Docker Engine only)", | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| return runInstallOrStart(cmd, runnerOptions{ | ||
| port: port, | ||
| host: host, | ||
| gpuMode: gpuMode, | ||
| doNotTrack: doNotTrack, | ||
| pullImage: true, | ||
| pruneContainers: true, | ||
| }) | ||
| }, | ||
| ValidArgsFunction: completion.NoComplete, | ||
| } | ||
| c.Flags().Uint16Var(&port, "port", 0, | ||
| "Docker container port for Docker Model Runner (default: 12434 for Docker Engine, 12435 for Cloud mode)") | ||
| c.Flags().StringVar(&host, "host", "127.0.0.1", "Host address to bind Docker Model Runner") | ||
| c.Flags().StringVar(&gpuMode, "gpu", "auto", "Specify GPU support (none|auto|cuda)") | ||
| c.Flags().BoolVar(&doNotTrack, "do-not-track", false, "Do not track models usage in Docker Model Runner") | ||
| return c | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| package commands | ||
|
|
||
| import ( | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestReinstallRunnerHostFlag(t *testing.T) { | ||
| testCases := []struct { | ||
| name string | ||
| value string | ||
| }{ | ||
| {"localhost", "127.0.0.1"}, | ||
| {"all_interfaces", "0.0.0.0"}, | ||
| {"specific_IP", "192.168.1.100"}, | ||
| } | ||
|
|
||
| for _, tc := range testCases { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| // Reset the command for each test | ||
| cmd := newReinstallRunner() | ||
| err := cmd.Flags().Set("host", tc.value) | ||
| if err != nil { | ||
| t.Errorf("Failed to set host flag to '%s': %v", tc.value, err) | ||
| } | ||
ericcurtin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Verify the value was set | ||
| hostValue, err := cmd.Flags().GetString("host") | ||
| if err != nil { | ||
| t.Errorf("Failed to get host flag value: %v", err) | ||
| } | ||
ericcurtin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if hostValue != tc.value { | ||
| t.Errorf("Expected host value to be '%s', got '%s'", tc.value, hostValue) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestReinstallRunnerCommandFlags(t *testing.T) { | ||
| cmd := newReinstallRunner() | ||
|
|
||
| // Verify all expected flags exist | ||
| expectedFlags := []string{"port", "host", "gpu", "do-not-track"} | ||
| for _, flagName := range expectedFlags { | ||
| if cmd.Flags().Lookup(flagName) == nil { | ||
| t.Errorf("Expected flag '--%s' not found", flagName) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func TestReinstallRunnerCommandType(t *testing.T) { | ||
| cmd := newReinstallRunner() | ||
|
|
||
| // Verify command properties | ||
| if cmd.Use != "reinstall-runner" { | ||
| t.Errorf("Expected command Use to be 'reinstall-runner', got '%s'", cmd.Use) | ||
| } | ||
|
|
||
| if cmd.Short != "Reinstall Docker Model Runner (Docker Engine only)" { | ||
| t.Errorf("Unexpected command Short description: %s", cmd.Short) | ||
| } | ||
|
|
||
| // Verify RunE is set | ||
| if cmd.RunE == nil { | ||
| t.Error("Expected RunE to be set") | ||
| } | ||
| } | ||
|
|
||
| func TestReinstallRunnerValidArgsFunction(t *testing.T) { | ||
| cmd := newReinstallRunner() | ||
|
|
||
| // The reinstall-runner command should not accept any arguments | ||
| // So ValidArgsFunction should be set to handle no arguments | ||
| if cmd.ValidArgsFunction == nil { | ||
| t.Error("Expected ValidArgsFunction to be set") | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| command: docker model reinstall-runner | ||
| short: Reinstall Docker Model Runner (Docker Engine only) | ||
| long: | | ||
| This command removes the existing Docker Model Runner container and reinstalls it with the specified configuration. Models and images are preserved during reinstallation. | ||
| usage: docker model reinstall-runner | ||
| pname: docker model | ||
| plink: docker_model.yaml | ||
| options: | ||
| - option: do-not-track | ||
| value_type: bool | ||
| default_value: "false" | ||
| description: Do not track models usage in Docker Model Runner | ||
| deprecated: false | ||
| hidden: false | ||
| experimental: false | ||
| experimentalcli: false | ||
| kubernetes: false | ||
| swarm: false | ||
| - option: gpu | ||
| value_type: string | ||
| default_value: auto | ||
| description: Specify GPU support (none|auto|cuda) | ||
| deprecated: false | ||
| hidden: false | ||
| experimental: false | ||
| experimentalcli: false | ||
| kubernetes: false | ||
| swarm: false | ||
| - option: host | ||
| value_type: string | ||
| default_value: 127.0.0.1 | ||
| description: Host address to bind Docker Model Runner | ||
| deprecated: false | ||
| hidden: false | ||
| experimental: false | ||
| experimentalcli: false | ||
| kubernetes: false | ||
| swarm: false | ||
| - option: port | ||
| value_type: uint16 | ||
| default_value: "0" | ||
| description: | | ||
| Docker container port for Docker Model Runner (default: 12434 for Docker Engine, 12435 for Cloud mode) | ||
| deprecated: false | ||
| hidden: false | ||
| experimental: false | ||
| experimentalcli: false | ||
| kubernetes: false | ||
| swarm: false | ||
| deprecated: false | ||
| hidden: false | ||
| experimental: false | ||
| experimentalcli: false | ||
| kubernetes: false | ||
| swarm: false | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # docker model reinstall-runner | ||
|
|
||
| <!---MARKER_GEN_START--> | ||
| Reinstall Docker Model Runner (Docker Engine only) | ||
|
|
||
| ### Options | ||
|
|
||
| | Name | Type | Default | Description | | ||
| |:-----------------|:---------|:------------|:-------------------------------------------------------------------------------------------------------| | ||
| | `--do-not-track` | `bool` | | Do not track models usage in Docker Model Runner | | ||
| | `--gpu` | `string` | `auto` | Specify GPU support (none\|auto\|cuda) | | ||
| | `--host` | `string` | `127.0.0.1` | Host address to bind Docker Model Runner | | ||
| | `--port` | `uint16` | `0` | Docker container port for Docker Model Runner (default: 12434 for Docker Engine, 12435 for Cloud mode) | | ||
|
|
||
|
|
||
| <!---MARKER_GEN_END--> | ||
|
|
||
| ## Description | ||
|
|
||
| This command removes the existing Docker Model Runner container and reinstalls it with the specified configuration. Models and images are preserved during reinstallation. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.