Skip to content

improve launch command#661

Open
ericcurtin wants to merge 1 commit intomainfrom
improve-model-cli-launch-functionality
Open

improve launch command#661
ericcurtin wants to merge 1 commit intomainfrom
improve-model-cli-launch-functionality

Conversation

@ericcurtin
Copy link
Contributor

  • Allow docker model launch with no args to list supported apps with descriptions and install status
  • Add --config flag to print configuration without launching
  • Properly handle -- separator for passing extra args to integrations
  • Reject unexpected extra args without -- separator with helpful error
  • Add app descriptions for all supported apps
  • Update documentation and tests

- Allow `docker model launch` with no args to list supported apps with
  descriptions and install status
- Add `--config` flag to print configuration without launching
- Properly handle `--` separator for passing extra args to integrations
- Reject unexpected extra args without `--` separator with helpful error
- Add app descriptions for all supported apps
- Update documentation and tests

Signed-off-by: Eric Curtin <[email protected]>
@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 significantly enhances the docker model launch command by improving its user experience and flexibility. It allows users to easily discover supported applications and their details, inspect application configurations before execution, and provides more robust handling of arguments for integrated applications. These changes make the command more intuitive and powerful for managing Docker Model Runner applications.

Highlights

  • Enhanced launch command functionality: The docker model launch command now lists supported applications with descriptions and installation status when executed without arguments.
  • New --config flag: A --config flag has been added, allowing users to print the configuration of an application without actually launching it.
  • Improved argument handling: The command now properly handles extra arguments passed to integrations using the -- separator and rejects unexpected extra arguments without it, providing helpful error messages.
  • App descriptions added: Human-readable descriptions have been included for all supported applications, enhancing user understanding.
  • Documentation and test updates: The command's documentation and test suite have been updated to reflect these new features and behaviors, ensuring correctness and clarity.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • cmd/cli/commands/launch.go
    • Added appDescriptions map for human-readable app descriptions.
    • Modified newLaunchCmd to allow docker model launch without arguments to list apps.
    • Introduced configOnly flag and logic to print app configuration.
    • Implemented logic to correctly parse passthrough arguments using the -- separator.
    • Added error handling for unexpected arguments without the -- separator.
    • Created listSupportedApps function to display app names, descriptions, and installation status.
    • Created printAppConfig function to show detailed configuration for container and host apps.
    • Updated cobra.Command Use and Long fields to reflect new functionality and examples.
  • cmd/cli/commands/launch_test.go
    • Replaced TestNewLaunchCmdRequiresAtLeastOneArg with TestNewLaunchCmdNoArgsListsApps to verify the new behavior of listing apps when no arguments are provided.
    • Added TestNewLaunchCmdConfigFlag and TestNewLaunchCmdConfigFlagHostApp to test the --config flag for both container and host applications.
    • Added TestNewLaunchCmdRejectsExtraArgsWithoutDash to ensure proper error handling for unexpected arguments.
    • Added TestNewLaunchCmdPassthroughArgs to confirm correct parsing of arguments after --.
    • Added TestAppDescriptionsExistForAllApps to validate that all supported apps have descriptions.
    • Added TestListSupportedApps, TestPrintAppConfigContainerApp, TestPrintAppConfigHostApp, and TestPrintAppConfigUnsupported to test the new utility functions.
  • cmd/cli/docs/reference/docker_model_launch.yaml
    • Updated the long description to include information about listing apps without arguments and new examples.
    • Modified the usage string to reflect the optional APP argument.
    • Added the --config option with its description.
  • cmd/cli/docs/reference/model_launch.md
    • Updated the main description to mention listing apps without arguments.
    • Added new examples for various launch command usages.
    • Included the --config option in the command options table.
Activity
  • No human activity has been recorded on this pull request yet.
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

