Skip to content

Conversation

@ericcurtin
Copy link
Contributor

@ericcurtin ericcurtin commented Oct 15, 2025

So one can reinstall in one command

Summary by Sourcery

Add a new CLI command to perform a one-step reinstallation of Docker Model Runner in standalone Docker Engine contexts.

New Features:

  • Introduce a reinstall-runner command with flags for port, host, GPU mode, and telemetry control
  • Implement end-to-end reinstallation logic that prunes existing containers, updates the image, ensures storage volume, and recreates the runner container

Documentation:

  • Add CLI reference documentation for the reinstall-runner command

Tests:

  • Add unit tests to validate reinstall-runner command flags and properties

Copilot AI review requested due to automatic review settings October 15, 2025 04:42
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 15, 2025

Reviewer's Guide

This PR adds a new "reinstall-runner" CLI command for Docker Model Runner by registering it in the root command, implementing its full reinstallation workflow with context-aware flag defaults and Docker operations, and complements it with unit tests and updated documentation.

Class diagram for the new reinstall-runner command implementation

classDiagram
    class reinstall_runner_command {
        +port: uint16
        +host: string
        +gpuMode: string
        +doNotTrack: bool
        +RunE(cmd, args): error
    }
    reinstall_runner_command --|> cobra_Command
    class standalone {
        +PruneControllerContainers(ctx, dockerClient, bool, cmd): error
        +EnsureControllerImage(ctx, dockerClient, gpu, cmd): error
        +EnsureModelStorageVolume(ctx, dockerClient, cmd): (volume, error)
        +CreateControllerContainer(ctx, dockerClient, port, host, environment, doNotTrack, gpu, modelStorageVolume, cmd, engineKind): error
        +DefaultControllerPortMoby: uint16
        +DefaultControllerPortCloud: uint16
    }
    class gpupkg {
        +ProbeGPUSupport(ctx, dockerClient): (GPUSupport, error)
        +GPUSupportCUDA
    }
    class desktop {
        +DockerClientForContext(dockerCLI, context): (dockerClient, error)
    }
    reinstall_runner_command --> standalone : uses
    reinstall_runner_command --> gpupkg : uses
    reinstall_runner_command --> desktop : uses
    class types {
        +ModelRunnerEngineKindDesktop
        +ModelRunnerEngineKindMobyManual
        +ModelRunnerEngineKindCloud
    }
    reinstall_runner_command --> types : checks engine kind
Loading

File-Level Changes

Change Details Files
Introduce and register the reinstall-runner command
  • Added newReinstallRunner invocation in root command
  • Defined command flags (--port, --host, --gpu, --do-not-track)
  • Implemented RunE reinstallation logic: context check, client creation, pruning, GPU probe, image pull, container creation, and wait loop
cmd/cli/commands/root.go
cmd/cli/commands/reinstall-runner.go
Add unit tests for reinstall-runner behavior
  • Verified flag parsing and default values
  • Checked command metadata (Use, Short, RunE)
  • Ensured ValidArgsFunction is set
cmd/cli/commands/reinstall-runner_test.go
Update CLI reference documentation
  • Added reference doc entry with description and options table for reinstall-runner
cmd/cli/docs/reference/model_reinstall-runner.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ericcurtin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new reinstall-runner command to the Docker CLI, designed to streamline the process of reinstalling the Docker Model Runner. This command automates the necessary steps, such as removing existing runner containers and setting up new ones, while intelligently preserving user data like models and images. It also incorporates logic to adapt its behavior based on the Docker engine context (e.g., Docker Desktop, standalone Docker Engine, or Cloud environments) and provides configurable options for GPU support and network binding.

Highlights

  • New reinstall-runner Command: Introduces a new CLI command to simplify the reinstallation of the Docker Model Runner.
  • Automated Reinstallation Logic: The command handles the removal of existing runner containers, re-initialization, and ensures the latest controller image and model storage volume are in place.
  • Context-Aware Operation: Supports different Docker engine contexts (Docker Desktop, Docker Engine/Moby, and Cloud), providing specific handling and user feedback for each.
  • Data Preservation: Explicitly prunes model runner containers but ensures that models and images are preserved during the reinstallation process.
  • GPU Support Configuration: Allows users to specify GPU support (none, auto, cuda) during reinstallation.
  • CLI Integration and Documentation: The new command is integrated into the main CLI structure and comes with dedicated unit tests and reference documentation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new reinstall-runner command that allows users to reinstall the Docker Model Runner in a single operation. The command removes the existing runner container and reinstalls it with specified configuration while preserving models and images.

Key Changes:

  • Implements the reinstall-runner command with support for configuring port, host, GPU settings, and tracking preferences
  • Adds comprehensive test coverage for command flags and properties
  • Includes documentation for the new command with detailed option descriptions

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

