Skip to content

Conversation

@SAKURA-CAT
Copy link
Member

添加客户端心跳,以解决resume等场景下过久未上传日志,错误关闭实验的问题

closes: #1255

Moved client utility functions and models to a new utils.py file, including the safe_request decorator. Introduced a client heartbeat mechanism to keep experiments active, with integration in CloudPyCallback. Updated imports and improved type hinting for better maintainability.
@SAKURA-CAT SAKURA-CAT requested a review from Zeyi-Lin December 31, 2025 05:57
@SAKURA-CAT SAKURA-CAT self-assigned this Dec 31, 2025
@SAKURA-CAT SAKURA-CAT added the 💪 enhancement New feature or request label Dec 31, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @SAKURA-CAT, 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 introduces a crucial client-side heartbeat feature to ensure the continuous active status of experiments, addressing issues where experiments might be incorrectly closed due to prolonged periods without log uploads or during resume operations. Concurrently, it refactors core client utilities by centralizing error handling and model definitions, improving code organization and maintainability.

Highlights

  • Experiment Heartbeat Mechanism: A new client-side heartbeat mechanism has been implemented to prevent experiments from being prematurely terminated due to inactivity, such as during resume operations or when log uploads are infrequent. This ensures experiments remain active even during periods of low data transmission.
  • Client Utilities Refactoring: Core client utilities have been refactored by consolidating network error handling (the safe_request function) and client model definitions (ProjectInfo, ExperimentInfo) into a dedicated swanlab/core_python/client/utils.py module, improving code organization.
  • API and Lifecycle Integration: A new send_experiment_heartbeat API endpoint was added, which is periodically invoked by a client-side timer. This heartbeat is seamlessly integrated into the experiment's lifecycle, starting on initialization and stopping gracefully upon experiment termination.

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

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

这个拉取请求引入了心跳机制来保持实验的活跃状态,这是一个很好的补充,可以防止实验过早终止。将客户端工具函数重构到单独的 utils.py 文件中也改善了代码的组织结构。我有一些建议可以提高代码质量和健壮性。具体来说,我建议避免使用通配符导入以提高清晰度,使用 f-string 进行日志记录,并添加空值检查以防止在停止心跳时出现潜在的运行时错误。

Added an interval parameter to create_client_heartbeat for configurable heartbeat timing. Improved CloudPyCallback.on_stop to check for heartbeat existence before canceling and joining, preventing potential errors.
Corrected a typo in a comment to improve clarity and maintain code quality. No functional changes were made.
@SAKURA-CAT SAKURA-CAT merged commit fb51ee7 into main Jan 1, 2026
5 checks passed
@SAKURA-CAT SAKURA-CAT deleted the feat/heartbeat branch January 1, 2026 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💪 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ADVICE] 加入客户端的心跳,更好的反馈实验状态

3 participants