-
Notifications
You must be signed in to change notification settings - Fork 142
Feature/backup mode #1024
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
Feature/backup mode #1024
Conversation
* feat: add backup api * refactor: delete exp count in callback * refactor: create folder not only local * refactor: log handler and callback params * refactor: again! * chore: revert log
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 adds a new “backup” logging mode that retains all cloud-mode features locally without uploading, introduces a shared backup model layer, and integrates backup callbacks across the SDK and runtime.
- Extend ProxyType and write logic to skip proxying when proxy_type is
"none"
. - Introduce
BackupHandler
, backup models (Pydantic), and writer utilities for serializing/deserializing and writing backup data. - Update environment, SDK initialization, run operator, and all callbackers (local/cloud/backup) to respect the new backup mode.
Reviewed Changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
swanlab/log/type.py | Add 'none' to ProxyType to disable terminal proxy. |
swanlab/log/log.py | Guard log uploads when no messages are present. |
swanlab/log/backup/models.py | New backup data models with JSON (de)serialization. |
swanlab/log/backup/backup_handler.py | BackupHandler for async writing of backup entries. |
swanlab/log/backup/writer.py | Helper to write runtime info and media buffers. |
swanlab/env.py | Extend allowed modes with "backup" . |
swanlab/data/utils.py | Import BackupCallback and login info type. |
swanlab/data/sdk.py | Support "backup" in MODES and docs. |
swanlab/data/run/main.py | Integrate should_save logic for backup mode. |
swanlab/data/run/helper.py | Adjusted on_stop signature to include epoch . |
swanlab/data/run/callback.py | Centralize backup start/stop and proxy registration. |
swanlab/data/callbacker/local.py | Hook in backup callbacks alongside local behavior. |
swanlab/data/callbacker/cloud.py | Hook in backup callbacks alongside cloud behavior. |
swanlab/data/callbacker/backup.py | Define no-op backup-specific callbacks. |
swanlab/api/upload/model.py | Include LogModel and adjust metric path prefix. |
swanlab/api/upload/init.py | Export LogModel . |
swanlab/api/http.py | Expose history_exp_count and adjust mount_project . |
🏠 主要功能
完成了日志备份功能的 80%:
backup
模式,此模式下支持云端模式的所有功能但不上传文件,并保存相关备份文件到run_dir
文件夹内backup
、cloud
、local
三大模式都支持备份日志文件,并且在设计上同时支持云端的所有功能local
模式的数据格式,现在local
模式只在swanboard
回调层面区分了部分不兼容的图表类型(比如 3D 点云)和功能(比如硬件监控),相关文件依旧在run_dir
文件夹内,它是backup
模式保存数据的全集,这意味着用户可以将local
模式下的日志输出保存到云端回调模型
和上传接口模型
之间的中间层——备份模型
,允许在回调模型
和上传接口模型
之间互相切换,这是日志备份功能的基础。💡 设计思想
backup
模式新增BackupCallback
回调类,方便触发备份器事件run_dir
文件夹内,包括a. backup.swanlab:对一次实验的整体性描述,包含日志等信息
b. files:继承原本实验元信息保存的设计思想,保存conda环境、python环境、系统信息、用户config配置对象等文件
c. media:保存实验产出的媒体文件
⌛️ 待完成