feat(rayapp): Anyscale CLI pr4 add workspace operations#399
feat(rayapp): Anyscale CLI pr4 add workspace operations#399elliot-barn wants to merge 7 commits intomainfrom
Conversation
Add foundational components for Anyscale CLI wrapper: - AnyscaleCLI struct and NewAnyscaleCLI() constructor - errAnyscaleNotInstalled error sentinel for installation checks - isAnyscaleInstalled() helper to verify CLI availability - runAnyscaleCLI() base method for executing anyscale commands Includes comprehensive test coverage with setupMockAnyscale test helper. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add convertBuildIdToImageURI function that parses build IDs like "anyscaleray2441-py312-cu128" into image URI "anyscale/ray:2.44.1-py312-cu128" and Ray version "2.44.1". Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add WorkspaceState type with constants (StateTerminated, StateStarting, StateRunning) and String() method for representing workspace states. Add compute config operations: - parseComputeConfigName: parse AWS config path to config name - CreateComputeConfig: create compute config if it doesn't exist - GetComputeConfig: retrieve compute config details by name Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive workspace management methods: - WorkspaceTestConfig struct for workspace configuration - createEmptyWorkspace() - create new workspace with build ID conversion - terminateWorkspace() - terminate a workspace by name - copyTemplateToWorkspace() - push template files to workspace - pushTemplateToWorkspace() - push local files to workspace - runCmdInWorkspace() - execute commands in workspace - startWorkspace() - start a stopped workspace - getWorkspaceStatus() - get current workspace status - waitForWorkspaceState() - wait for workspace to reach desired state Also add compute config conversion functionality: - isOldComputeConfigFormat() - detect old config format - ConvertComputeConfig() - convert old to new format - ConvertComputeConfigFile() - convert config files - Auto-conversion in CreateComputeConfig() This completes the Anyscale CLI wrapper with full workspace lifecycle management capabilities. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary of ChangesHello @elliot-barn, 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 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.
Code Review
This pull request introduces comprehensive workspace management capabilities to the Anyscale CLI wrapper, including creation, termination, and execution of commands within workspaces. It also adds a helpful utility to automatically convert legacy compute configuration files to the new format. The code is well-structured and includes a good set of unit tests for the new functionality. My review includes a few suggestions to improve error handling, consistency, and correct a potential bug in command execution.
| func (ac *AnyscaleCLI) runCmdInWorkspace(config *WorkspaceTestConfig, cmd string) error { | ||
| output, err := ac.runAnyscaleCLI([]string{"workspace_v2", "run_command", "--name", config.workspaceName, cmd}) | ||
| if err != nil { | ||
| return fmt.Errorf("run command in workspace failed: %w", err) | ||
| } | ||
| fmt.Println("run command in workspace output:\n", output) | ||
| return nil | ||
| } |
There was a problem hiding this comment.
The cmd string is passed as a single argument to the anyscale CLI. This will likely fail if the command contains arguments (e.g., ls -l). The command string should be split into its components. Using strings.Fields() is a simple way to achieve this for commands without quoted arguments. For more complex use cases, a shell-aware parser might be needed, but strings.Fields should cover many common scenarios.
func (ac *AnyscaleCLI) runCmdInWorkspace(config *WorkspaceTestConfig, cmd string) error {
args := []string{"workspace_v2", "run_command", "--name", config.workspaceName}
args = append(args, strings.Fields(cmd)...)
output, err := ac.runAnyscaleCLI(args)
if err != nil {
return fmt.Errorf("run command in workspace failed: %w", err)
}
fmt.Println("run command in workspace output:\n", output)
return nil
}|
I've addressed all 4 issues identified in the code review: 1. Fixed temp file race condition (Important)
2. Added nil pointer checks in
3. Added nil pointer check in
4. Added comprehensive unit tests (Minor)
Bonus: Fixed |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Elliot Barnwell <elliot.barnwell@anyscale.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Elliot Barnwell <elliot.barnwell@anyscale.com>
|
I've re-applied all 4 fixes from the code review after the Gemini suggestions were merged: 1. Fixed temp file race condition (Important) ✅
2. Added nil pointer checks in
3. Added nil pointer check in
4. Added comprehensive unit tests (Minor) ✅
Bonus: Fixed |
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
|
All 4 code review findings have been addressed: 1. Temp file race condition ✅
2. Nil pointer checks in
3. Nil pointer check in
4. Missing test coverage ✅
Bonus: Fixed |
Code Review ✅ Approved 4 resolved / 4 findingsWell-structured implementation of workspace operations and compute config conversion. The code demonstrates good error handling with nil checks, proper temp file cleanup, and comprehensive test coverage. No significant issues found. ✅ 4 resolved✅ Bug: Temp file may be deleted before CLI command reads it
✅ Edge Case: Potential nil pointer dereference in createEmptyWorkspace
✅ Edge Case: Potential nil pointer in copyTemplateToWorkspace
✅ Quality: Missing tests for ConvertComputeConfig functions
OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
Add comprehensive workspace management methods:
Also add compute config conversion functionality:
This completes the Anyscale CLI wrapper with full workspace lifecycle management capabilities.