From adfa3886d1420bc2847ce5f8803eeee56a686107 Mon Sep 17 00:00:00 2001 From: KAAANG <79990647+SAKURA-CAT@users.noreply.github.com> Date: Mon, 2 Jun 2025 19:11:20 +0800 Subject: [PATCH 1/4] feat: backup mode --- pyproject.toml | 2 +- swankit/env.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2a008e9..5d291f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ build-backend = "hatchling.build" [project] name = "swankit" -version = "0.2.0" +version = "0.2.1" dynamic = ["readme", "dependencies"] description = "Base toolkit for SwanLab" license = "Apache-2.0" diff --git a/swankit/env.py b/swankit/env.py index 25bcd34..ff65c89 100644 --- a/swankit/env.py +++ b/swankit/env.py @@ -22,7 +22,7 @@ class SwanLabMode(Enum): DISABLED = "disabled" CLOUD = "cloud" - CLOUD_ONLY = "cloud-only" + BACKUP = "backup" LOCAL = "local" @classmethod @@ -49,7 +49,7 @@ class SwanLabSharedEnv(Enum): """ SWANLAB_MODE = "SWANLAB_MODE" """ - swanlab的解析模式,涉及操作员注册的回调,目前有三种:local、cloud、disabled,默认为cloud + swanlab的解析模式,涉及操作员注册的回调,目前有四种:local、cloud、disabled 和 backup,默认为cloud 大小写不敏感 """ From 88373f63a37751ff8ac601d5dc7dd81171e86f10 Mon Sep 17 00:00:00 2001 From: KAAANG <79990647+SAKURA-CAT@users.noreply.github.com> Date: Mon, 2 Jun 2025 19:57:50 +0800 Subject: [PATCH 2/4] refactor: delete exp count in callback --- swankit/callback/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/swankit/callback/__init__.py b/swankit/callback/__init__.py index 5ca047b..f288f87 100644 --- a/swankit/callback/__init__.py +++ b/swankit/callback/__init__.py @@ -42,7 +42,6 @@ def before_init_experiment( run_id: str, exp_name: str, description: str, - num: int, colors: Tuple[str, str], *args, **kwargs, @@ -52,7 +51,6 @@ def before_init_experiment( :param run_id: str, SwanLabRun的运行id :param exp_name: str, 实验名称 :param description: str, 实验描述 - :param num: int, 历史实验数量 :param colors: Tuple[str, str], 实验颜色,[light, dark] """ pass From 3e38130cca1ac4a1c427c1c61edc0083cdfac676 Mon Sep 17 00:00:00 2001 From: KAAANG <79990647+SAKURA-CAT@users.noreply.github.com> Date: Tue, 3 Jun 2025 13:03:12 +0800 Subject: [PATCH 3/4] chore: add public params on init --- swankit/callback/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/swankit/callback/__init__.py b/swankit/callback/__init__.py index f288f87..3a14fc2 100644 --- a/swankit/callback/__init__.py +++ b/swankit/callback/__init__.py @@ -20,11 +20,12 @@ class SwanKitCallback(ABC): 此处只定义会被调用的函数,用于接口规范 """ - def on_init(self, proj_name: str, workspace: str, logdir: str = None, *args, **kwargs): + def on_init(self, proj_name: str, workspace: str, public: bool = None, logdir: str = None, *args, **kwargs): """ 执行`swanlab.init`时调用,此时运行时环境变量没有被设置,此时修改环境变量还是有效的 :param logdir: str, 用户设置的日志目录 :param proj_name: str, 项目名称 + :param public: bool, 是否为公开项目 :param workspace: str, 工作空间 :param kwargs: dict, 其他参数,为了增加灵活性,可以在on_init的时候设置一些其他类内参数 """ From 7a952a24e2123a9ea7c76a498514be68cba8690d Mon Sep 17 00:00:00 2001 From: KAAANG <79990647+SAKURA-CAT@users.noreply.github.com> Date: Tue, 3 Jun 2025 22:02:03 +0800 Subject: [PATCH 4/4] fix: test --- test/unit/test_env.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/test_env.py b/test/unit/test_env.py index 27a1294..09f809e 100644 --- a/test/unit/test_env.py +++ b/test/unit/test_env.py @@ -28,7 +28,7 @@ def test_list_mode(): assert len(ms) == 4 assert "disabled" in ms assert "cloud" in ms - assert "cloud-only" in ms + assert "backup" in ms assert "local" in ms