Skip to content

feat(rayapp): Add Anyscale CLI wrapper and workspace test runner for templates#406

Closed
sai-miduthuri wants to merge 24 commits intoray-project:mainfrom
sai-miduthuri:template-test-runner
Closed

feat(rayapp): Add Anyscale CLI wrapper and workspace test runner for templates#406
sai-miduthuri wants to merge 24 commits intoray-project:mainfrom
sai-miduthuri:template-test-runner

Conversation

@sai-miduthuri
Copy link

@sai-miduthuri sai-miduthuri commented Feb 3, 2026

PR opened from wrong branch. Closing this PR and moving to #412

elliot-barn and others added 20 commits January 24, 2026 01:46
Adds AnyscaleCLI struct with methods for:
- Compute config management (Create, Get, List)
- Workspace operations (Create, Start, Terminate, Push, RunCommand,
  GetStatus, WaitForState)
- Build ID to image URI conversion
- Compute config name parsing

All methods are standalone and don't depend on external types.
Full unit test coverage included.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds comprehensive Anyscale CLI wrapper and workspace test runner:

**Anyscale CLI (anyscale_cli.go)**
- Compute config management (Create, Get, List)
- Workspace operations (Create, Start, Terminate, Push, RunCommand)
- Build ID to image URI conversion
- Full unit test coverage

**Workspace Test Runner (test.go)**
- WorkspaceTestConfig for running tests in Anyscale workspaces
- Automated flow: create compute config, create workspace, push template, run tests, cleanup
- Zips template to temp directory before pushing
- Full unit test coverage for all scenarios

**Utilities (util.go)**
- zipDirectory function for packaging templates

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Restore WorkspaceTestConfig struct that was commented out but still
  referenced by workspace functions
- Update TestCreateComputeConfig to use temp config files instead of
  non-existent paths, since CreateComputeConfig now reads the file
- Remove ListComputeConfigs function and its tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
The token field was never used - authentication relies on environment
variables (ANYSCALE_CLI_TOKEN, ANYSCALE_HOST) instead.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
Authentication is handled via environment variables (ANYSCALE_CLI_TOKEN
& ANYSCALE_HOST) rather than interactive login.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @sai-miduthuri, 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 rayapp tool by integrating robust Anyscale CLI interaction capabilities and introducing an automated workspace-based testing framework for templates. It allows for more flexible and reliable management of Anyscale resources, particularly for CI/CD pipelines, by providing programmatic control over compute configurations and workspace lifecycles. The new test runner streamlines the process of validating templates within actual Anyscale environments, improving development efficiency and ensuring template quality.

Highlights

  • Anyscale CLI Wrapper: A new Go package (anyscale_cli.go) has been added, providing a comprehensive wrapper for interacting with the Anyscale CLI. This includes functionalities for managing compute configurations (create, get, format conversion) and handling the full lifecycle of Anyscale workspaces (create, start, terminate, push, run commands, wait for state). It also includes utilities for converting between Anyscale build IDs and image URIs.
  • Workspace Test Runner: A new Go package (test.go) introduces an automated test runner for Anyscale templates. This runner orchestrates the end-to-end testing process, including compute config creation, workspace creation and management, template deployment, test execution, and cleanup, ensuring templates are validated within actual Anyscale environments.
  • Flexible Cluster Environment Configuration: Templates can now specify cluster environments using either a BuildID or an ImageURI. The system automatically handles the conversion and population of BuildID from ImageURI when only the latter is provided, enhancing flexibility in template definitions.
  • Enhanced rayapp CLI: The rayapp command-line tool now includes a new test command to trigger the workspace test runner. Command-line argument parsing has been refactored using flag.NewFlagSet for improved command-specific flag management, and clearer usage instructions are provided.
  • Compute Config Format Conversion: The Anyscale CLI wrapper includes logic to detect and automatically convert old Anyscale compute config YAML formats (e.g., using head_node_type) to the new format during the compute config creation process.

🧠 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
  • build_rayapp.sh
    • The rayapp binary is now moved to ../rayapp after building, instead of being executed directly.
  • rayapp/anyscale_cli.go
    • Added AnyscaleCLI struct and methods to wrap Anyscale CLI commands.
    • Implemented functions for managing Anyscale compute configurations (create, get, format conversion).
    • Provided functionalities for Anyscale workspace lifecycle management (create, start, terminate, push, run commands, wait for state).
    • Included utilities for converting between Anyscale build IDs and image URIs.
  • rayapp/anyscale_cli_test.go
    • Added comprehensive unit tests for anyscale_cli.go functionalities, including mocking the Anyscale CLI for isolated testing.
  • rayapp/builder_test.go
    • Updated TestBuilder to include test cases for ClusterEnv using both BuildID and ImageURI.
  • rayapp/rayapp/main.go
    • Added a new test command to the rayapp CLI, enabling template testing.
    • Refactored command-line argument parsing to use flag.NewFlagSet for improved command-specific flag management.
    • Implemented a printUsage function for clearer CLI help messages.
  • rayapp/template.go
    • Added ImageURI field to the ClusterEnv struct, allowing templates to specify images directly.
    • Implemented logic to automatically derive BuildID from ImageURI when ImageURI is provided in ClusterEnv.
    • Ensured BuildID resolution from ImageURI during template reading.
  • rayapp/template_test.go
    • Added a new test case to TestReadTemplates to validate ImageURI parsing and automatic BuildID population.
  • rayapp/test.go
    • Introduced test.go to provide a comprehensive workspace test runner.
    • Implemented WorkspaceTestConfig to manage test parameters and orchestrate the test lifecycle.
    • Automated the end-to-end testing process: compute config creation, workspace creation/management, template deployment, test execution, and cleanup.
  • rayapp/test_test.go
    • Added extensive unit tests for the workspace test runner (test.go), covering various success and failure paths, and mocking external dependencies.
  • rayapp/util.go
    • Added a new utility function zipDirectory to package template directories into zip files.