@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 significantly improves the docker model launch command by adding the ability to list supported applications, view their configurations, and providing a more robust argument parsing for passing arguments to the launched applications. The changes are well-implemented and include comprehensive tests and documentation updates. I have a couple of minor suggestions to improve the consistency of a user-facing usage string.

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 - I've found 3 issues, and left some high level feedback:

  • In newLaunchCmd's RunE, when using ArgsLenAtDash, appArgs should probably be args[dashIdx+1:] instead of args[dashIdx:] so that the literal -- separator is not forwarded to the app alongside its arguments.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `newLaunchCmd`'s `RunE`, when using `ArgsLenAtDash`, `appArgs` should probably be `args[dashIdx+1:]` instead of `args[dashIdx:]` so that the literal `--` separator is not forwarded to the app alongside its arguments.

## Individual Comments

### Comment 1
<location> `cmd/cli/commands/launch.go:123` </location>
<code_context>
 			app := strings.ToLower(args[0])
-			appArgs := args[1:]
+
+			// Extract passthrough args using -- separator
+			var appArgs []string
+			dashIdx := cmd.ArgsLenAtDash()
</code_context>

<issue_to_address>
**issue (bug_risk):** Extra positional args before `--` are silently ignored instead of being rejected.

When `ArgsLenAtDash()` > 1, any args between the app name and `--` (e.g., `docker model launch claude foo -- bar`) are dropped, so only `bar` reaches the app and `foo` is silently ignored. This differs from the behavior without `--`, where extra args cause an error. Consider requiring `dashIdx == 1` and erroring otherwise, or clearly documenting that only args after `--` are forwarded and earlier ones are ignored.
</issue_to_address>

### Comment 2
<location> `cmd/cli/commands/launch.go:191-200` </location>
<code_context>
+func printAppConfig(cmd *cobra.Command, app string, ep engineEndpoints) error {
</code_context>

<issue_to_address>
**suggestion (bug_risk):** `--config` output does not reflect user overrides like `--image` or `--port`.

`printAppConfig` always shows `ca.defaultImage` and `ca.defaultHostPort`, even when `--image` or `--port` overrides are provided with `--config`. This can cause the printed config to differ from what `launchContainerApp` will actually use. Please pass the resolved image/port (including overrides) into `printAppConfig` so its output reflects the real launch configuration.

Suggested implementation:

```golang
 // printAppConfig prints the configuration that would be used for the given app.
func printAppConfig(cmd *cobra.Command, app string, ep engineEndpoints, image string, hostPort int) error {
	if ca, ok := containerApps[app]; ok {
		cmd.Printf("Configuration for %s (container app):\n", app)
		cmd.Printf("  Image:          %s\n", image)
		cmd.Printf("  Container port: %d\n", ca.containerPort)
		cmd.Printf("  Host port:      %d\n", hostPort)
		if ca.envFn != nil {
			cmd.Printf("  Environment:\n")
			for _, e := range ca.envFn(ep.container) {
				cmd.Printf("    %s\n", e)
			}

```

To fully implement the behavior you described, you will also need to:

1. Update every call to `printAppConfig` to use the new signature:
   - Compute the final image string (respecting `--image` flag overrides and any defaults used by `launchContainerApp`).
   - Compute the final host port (respecting `--port` flag overrides and any defaults).
   - Pass those values as the `image` and `hostPort` arguments when calling `printAppConfig`.

   For example, a call that previously looked like:
   ```go
   if err := printAppConfig(cmd, app, ep); err != nil { ... }
   ```
   should become something like:
   ```go
   resolvedImage := imageFlagValueOrDefault // same value used by launchContainerApp
   resolvedHostPort := hostPortFlagValueOrDefault
   if err := printAppConfig(cmd, app, ep, resolvedImage, resolvedHostPort); err != nil { ... }
   ```

2. Ensure that the logic computing `resolvedImage` and `resolvedHostPort` is exactly the same as that used by `launchContainerApp`, so the printed configuration always matches the actual launch configuration.
</issue_to_address>

### Comment 3
<location> `cmd/cli/commands/launch.go:186` </location>
<code_context>
+		cmd.Printf("  %-15s %s%s\n", name, desc, status)
+	}
+	cmd.Println()
+	cmd.Println("Usage: docker model launch APP [-- APP_ARGS...]")
+	return nil
+}
</code_context>

<issue_to_address>
**nitpick:** Usage line in `listSupportedApps` is inconsistent with the new `[APP]` optional syntax.

This usage line implies `APP` is required, unlike the command’s `Use`/docs, which show `[APP]`. Please align this string with the canonical usage (e.g., by reusing `Use` or changing `APP` to `[APP]`).
</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.

app := strings.ToLower(args[0])
appArgs := args[1:]

// Extract passthrough args using -- separator
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Extra positional args before -- are silently ignored instead of being rejected.

When ArgsLenAtDash() > 1, any args between the app name and -- (e.g., docker model launch claude foo -- bar) are dropped, so only bar reaches the app and foo is silently ignored. This differs from the behavior without --, where extra args cause an error. Consider requiring dashIdx == 1 and erroring otherwise, or clearly documenting that only args after -- are forwarded and earlier ones are ignored.

Comment on lines +191 to +200
func printAppConfig(cmd *cobra.Command, app string, ep engineEndpoints) error {
if ca, ok := containerApps[app]; ok {
cmd.Printf("Configuration for %s (container app):\n", app)
cmd.Printf(" Image: %s\n", ca.defaultImage)
cmd.Printf(" Container port: %d\n", ca.containerPort)
cmd.Printf(" Host port: %d\n", ca.defaultHostPort)
if ca.envFn != nil {
cmd.Printf(" Environment:\n")
for _, e := range ca.envFn(ep.container) {
cmd.Printf(" %s\n", e)
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (bug_risk): --config output does not reflect user overrides like --image or --port.

printAppConfig always shows ca.defaultImage and ca.defaultHostPort, even when --image or --port overrides are provided with --config. This can cause the printed config to differ from what launchContainerApp will actually use. Please pass the resolved image/port (including overrides) into printAppConfig so its output reflects the real launch configuration.

Suggested implementation:

 // printAppConfig prints the configuration that would be used for the given app.
func printAppConfig(cmd *cobra.Command, app string, ep engineEndpoints, image string, hostPort int) error {
	if ca, ok := containerApps[app]; ok {
		cmd.Printf("Configuration for %s (container app):\n", app)
		cmd.Printf("  Image:          %s\n", image)
		cmd.Printf("  Container port: %d\n", ca.containerPort)
		cmd.Printf("  Host port:      %d\n", hostPort)
		if ca.envFn != nil {
			cmd.Printf("  Environment:\n")
			for _, e := range ca.envFn(ep.container) {
				cmd.Printf("    %s\n", e)
			}

To fully implement the behavior you described, you will also need to:

  1. Update every call to printAppConfig to use the new signature:

    • Compute the final image string (respecting --image flag overrides and any defaults used by launchContainerApp).
    • Compute the final host port (respecting --port flag overrides and any defaults).
    • Pass those values as the image and hostPort arguments when calling printAppConfig.

    For example, a call that previously looked like:

    if err := printAppConfig(cmd, app, ep); err != nil { ... }

    should become something like:

    resolvedImage := imageFlagValueOrDefault // same value used by launchContainerApp
    resolvedHostPort := hostPortFlagValueOrDefault
    if err := printAppConfig(cmd, app, ep, resolvedImage, resolvedHostPort); err != nil { ... }
  2. Ensure that the logic computing resolvedImage and resolvedHostPort is exactly the same as that used by launchContainerApp, so the printed configuration always matches the actual launch configuration.

@ilopezluna
Copy link
Contributor

I think its worth to add the Sourcery suggestion:

Consider requiring dashIdx == 1 and erroring otherwise, or clearly documenting that only args after -- are forwarded and earlier ones are ignored.

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