Skip to content

Comments

feat: sync_tensorboard add types params#1396

Merged
SAKURA-CAT merged 2 commits intomainfrom
feat/sync-tensorboard-filter
Dec 27, 2025
Merged

feat: sync_tensorboard add types params#1396
SAKURA-CAT merged 2 commits intomainfrom
feat/sync-tensorboard-filter

Conversation

@Zeyi-Lin
Copy link
Member

@Zeyi-Lin Zeyi-Lin commented Dec 27, 2025

Description

使用方式:

import swanlab

swanlab.sync_tensorboardX()
# 只同步标量数据(排除文本、图像等)
swanlab.sync_tensorboardX(types=['scalar', 'scalars'])
writer = SummaryWriter('runs/example')

# 这些不会被同步(因为 types 过滤)
writer.add_image('random_image', np.random.randint(0, 255, (3, 100, 100)), global_step=20)
writer.add_text('random_text', 'hello', global_step=10)

for i in range(100):
    scalar_value = np.random.rand()
    # 这些会被同步(标量数据)
    writer.add_scalar('random_scalar', scalar_value, i)
    writer.add_scalars('random_scalars', {'scalar1': scalar_value, 'scalar2': scalar_value * 2}, i)

Closes: #1390

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Zeyi-Lin, 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 enhances the TensorBoard synchronization functionality by adding a types parameter to the sync_tensorboardX and sync_tensorboard_torch methods. This allows users to selectively synchronize specific data types, such as scalars, images, or text, from their TensorBoard logs to SwanLab. This feature provides greater flexibility and control over the data being logged, enabling more focused analysis and potentially reducing unnecessary data transfer.

Highlights

  • New types parameter: Introduced a new types parameter to swanlab.sync_tensorboardX() and swanlab.sync_tensorboard_torch() functions.
  • Selective Data Synchronization: Users can now specify which types of data (e.g., 'scalar', 'scalars', 'image', 'text') should be synchronized from TensorBoard to SwanLab, allowing for more granular control over logging.
  • Internal Logic Update: The internal patching methods for SummaryWriter were updated to include conditional checks based on the provided types list, ensuring only desired data types are processed.
  • Documentation and Examples: Docstrings for the synchronization functions and example usage in test files have been updated to reflect the new types parameter and its functionality.

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

@Zeyi-Lin Zeyi-Lin requested a review from SAKURA-CAT December 27, 2025 04:17
@Zeyi-Lin Zeyi-Lin self-assigned this Dec 27, 2025
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

这个 PR 很好地实现了通过 types 参数来过滤 sync_tensorboard 同步内容的功能。代码实现清晰,文档和测试也相应地更新了。
我提出了一些建议,主要关于代码的可维护性和最佳实践,希望能帮助你进一步优化代码。此外,.gitignore 文件中似乎包含了一些个人开发环境的配置,建议移除。

@Zeyi-Lin Zeyi-Lin added the 💪 enhancement New feature or request label Dec 27, 2025
@SAKURA-CAT SAKURA-CAT merged commit 9d783c8 into main Dec 27, 2025
5 checks passed
@SAKURA-CAT SAKURA-CAT deleted the feat/sync-tensorboard-filter branch December 27, 2025 06:59
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.

能否在 sync_tensorboard_torch 时 加一些filter

2 participants