Activity
  • The pull request introduces new features for the rayapp tool.
  • It is a fork of an existing pull request, indicating iterative development and refinement of these features.
  • The author, sai-miduthuri, has implemented significant new functionality for Anyscale CLI integration and template testing.
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 introduces a comprehensive Anyscale CLI wrapper and a workspace test runner, which is a significant feature addition. The new code includes a Go wrapper for the anyscale CLI, a test runner for templates, and extensive unit tests. The command-line interface for rayapp has also been improved to accommodate the new test command. My review has identified a couple of high-severity issues with a restrictive version parsing logic that could cause problems with future Ray versions, and a medium-severity issue with a confusing CLI usage message. Despite these points, the overall contribution is solid and includes excellent test coverage.

Comment on lines +425 to +429
buildIDVersionRe := regexp.MustCompile(`^(\d)(\d{2})(\d+)$`)
matches := buildIDVersionRe.FindStringSubmatch(versionStr)
if matches == nil {
return "", "", fmt.Errorf("version string must match major(1 digit).minor(2 digits).patch(1+ digits): %s", versionStr)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The regular expression for parsing the version from a build ID is too restrictive. It assumes the major version is always a single digit (^(\d)). This will fail for Ray versions 10 and above (e.g., a build ID for Ray 10.0.0). To make this more robust for future versions, the regex should allow for one or more digits for the major version.

Suggested change
buildIDVersionRe := regexp.MustCompile(`^(\d)(\d{2})(\d+)$`)
matches := buildIDVersionRe.FindStringSubmatch(versionStr)
if matches == nil {
return "", "", fmt.Errorf("version string must match major(1 digit).minor(2 digits).patch(1+ digits): %s", versionStr)
}
buildIDVersionRe := regexp.MustCompile(`^(\d+)(\d{2})(\d+)$`)
matches := buildIDVersionRe.FindStringSubmatch(versionStr)
if matches == nil {
return "", "", fmt.Errorf("version string must match major(1+ digits).minor(2 digits).patch(1+ digits): %s", versionStr)
}

Comment on lines +453 to +457
imageURIVersionRe := regexp.MustCompile(`^(\d)\.(\d{2})\.(\d+)$`)
matches := imageURIVersionRe.FindStringSubmatch(versionStr)
if matches == nil {
return "", "", fmt.Errorf("image URI version must match major(1 digit).minor(2 digits).patch(1+ digits): %s", versionStr)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Similar to the build ID conversion, the regular expression for parsing the version from an image URI is too restrictive. It assumes the major version is always a single digit (^(\d)). This will fail for Ray versions 10 and above. To make this more robust for future versions, the regex should allow for one or more digits for the major version.

Suggested change
imageURIVersionRe := regexp.MustCompile(`^(\d)\.(\d{2})\.(\d+)$`)
matches := imageURIVersionRe.FindStringSubmatch(versionStr)
if matches == nil {
return "", "", fmt.Errorf("image URI version must match major(1 digit).minor(2 digits).patch(1+ digits): %s", versionStr)
}
imageURIVersionRe := regexp.MustCompile(`^(\d+)\.(\d{2})\.(\d+)$`)
matches := imageURIVersionRe.FindStringSubmatch(versionStr)
if matches == nil {
return "", "", fmt.Errorf("image URI version must match major(1+ digits).minor(2 digits).patch(1+ digits): %s", versionStr)
}

Comment on lines +77 to +79
fmt.Println(" --workspace string Workspace name (required)")
fmt.Println(" --template-dir string Template directory (required)")
fmt.Println(" --config string Config file path (required)")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The usage message for the test command lists several flags (--workspace, --template-dir, --config) that are not implemented, and it's missing the implemented --build flag. The flag definitions for the unimplemented flags are also commented out in the code (lines 27-29).

This is confusing for users. To fix this, the usage message should reflect the actual implemented flags. The commented-out flag definitions should also be removed.

Suggested change
fmt.Println(" --workspace string Workspace name (required)")
fmt.Println(" --template-dir string Template directory (required)")
fmt.Println(" --config string Config file path (required)")
fmt.Println(" --build string Build file (default \"BUILD.yaml\")")

@sai-miduthuri sai-miduthuri deleted the template-test-runner branch February 3, 2026 23:50
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.

2 participants