feat(rayapp) Anyscale CLI pr2 build id conversion#397
feat(rayapp) Anyscale CLI pr2 build id conversion#397elliot-barn wants to merge 2 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>
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 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 functionality for converting Anyscale build IDs into image URIs, along with a wrapper for the Anyscale CLI. The changes are well-tested and the logic for build ID conversion is sound. I've identified a few minor issues: a debug print statement that should be removed from the CLI wrapper, a path construction in the tests that isn't portable, and an opportunity to simplify error checking in tests for better readability. Overall, great work on adding this new capability.
| return "", errAnyscaleNotInstalled | ||
| } | ||
|
|
||
| fmt.Println("anyscale cli args: ", args) |
There was a problem hiding this comment.
This fmt.Println appears to be a debug statement. Since runAnyscaleCLI is an unexported function within a library package, printing directly to stdout can lead to unexpected output for consumers of this package. It's best to remove this or replace it with a structured logger if this output is needed for debugging.
| tmp := t.TempDir() | ||
|
|
||
| if script != "" { | ||
| mockScript := tmp + "/anyscale" |
There was a problem hiding this comment.
| if errors.Is(tt.wantErr, errAnyscaleNotInstalled) { | ||
| if !errors.Is(err, errAnyscaleNotInstalled) { | ||
| t.Errorf("expected errAnyscaleNotInstalled, got: %v", err) | ||
| } | ||
| } else if !strings.Contains(err.Error(), tt.wantErr.Error()) { | ||
| t.Errorf("error %q should contain %q", err.Error(), tt.wantErr.Error()) | ||
| } |
There was a problem hiding this comment.
The error checking logic can be simplified for better readability. Using errors.Is to check the test table's wantErr value is a bit indirect. For a sentinel error like errAnyscaleNotInstalled, a direct comparison with == is more idiomatic and clearly expresses the intent to check for a specific error instance.
| if errors.Is(tt.wantErr, errAnyscaleNotInstalled) { | |
| if !errors.Is(err, errAnyscaleNotInstalled) { | |
| t.Errorf("expected errAnyscaleNotInstalled, got: %v", err) | |
| } | |
| } else if !strings.Contains(err.Error(), tt.wantErr.Error()) { | |
| t.Errorf("error %q should contain %q", err.Error(), tt.wantErr.Error()) | |
| } | |
| if tt.wantErr == errAnyscaleNotInstalled { | |
| if !errors.Is(err, errAnyscaleNotInstalled) { | |
| t.Errorf("expected errAnyscaleNotInstalled, got: %v", err) | |
| } | |
| } else if !strings.Contains(err.Error(), tt.wantErr.Error()) { | |
| t.Errorf("error %q should contain %q", err.Error(), tt.wantErr.Error()) | |
| } |
Code Review
|
| Auto-apply | Compact |
|
|
Was this helpful? React with 👍 / 👎 | Gitar
| // Capture output while also displaying to terminal with colors | ||
| var outputBuf bytes.Buffer | ||
| cmd.Stdout = io.MultiWriter(os.Stdout, &outputBuf) | ||
| cmd.Stderr = io.MultiWriter(os.Stderr, &outputBuf) |
There was a problem hiding this comment.
Details
The line fmt.Println("anyscale cli args: ", args) appears to be a debug statement that was accidentally left in the code. This will print to stdout every time the CLI is invoked, which:
- Pollutes the output with implementation details
- May interfere with output parsing by callers
- Doesn't follow the codebase convention of errors bubbling up without inline logging
Suggested fix: Remove this line or replace it with proper structured logging if debugging output is intentionally desired.
Was this helpful? React with 👍 / 👎
|
I've addressed the code review findings:
All tests pass for the anyscale_cli functionality: $ go test ./rayapp -run "TestNewAnyscaleCLI|TestIsAnyscaleInstalled|TestRunAnyscaleCLI|TestConvertBuildIdToImageURI" -v
...
PASS
ok github.com/ray-project/rayci/rayapp 0.007sThe code now follows project conventions (no inline logging, proper error handling with validation) and is ready for review. |
|
I've addressed both code review findings:
All tests pass: $ go test ./rayapp -run "TestNewAnyscaleCLI|TestIsAnyscaleInstalled|TestRunAnyscaleCLI|TestConvertBuildIdToImageURI" -v
PASS
ok github.com/ray-project/rayci/rayapp 0.007sThe code now follows project conventions (no inline logging, proper error handling with validation). |
Adding build id conversion to anyscale cli to convert the slugified build_id to an image_uri