File Description
cmd/cli/commands/reinstall-runner.go Core implementation of the reinstall-runner command with flag handling and reinstallation logic
cmd/cli/commands/root.go Registers the new reinstall-runner command in the CLI
cmd/cli/commands/reinstall-runner_test.go Test suite covering command flags, properties, and validation
cmd/cli/docs/reference/model_reinstall-runner.md User-facing documentation for the reinstall-runner command

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `cmd/cli/commands/reinstall-runner_test.go:50` </location>
<code_context>
+	}
+}
+
+func TestReinstallRunnerCommandType(t *testing.T) {
+	cmd := newReinstallRunner()
+
</code_context>

<issue_to_address>
**suggestion (testing):** No test coverage for command execution or error handling in RunE.

Please add tests that exercise RunE's execution logic, including scenarios with different contexts and flags, and cases that should trigger errors such as unsupported engine kinds or GPU mode issues.

Suggested implementation:

```golang
func TestReinstallRunnerCommandType(t *testing.T) {
	cmd := newReinstallRunner()

}

func TestReinstallRunnerRunE_Success(t *testing.T) {
	cmd := newReinstallRunner()
	// Set up flags for a successful run
	cmd.Flags().Set("host", "127.0.0.1")
	cmd.Flags().Set("port", "8080")
	cmd.Flags().Set("gpu", "false")
	cmd.Flags().Set("do-not-track", "false")

	// Simulate a supported engine kind
	cmd.Flags().Set("engine-kind", "docker")

	err := cmd.RunE(cmd, []string{})
	if err != nil {
		t.Errorf("RunE should succeed, got error: %v", err)
	}
}

func TestReinstallRunnerRunE_UnsupportedEngineKind(t *testing.T) {
	cmd := newReinstallRunner()
	cmd.Flags().Set("engine-kind", "unsupported-engine")

	err := cmd.RunE(cmd, []string{})
	if err == nil {
		t.Errorf("RunE should fail for unsupported engine kind")
	}
}

func TestReinstallRunnerRunE_GPUError(t *testing.T) {
	cmd := newReinstallRunner()
	cmd.Flags().Set("gpu", "true")
	// Simulate a context where GPU mode is not supported
	cmd.Flags().Set("engine-kind", "docker")

	// You may need to mock or simulate the GPU check logic here
	err := cmd.RunE(cmd, []string{})
	if err == nil {
		t.Errorf("RunE should fail when GPU mode is not supported")
	}
}

func TestReinstallRunnerRunE_FlagError(t *testing.T) {
	cmd := newReinstallRunner()
	// Do not set required flags to simulate error
	err := cmd.RunE(cmd, []string{})
	if err == nil {
		t.Errorf("RunE should fail when required flags are missing")
	}
}

```

- You may need to adjust the flag names and error conditions to match the actual implementation of `RunE`.
- If `RunE` depends on external systems or context, consider using mocks or stubs for those dependencies.
- If `engine-kind` is not a flag, replace it with the correct flag or argument that controls engine selection.
- If GPU error logic is more complex, you may need to mock the relevant checks or system calls.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new reinstall-runner command, which provides a convenient one-step way to reinstall the Docker Model Runner. The implementation correctly handles various engine contexts and reuses existing standalone package functions for pruning, image pulling, and container creation. The changes also include unit tests for the new command and corresponding documentation.

My review focuses on improving code maintainability and test quality. I've identified significant code duplication between the new reinstall-runner command and the existing install-runner command, and I recommend refactoring the shared logic into helper functions. Additionally, I've suggested a small improvement in the new tests to make them more robust.

@ericcurtin ericcurtin force-pushed the implement-docker-model-reinstall-runner branch from dece7d2 to 1956beb Compare October 15, 2025 04:52
Copilot AI review requested due to automatic review settings October 15, 2025 11:21
@ericcurtin ericcurtin force-pushed the implement-docker-model-reinstall-runner branch from 1956beb to 2105f16 Compare October 15, 2025 11:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

So one can reinstall in one command

Signed-off-by: Eric Curtin <[email protected]>
@ericcurtin ericcurtin force-pushed the implement-docker-model-reinstall-runner branch from 2105f16 to 6073d73 Compare October 15, 2025 11:25
@ericcurtin ericcurtin requested a review from p1-0tr October 15, 2025 11:31
@ericcurtin
Copy link
Contributor Author

@p1-0tr @ilopezluna PTAL

@ericcurtin ericcurtin merged commit ae96ffd into main Oct 15, 2025
9 checks passed
@ericcurtin ericcurtin deleted the implement-docker-model-reinstall-runner branch October 15, 2025 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants