Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
swankit==0.2.1
swankit==0.2.2
urllib3>=1.26.0
requests>=2.25.0
setuptools
Expand Down
4 changes: 2 additions & 2 deletions swanlab/data/callbacker/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
from ..run import get_run


class BackupCallback(SwanLabRunCallback):
class OfflineCallback(SwanLabRunCallback):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def __str__(self) -> str:
return "SwanLabBackupCallback"
return "SwanLabOfflineCallback"

# ---------------------------------- 辅助函数 ----------------------------------
def _sync_tip_print(self):
Expand Down
2 changes: 1 addition & 1 deletion swanlab/data/run/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def __init__(
should_save = False
elif self.__mode == "local":
should_save = True
elif self.__mode == "backup":
elif self.__mode == "offline":
should_save = True
elif self.__mode == "cloud":
should_save = swanlab_settings.backup
Expand Down
6 changes: 3 additions & 3 deletions swanlab/data/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def login(api_key: str = None, host: str = None, web_host: str = None, save: boo
os.environ[SwanLabEnv.API_KEY.value] = api_key


MODES = Literal["disabled", "cloud", "local", "backup"]
MODES = Literal["disabled", "cloud", "local", "offline"]


class SwanLabInitializer:
Expand Down Expand Up @@ -139,7 +139,7 @@ def init(
If the value is 'cloud', data will be uploaded to the cloud and the local log will be saved.
If the value is 'local', data will only be saved locally and will not be uploaded to the cloud.
If the value is 'disabled', data will not be saved or uploaded, just parsing the data.
If the value is 'backup', data will be saved locally without uploading to the cloud.
If the value is 'offline', data will be saved locally without uploading to the cloud.
load : str, optional
If you pass this parameter,SwanLab will search for the configuration file you specified
(which must be in JSON or YAML format)
Expand Down Expand Up @@ -194,7 +194,7 @@ def init(
callbacks = check_callback_format(self.cbs + callbacks)
# 校验mode参数并适配 backup 模式
mode, login_info = _init_mode(mode)
if mode == "backup":
if mode == "offline":
merge_settings(Settings(backup=True))
elif mode == "disabled":
merge_settings(Settings(backup=False))
Expand Down
6 changes: 3 additions & 3 deletions swanlab/data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from swankit.log import FONT

from swanlab.api import terminal_login, LoginInfo
from swanlab.data.callbacker.backup import BackupCallback
from swanlab.data.callbacker.backup import OfflineCallback
from swanlab.data.callbacker.cloud import CloudRunCallback
from swanlab.data.formatter import check_proj_name_format, check_load_json_yaml
from swanlab.data.run import SwanLabRun
Expand Down Expand Up @@ -209,8 +209,8 @@ def _create_operator(
# 本地模式不保存 media,由回调同步保存
c.append(LocalRunCallback(backup=backup, backup_media=False))
# 1.4 . 备份模式
elif mode == SwanLabMode.BACKUP.value:
c.append(BackupCallback(backup=True))
elif mode == SwanLabMode.OFFLINE.value:
c.append(OfflineCallback(backup=True))
# 1.5. 其他非法模式 报错,backup 模式不需要在此处理
# 上层已经 merge_settings , get_settings().backup 与此处是否设置 backup 功能等价
elif mode not in SwanLabMode.list():
Expand Down
4 changes: 2 additions & 2 deletions swanlab/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SwanLabEnv(enum.Enum):
"""
MODE = SwanLabSharedEnv.SWANLAB_MODE.value
"""
swanlab的解析模式,涉及操作员注册的回调,目前有三种:local、cloud、disabled,默认为cloud
swanlab的解析模式,涉及操作员注册的回调,目前有四种:local、cloud、disabled、offline,默认为cloud
大小写敏感
"""
SWANBOARD_PROT = "SWANLAB_BOARD_PORT"
Expand Down Expand Up @@ -139,7 +139,7 @@ def check(cls):
:raises ValueError: 如果环境变量的值不在预期值中
"""
envs = {
cls.MODE.value: ["local", "cloud", "disabled", "backup"],
cls.MODE.value: ["local", "cloud", "disabled", "offline"],
cls.RUNTIME.value: ["user", "develop", "test", "test-no-cloud"],
}
for k, vs in envs.items():
Expand Down
6 changes: 3 additions & 3 deletions test/unit/data/test_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,16 +308,16 @@ def test_init_logdir_env(self):
run = S.init(mode="local")
assert run.public.swanlog_dir == logdir

def test_init_logdir_backup(self):
def test_init_logdir_offline(self):
logdir = os.path.join(T.TEMP_PATH, generate()).__str__()
os.environ[LOG_DIR] = logdir
run = S.init(mode="backup")
run = S.init(mode="offline")
assert run.public.swanlog_dir == logdir
run.finish()
del os.environ[LOG_DIR]
logdir = os.path.join(T.TEMP_PATH, generate()).__str__()
os.environ[LOG_DIR] = logdir
run = S.init(mode="backup")
run = S.init(mode="offline")
assert run.public.swanlog_dir == logdir

@pytest.mark.skipif(T.is_skip_cloud_test, reason="skip cloud test")
Expand Down
Loading