Skip to content

Conversation

SAKURA-CAT
Copy link
Member

借鉴 W&B 的本地日志保存方案,使用 Google 的 LevelDB 协议保存持久化数据并实现完整性校验,防止数据损坏和篡改

@SAKURA-CAT SAKURA-CAT self-assigned this Jun 5, 2025
@SAKURA-CAT SAKURA-CAT added 📚 documentation Improvements or additions to documentation 💪 enhancement New feature or request labels Jun 5, 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

This PR introduces a LevelDB‐style DataStore for durable logging and integrates it into the existing backup handler, replacing plain-text file writes with a structured, CRC‐protected format. Tests for basic write/scan functionality are also added.

  • Implement DataStore using LevelDB log format, including CRC32 integrity checks
  • Rename model serialization methods (to_backupto_record, from_backupfrom_record) and update handler calls
  • Update BackupHandler to use DataStore instead of direct file I/O and add unit tests

Reviewed Changes

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

Show a summary per file
File Description
test/unit/log/backup/test_datastore.py Add basic write/read tests for new DataStore implementation
swanlab/log/backup/models.py Rename serialization methods to to_record/from_record and append newline
swanlab/log/backup/handler.py Swap raw file handle for DataStore, update method calls
swanlab/log/backup/datastore.py New DataStore class implementing LevelDB log format with CRC
swanlab/log/backup/init.py Update import path for handler
swanlab/data/callbacker/backup.py Incorrect @file annotation name changed to crypto.py
swanlab/cli/commands/sync/init.py Add new sync command module header
Comments suppressed due to low confidence (3)

swanlab/log/backup/handler.py:76

  • [nitpick] The attribute name f is too generic now that it holds a DataStore; consider renaming it to store or datastore for clarity.
        self.f = DataStore()

swanlab/data/callbacker/backup.py:3

  • The @file annotation is set to crypto.py but the filename is still backup.py; please correct the annotation to match the file name.
@file: crypto.py

swanlab/log/backup/datastore.py:32

  • [nitpick] Function name strtobytes doesn't follow standard snake_case naming; consider renaming to str_to_bytes (and bytes_to_str).
def strtobytes(x):

@SAKURA-CAT SAKURA-CAT merged commit 6bbd7ff into feature/backup Jun 5, 2025
5 checks passed
@SAKURA-CAT SAKURA-CAT deleted the feat/backup-crypto branch June 5, 2025 11:52
SAKURA-CAT added a commit that referenced this pull request Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 documentation Improvements or additions to documentation 💪 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant