Skip to content

[rayapp] rayapp: split stdout and stderr tailwriter#473

Merged
elliot-barn merged 2 commits intomainfrom
elliot-split-tail-writer
Mar 26, 2026
Merged

[rayapp] rayapp: split stdout and stderr tailwriter#473
elliot-barn merged 2 commits intomainfrom
elliot-split-tail-writer

Conversation

@elliot-barn
Copy link
Copy Markdown
Collaborator

@elliot-barn elliot-barn commented Mar 24, 2026

rayapp/anyscale_cli.go — Split the single tailWriter into separate
stdoutBuf and stderrBuf. Only stdout is returned as the parsed output.
On error, stderr is included in the error message for diagnostics.

rayapp/anyscale_cli_test.go — Updated the "command fails with stderr"
test case to expect stderr content in the error string instead of in
the returned output. Added TestRunAnyscaleCLI_StderrNotInOutput that
verifies a [WARNING] on stderr doesn't leak into the parsed output.

Tested locally with rayapp test service-intro on anyscale==0.26.81

partial log of successful anyscale cli commands with [WARNING] messages (anyscale +58.9s) Workspace 'expwrk_jegme97wcmdsmg9pejnp184eqd' reached target state, exiting >>> anyscale workspace_v2 push --name service-intro-20260324182301 --local-dir /tmp/template_zip4143637084 [WARNING] A newer version of the Anyscale CLI is available. Your current version is 0.26.81. The latest version is 0.26.91. To avoid issues accessing Anyscale`s API, upgrade to the latest version by running `pip install --upgrade anyscale`. Detected files that exist in the destination but not in the source. The files will not be deleted by default. You can add '--delete' option to delete the files: .anyscaleignore >>> anyscale workspace_v2 run_command --name service-intro-20260324182301 unzip -o service-intro.zip [WARNING] A newer version of the Anyscale CLI is available. Your current version is 0.26.81. The latest version is 0.26.91. To avoid issues accessing Anyscale`s API, upgrade to the latest version by running `pip install --upgrade anyscale`. Archive: service-intro.zip inflating: README.ipynb inflating: README.md inflating: assets/service-logs.png inflating: assets/service-overview.png inflating: assets/service-replicas.png inflating: assets/service-rollout.png inflating: main.py >>> anyscale workspace_v2 push --name service-intro-20260324182301 --local-dir /tmp/test_zip1617622678 [WARNING] A newer version of the Anyscale CLI is available. Your current version is 0.26.81. The latest version is 0.26.91. To avoid issues accessing Anyscale`s API, upgrade to the latest version by running `pip install --upgrade anyscale`. Detected files that exist in the destination but not in the source. The files will not be deleted by default. You can add '--delete' option to delete the files: assets/service-rollout.png assets/service-replicas.png assets/service-overview.png assets/service-logs.png assets/ service-intro.zip main.py README.md README.ipynb .anyscaleignore >>> anyscale workspace_v2 run_command --name service-intro-20260324182301 unzip -o tests.zip [WARNING] A newer version of the Anyscale CLI is available. Your current version is 0.26.81. The latest version is 0.26.91. To avoid issues accessing Anyscale`s API, upgrade to the latest version by running `pip install --upgrade anyscale`. Archive: tests.zip inflating: tests.sh >>> anyscale workspace_v2 run_command --name service-intro-20260324182301 timeout 900 bash -c 'bash tests.sh' [WARNING] A newer version of the Anyscale CLI is available. Your current version is 0.26.81. The latest version is 0.26.91. To avoid issues accessing Anyscale`s API, upgrade to the latest version by running `pip install --upgrade anyscale`.

Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 refactors the runAnyscaleCLI function to distinctly handle stdout and stderr streams. This change is vital for applications that parse the command-line interface's output, as it prevents diagnostic messages or warnings from stderr from interfering with structured data returned on stdout. While both streams are still displayed to the user, the programmatic capture now isolates stdout, leading to more robust parsing and clearer error reporting.

Highlights

  • Separated Output Streams: The runAnyscaleCLI function now captures stdout and stderr independently using separate tailWriter buffers, ensuring distinct handling of each stream.
  • Clean Structured Output: The function's return value now exclusively contains stdout content, preventing structured output (e.g., JSON/YAML) from being corrupted by stderr messages.
  • Enhanced Error Reporting: Error messages generated by runAnyscaleCLI now include the full content of stderr, providing more comprehensive context when a command fails.
  • Improved Test Coverage: A new test case, TestRunAnyscaleCLI_StderrNotInOutput, was added to specifically verify that stderr content does not appear in the returned stdout, ensuring the integrity of structured output.

🧠 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 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.

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
Copy Markdown
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 refactors the runAnyscaleCLI function to explicitly separate stdout and stderr streams. Previously, both streams were combined, which could lead to issues when parsing structured output from stdout if stderr contained warnings or other messages. The updated implementation now captures stdout and stderr into distinct buffers, returning only the stdout content for parsing while still displaying both streams to the terminal. If the command fails, the stderr content is now included in the returned error message. Corresponding test cases have been updated, and a new test TestRunAnyscaleCLI_StderrNotInOutput was added to verify that stderr content does not interfere with the returned stdout.

@elliot-barn elliot-barn reopened this Mar 24, 2026
@elliot-barn elliot-barn marked this pull request as ready for review March 24, 2026 18:24
@elliot-barn elliot-barn requested a review from aslonnie March 26, 2026 17:10
Comment thread rayapp/anyscale_cli.go Outdated
Copy link
Copy Markdown
Contributor

@sai-miduthuri sai-miduthuri left a comment

Choose a reason for hiding this comment

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

Everything else looks good except for the handling of stdout and stderr in the case of err != nil.

Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
@elliot-barn elliot-barn merged commit 8116375 into main Mar 26, 2026
2 checks passed
@elliot-barn elliot-barn deleted the elliot-split-tail-writer branch March 26, 2026 22:29
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