chore: automates session tracing context#591
Conversation
Summary of ChangesHello @rchardx, 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 performance tracing mechanism to automate the management of session identifiers. By leveraging Python's Highlights
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 a significant improvement to the session tracing mechanism by automating context management with contextvars. The new @session_context decorator and the updated trace_session_phase/atrace_session_phase functions greatly simplify the tracing API, removing the need for manual session ID propagation. The changes are well-implemented across the tracer utility, workflow files, and documentation. My review includes a couple of minor suggestions to improve code clarity in the updated tests by removing redundant try...finally blocks.
There was a problem hiding this comment.
Pull Request Overview
This PR streamlines session tracing by automating context management for session identifiers. The changes eliminate manual session registration code in workflow methods, replacing it with a new @session_context() decorator that automatically handles session creation and context population from the active task. This reduces boilerplate and makes the tracing API more intuitive.
- Introduced
session_context()decorator to automatically register sessions per sample invocation - Simplified
atrace_session_phase()andtrace_session_phase()APIs to no longer require explicitsession_idparameters - Updated rollout workflows (
RLVRWorkflowandVisionRLVRWorkflow) to use the new decorator-based approach
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| areal/utils/perf_tracer.py | Added session_context() decorator factory and updated phase tracing context managers to automatically retrieve session_id from context |
| areal/workflow/rlvr.py | Applied @session_context() decorator to _collect_samples method and removed manual session registration code |
| areal/workflow/vision_rlvr.py | Applied @session_context() decorator to _collect_samples method and removed manual session registration code |
| areal/tests/test_perf_tracer.py | Updated tests to use new API where phase context managers no longer require session_id parameter |
| docs/best_practices/perf_profiling.md | Refreshed documentation with examples of the new decorator-based workflow and updated API signatures |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Removes manual session identifiers from phase scopes so they resolve from contextvars. Introduces a decorator to register sessions per sample when a task is active and applies it to rollout workflows to streamline tracing. Refreshes profiling guidance and tests to match the new implicit session workflow.
d623b6f to
e45c4de
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request is a well-executed refactoring that automates session tracing context using contextvars. The introduction of the @session_context decorator is a significant improvement, as it removes boilerplate code from workflows and makes the tracing mechanism more implicit and easier to use. The changes are applied consistently, and the updates to tests and documentation are thorough and clear. Overall, this is a great enhancement to the codebase's maintainability. I have a couple of minor suggestions to improve docstring consistency.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* chore: automates session tracing context Removes manual session identifiers from phase scopes so they resolve from contextvars. Introduces a decorator to register sessions per sample when a task is active and applies it to rollout workflows to streamline tracing. Refreshes profiling guidance and tests to match the new implicit session workflow. * Apply suggestions from code review Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* chore: automates session tracing context Removes manual session identifiers from phase scopes so they resolve from contextvars. Introduces a decorator to register sessions per sample when a task is active and applies it to rollout workflows to streamline tracing. Refreshes profiling guidance and tests to match the new implicit session workflow. * Apply suggestions from code review Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Description
Removes manual session identifiers from phase scopes so they resolve from contextvars. Introduces a decorator to register sessions per sample when a task is active and applies it to rollout workflows to streamline tracing. Refreshes profiling guidance and tests to match the new implicit session workflow.
Type of Change
work as expected)
Checklist
jb build docs/gemini review)Breaking Change Details (if applicable):
Additional Context
Need help? Check the Contributing Guide or ask in
GitHub Discussions!