Skip to content

chore (REF352): open_session enhancement.#353

Merged
k82cn merged 5 commits into
xflops:mainfrom
k82cn:rfe352_open_session
Feb 9, 2026
Merged

chore (REF352): open_session enhancement.#353
k82cn merged 5 commits into
xflops:mainfrom
k82cn:rfe352_open_session

Conversation

@k82cn
Copy link
Copy Markdown
Contributor

@k82cn k82cn commented Feb 9, 2026

fix #352

Signed-off-by: Klaus Ma <klausm@nvidia.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @k82cn, 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 open_session RPC by introducing 'get-or-create' functionality. Previously, users had to manage separate open_session and create_session calls, leading to complex logic and potential race conditions. With this change, open_session can now atomically retrieve an existing session or create a new one if a SessionSpec is provided. It also incorporates spec validation to prevent configuration drift for existing sessions. This streamlines the session management workflow across Rust and Python SDKs, simplifying client-side logic and improving API usability.

Highlights

  • Atomic Get-or-Create for Sessions: The open_session RPC now supports atomic 'get-or-create' functionality, allowing clients to retrieve an existing session or create a new one if it doesn't exist, all within a single call.
  • Optional Session Specification: The OpenSessionRequest protobuf message has been enhanced with an optional SessionSpec field. This spec is used for creating new sessions or for validating the configuration of existing ones.
  • Spec Validation for Existing Sessions: When an existing session is opened with a provided SessionSpec, the system now performs strict validation to ensure the requested spec matches the existing session's configuration, preventing configuration drift.
  • Backward Compatibility: The enhancement maintains full backward compatibility, meaning existing clients that call open_session without providing a SessionSpec will continue to function as before.
Changelog
  • docs/designs/RFE352-open-session-enhancement/FS.md
    • New design document added, detailing the enhancement of the OpenSession RPC to support atomic get-or-create semantics and spec validation.
  • rpc/protos/frontend.proto
    • Modified OpenSessionRequest message to include an optional SessionSpec session field.
  • sdk/python/src/flamepy/core/client.py
    • Updated open_session function signatures (module-level and Connection class) to accept an optional spec parameter, enabling session creation or validation.
  • sdk/rust/src/client/mod.rs
    • Added a new open_session method to the Connection struct, allowing Rust clients to utilize the enhanced RPC with optional session specifications.
    • Imported OpenSessionRequest for use in the new open_session method.
  • session_manager/src/apiserver/frontend.rs
    • Modified the open_session gRPC handler to correctly parse and forward the optional SessionSpec from incoming requests to the controller.
  • session_manager/src/controller/mod.rs
    • Updated the open_session method to accept an optional SessionAttributes and delegate the core logic to the storage layer.
  • session_manager/src/storage/engine/mod.rs
    • Extended the Engine trait with a new open_session method signature to accommodate the optional session specification.
  • session_manager/src/storage/engine/sqlite.rs
    • Implemented the open_session method for the SqliteEngine, providing atomic get-or-create functionality, including internal helper functions (_get_session, _create_session) and a compare_specs function for validation.
    • Refactored existing get_session and create_session methods to utilize the new internal helper functions for transactional operations.
  • session_manager/src/storage/mod.rs
    • Introduced a new open_session method that orchestrates the call to the underlying engine and updates the in-memory session cache.
Activity
  • A new design document was created to formally propose and detail the open_session enhancement.
  • The core gRPC protocol was updated to allow optional session specifications in OpenSessionRequest.
  • The session manager's backend logic was significantly refactored to support atomic session retrieval or creation, including robust spec validation.
  • Both the Python and Rust SDKs were updated to expose this new, more convenient API to developers.
  • Helper functions were introduced in the SQLite engine to streamline transactional operations and ensure data consistency.
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
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 introduces a valuable "get-or-create" enhancement to the open_session RPC, simplifying client logic and preventing potential race conditions. The changes are well-architected, consistently applied from the Protobuf definitions through the backend storage engine to the client SDKs. The use of a database transaction for atomicity is a key strength of this implementation. The accompanying design document is thorough and clear. I have provided a few minor suggestions to further improve the clarity of the design document and simplify a small portion of the Python SDK code.

Comment thread docs/designs/RFE352-open-session-enhancement/FS.md Outdated
Comment thread docs/designs/RFE352-open-session-enhancement/FS.md Outdated
Comment thread sdk/python/src/flamepy/core/client.py Outdated
k82cn added 4 commits February 9, 2026 10:46
Signed-off-by: Klaus Ma <klausm@nvidia.com>
Signed-off-by: Klaus Ma <klausm@nvidia.com>
Signed-off-by: Klaus Ma <klausm@nvidia.com>
Signed-off-by: Klaus Ma <klausm@nvidia.com>
@k82cn k82cn merged commit 71981d9 into xflops:main Feb 9, 2026
5 checks passed
@k82cn k82cn deleted the rfe352_open_session branch February 9, 2026 04:02
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.

Enhance OpenSession rpc to support creating session if spec provided.

1 participant