-
Notifications
You must be signed in to change notification settings - Fork 142
Feat/sync #1046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/sync #1046
Conversation
There was a problem hiding this 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 inswanlab/sync
- Enhance backup models (
Footer
,ModelsParser
) and enable iteration inDataStore
- Integrate
sync
command into the CLI and adjustmount_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 overmetric_info.metric_buffers
was likely correct. Verify thatmetric_info.metric['data']
exists and contains the expected file names, or revert to usingmetric_info.metric_buffers
.
for name in metric_info.metric['data']:
swanlab/api/http.py:303
- The type hint
Optional[Tuple[str, str]]
requires importingOptional
fromtyping
. Please addfrom 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):
* feat: sync init * fix: file name * feat: sync cli * feat: logs footer
Description
基本实现sync功能,暂未实现: