-
Notifications
You must be signed in to change notification settings - Fork 77
refactor(cli): centralize standalone runner initialization #528
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
Conversation
Summary of ChangesHello @doringeman, 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 refactors the command-line interface (CLI) to centralize the initialization and availability checks for the standalone model runner. By introducing a Highlights
🧠 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. Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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 1 issue, and left some high level feedback:
- The
withStandaloneRunnerdecorator only wrapsRunEand silently no-ops for commands that useRun; if any of the wrapped commands or future additions useRuninstead ofRunE, they will skip runner initialization—consider either handlingRunas well or explicitly enforcingRunEusage for commands in the wrapped set. - In
withStandaloneRunneryou always passfalseas thedebugargument toensureStandaloneRunnerAvailable, whereasnewRunCmdpreviously forwarded itsdebugflag; if the debug setting is still relevant for automatic installation behavior, it might be worth threading that through instead of hardcodingfalse.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `withStandaloneRunner` decorator only wraps `RunE` and silently no-ops for commands that use `Run`; if any of the wrapped commands or future additions use `Run` instead of `RunE`, they will skip runner initialization—consider either handling `Run` as well or explicitly enforcing `RunE` usage for commands in the wrapped set.
- In `withStandaloneRunner` you always pass `false` as the `debug` argument to `ensureStandaloneRunnerAvailable`, whereas `newRunCmd` previously forwarded its `debug` flag; if the debug setting is still relevant for automatic installation behavior, it might be worth threading that through instead of hardcoding `false`.
## Individual Comments
### Comment 1
<location> `cmd/cli/commands/install-runner.go:169-175` </location>
<code_context>
+// withStandaloneRunner wraps a command's RunE to ensure the standalone runner
+// is available before executing the command. This is a no-op in unsupported
+// contexts (e.g., Docker Desktop) or if automatic installations have been disabled.
+func withStandaloneRunner(cmd *cobra.Command) *cobra.Command {
+ if cmd.RunE == nil {
+ return cmd
+ }
+ originalRunE := cmd.RunE
+ cmd.RunE = func(cmd *cobra.Command, args []string) error {
+ if _, err := ensureStandaloneRunnerAvailable(cmd.Context(), asPrinter(cmd), false); err != nil {
+ return fmt.Errorf("unable to initialize standalone model runner: %w", err)
+ }
</code_context>
<issue_to_address>
**issue (bug_risk):** `withStandaloneRunner` hardcodes `debug` to `false`, changing behavior for commands that previously passed it through.
Commands like `run` previously called `ensureStandaloneRunnerAvailable` with their `debug` flag, but `withStandaloneRunner` now always passes `false`. If `debug` alters logging or initialization behavior, this will silently drop debug mode even when `--debug` is set. Please pass a per-command debug value into `withStandaloneRunner` (or derive it from `*cobra.Command`) so commands can still propagate their debug state.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this 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 significant refactoring to centralize the standalone model runner initialization logic. By adding a withStandaloneRunner decorator, the repeated checks and auto-installation logic are removed from individual commands and handled in a consistent, centralized manner in root.go. This greatly improves code maintainability and reduces duplication. The changes are well-executed, and I have one minor suggestion for improvement.
cf79a35 to
95907a6
Compare
Add withStandaloneRunner decorator to wrap commands that require a running model runner, ensuring consistent auto-installation behavior across all CLI commands. Signed-off-by: Dorin Geman <dorin.geman@docker.com>
95907a6 to
1b6f2ce
Compare
Add withStandaloneRunner decorator to wrap commands that require a running model runner, ensuring consistent auto-installation behavior across all CLI commands.
Fixes #274.