From afe06a49fbfb7b4f99fc25463d3a9fb44960d8b1 Mon Sep 17 00:00:00 2001 From: ZeYi Lin <944270057@qq.com> Date: Tue, 10 Feb 2026 22:48:45 +0800 Subject: [PATCH 1/2] convert to None --- swanlab/data/sdk.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/swanlab/data/sdk.py b/swanlab/data/sdk.py index 60da47f34..14592e983 100644 --- a/swanlab/data/sdk.py +++ b/swanlab/data/sdk.py @@ -264,6 +264,10 @@ def init( swanlog.warning(f"project name is too long, auto cut to {p}") project = p # 2.2 校验实验名称 + # 处理空字符串情况 + if experiment_name == "": + swanlog.warning("The experiment name is an empty string, automatically converted to None.") + experiment_name = None if experiment_name: e = check_exp_name_format(experiment_name) if experiment_name != e: From 26d6878dd42237641823bb356f8cbd0afd04e794 Mon Sep 17 00:00:00 2001 From: ZeYi Lin <944270057@qq.com> Date: Wed, 11 Feb 2026 00:00:09 +0800 Subject: [PATCH 2/2] fix --- swanlab/data/sdk.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/swanlab/data/sdk.py b/swanlab/data/sdk.py index 14592e983..9beb71be5 100644 --- a/swanlab/data/sdk.py +++ b/swanlab/data/sdk.py @@ -264,9 +264,9 @@ def init( swanlog.warning(f"project name is too long, auto cut to {p}") project = p # 2.2 校验实验名称 - # 处理空字符串情况 - if experiment_name == "": - swanlog.warning("The experiment name is an empty string, automatically converted to None.") + # 处理空字符串或纯空格字符串情况 + if experiment_name is not None and not experiment_name.strip(): + swanlog.warning("The experiment name is an empty or whitespace-only string, automatically converted to None.") experiment_name = None if experiment_name: e = check_exp_name_format(experiment_name)