chore: enhance runner.service with open_session.#354
Conversation
Signed-off-by: Klaus Ma <klausm@nvidia.com>
Summary of ChangesHello @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 refactors the Highlights
Changelog
Activity
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 enhances runner.service to use the new open_session API, allowing for session reuse and enabling recursive service calls. The changes in sdk/python/src/flamepy/runner/runner.py correctly implement the switch from create_session to open_session. New e2e tests have been added to validate this new functionality, including recursive calls and session reuse across multiple services.
My review identifies one high-severity issue in the new recursive test case. The test implementation reveals a flaw in runner.Runner that causes significant performance degradation and resource leaks due to repeated, unnecessary packaging and uploading. I've provided details in a specific comment.
e2e/tests/test_runner.py
Outdated
|
|
||
| # Create a new Runner to reuse existing app (fail_if_exists=False by default) | ||
| # The outer Runner manages the lifecycle (registration/unregistration) | ||
| inner_runner = runner.Runner(self._session_context.application_name) |
There was a problem hiding this comment.
This line creates a new runner.Runner instance on each recursive call. The runner.Runner constructor is heavyweight: it packages the current directory and uploads it to storage on every invocation, even if the application already exists. This leads to significant performance overhead and resource leakage, as the created packages are not cleaned up.
The inner_runner is not closed (and cannot be, as it would close the shared session), so the uploaded packages in storage and local temporary package files are leaked on every recursive step.
To fix this, runner.Runner._start() should be refactored to check for the application's existence before packaging and uploading. If the application already exists and fail_if_exists=False, it should skip these expensive steps.
While the fix is in sdk/python/src/flamepy/runner/runner.py, which is outside the diff for this file, this test introduces the problematic pattern. The test is valuable for testing recursion, but it highlights a critical flaw in the Runner implementation that should be addressed.
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>
Signed-off-by: Klaus Ma <klausm@nvidia.com>
Signed-off-by: Klaus Ma <klausm@nvidia.com>
Signed-off-by: Klaus Ma <klausm@nvidia.com>
No description provided.