Skip to content

Conversation

SAKURA-CAT
Copy link
Member

完成日志备份基本框架

@SAKURA-CAT SAKURA-CAT requested a review from Copilot June 3, 2025 14:05
@SAKURA-CAT SAKURA-CAT self-assigned this Jun 3, 2025
@SAKURA-CAT SAKURA-CAT added the 💪 enhancement New feature or request label Jun 3, 2025
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

Adds a basic framework and integration points for a new “backup” mode that writes and retains local logs without uploading to the cloud.

  • Introduce a backup flag in settings and extend mode/init logic to handle backup.
  • Refactor the core logger to dispatch to multiple handlers and inject a backup handler.
  • Add stub modules and callbacks under swanlab/log/backup and swanlab/data/callbacker/backup.

Reviewed Changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
test/unit/data/callbacker/test_local.py Updated test to call _terminal_handler instead of _write_handler.
swanlab/swanlab_settings.py Added backup: StrictBool field to settings.
swanlab/log/log.py Refactored to support multiple handlers and no longer take a per-handler arg.
swanlab/log/backup/models.py Added stub module for backup JSON models.
swanlab/log/backup/init.py Implemented BackupHandler with decorator stubs.
swanlab/env.py Extended MODE enum and removed one RUNTIME value.
swanlab/data/utils.py Adjusted _create_operator signature to accept login_info and cbs.
swanlab/data/sdk.py Updated SDK init to support backup mode and logdir setup.
swanlab/data/run/main.py Updated run initialization to control save behavior and expanded on_init flow.
swanlab/data/run/callback.py Added low-level terminal/error hooks and backup integration.
swanlab/data/callbacker/local.py Cleaned up old write handler, introduced _terminal_handler.
swanlab/data/callbacker/cloud.py Removed duplicate utils and aligned terminal handling.
swanlab/data/callbacker/backup.py Added stub callback for backup mode.
swanlab/api/http.py Exposed history_exp_count and removed return from mount_project.
Comments suppressed due to low confidence (2)

test/unit/data/callbacker/test_local.py:33

  • [nitpick] The test is still named test_local_write_handler but now calls _terminal_handler. Rename the test to test_local_terminal_handler (and update any references) for clarity.
def test_local_write_handler(monkeypatch):

swanlab/data/run/main.py:227

  • The code uses random.randint but random is not imported in this module, leading to a NameError. Add import random at the top.
num = random.randint(0, 20)

@SAKURA-CAT SAKURA-CAT merged commit 060daba into feature/backup-mode Jun 3, 2025
5 of 10 checks passed
@SAKURA-CAT SAKURA-CAT deleted the feature/backup branch June 3, 2025 14:15
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