Skip to content

Conversation

SAKURA-CAT
Copy link
Member

@SAKURA-CAT SAKURA-CAT commented Jun 6, 2025

Description

基本实现sync功能,暂未实现:

  1. 测试
  2. 相关报错捕获
  3. sync命令参数设置

@SAKURA-CAT SAKURA-CAT requested a review from Copilot June 6, 2025 10:31
@SAKURA-CAT SAKURA-CAT self-assigned this Jun 6, 2025
@SAKURA-CAT SAKURA-CAT added the 💪 enhancement New feature or request label Jun 6, 2025
Copilot

This comment was marked as outdated.

@SAKURA-CAT SAKURA-CAT requested a review from Copilot June 6, 2025 10:36
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces the core sync functionality to upload local experiment backups to the cloud, extends backup parsing models to include footers, and wires the new command into the CLI and HTTP layers.

  • Add sync() entry point and export in swanlab/sync
  • Enhance backup models (Footer, ModelsParser) and enable iteration in DataStore
  • Integrate sync command into the CLI and adjust mount_exp to accept optional colors

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
swanlab/sync/init.py Implements sync(dir_path, login_required) and its upload workflow
swanlab/log/backup/models.py Adds Footer, refactors from_record, enhances file‐loading logic
swanlab/log/backup/handler.py Introduces BACKUP_FILE/BACKUP_VERSION, writes Footer on stop
swanlab/log/backup/datastore.py Adds __iter__/__next__ to support record iteration
swanlab/cli/main.py Registers the sync command in the top‐level CLI
swanlab/cli/commands/sync/init.py Implements the click‐based sync command
swanlab/api/http.py Changes mount_exp to accept optional colors
Comments suppressed due to low confidence (5)

swanlab/log/backup/models.py:50

  • The return type annotation Tuple[str, 'BaseModel'] is outdated—from_record now returns a single model instance. Please update the signature to -> BaseModel to match the implementation.
def from_record(cls, data: str) -> Tuple[str, 'BaseModel']:

swanlab/sync/init.py:17

  • [nitpick] The new sync function contains multiple code paths (login logic, parsing, uploads) but currently lacks unit or integration tests. Consider adding tests to cover scenarios like missing backup file, login failure, and successful upload.
def sync(dir_path: str, login_required: bool = True):

swanlab/log/backup/handler.py:68

  • [nitpick] You've changed version to represent the backup file format rather than the package version. Ensure consumers of the header understand this semantic change and update any documentation or mismatch error messages accordingly.
BACKUP_VERSION = 0

swanlab/log/backup/models.py:249

  • Accessing metric_info.metric['data'] may not match the intended source of buffer file names; the original loop over metric_info.metric_buffers was likely correct. Verify that metric_info.metric['data'] exists and contains the expected file names, or revert to using metric_info.metric_buffers.
for name in metric_info.metric['data']:

swanlab/api/http.py:303

  • The type hint Optional[Tuple[str, str]] requires importing Optional from typing. Please add from typing import Optional to avoid a NameError.
def mount_exp(self, exp_name, colors: Optional[Tuple[str, str]], description: str = None, tags: List[str] = None):

@SAKURA-CAT SAKURA-CAT merged commit d9d1f94 into feature/backup Jun 6, 2025
5 checks passed
@SAKURA-CAT SAKURA-CAT deleted the feat/sync branch June 6, 2025 10:41
SAKURA-CAT added a commit that referenced this pull request Jun 6, 2025
* feat: sync init

* fix: file name

* feat: sync cli

* feat: logs footer
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.

1 participant