From 8ac4e77caf3bb9f0c7fe68dffe2bd654b3db55e3 Mon Sep 17 00:00:00 2001 From: Ze-Yi LIN <58305964+Zeyi-Lin@users.noreply.github.com> Date: Tue, 28 May 2024 00:58:58 +0800 Subject: [PATCH] Feat/bugfix-login (#576) * Update env.py * Update package.json --- swanlab/env.py | 26 +++++++++++--------------- swanlab/package.json | 2 +- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/swanlab/env.py b/swanlab/env.py index 8c5c988eb..5b8b67114 100644 --- a/swanlab/env.py +++ b/swanlab/env.py @@ -91,11 +91,14 @@ def get_swanlog_dir(env: Optional[Env] = None) -> Optional[str]: assert_exist( path, target_type="folder", - desc='The log file was not found in the default path "{path}". ' - 'Please use the "swanlab watch -l " command to specify the location of the log path."'.format(path=path) - if path == default else 'SWANLAB_LOG_DIR must be an existing path, now is "{path}"'.format(path=path), - t_desc='SWANLAB_LOG_DIR must be a directory, now is "{path}"'.format(path=path) + desc=( + 'The log file was not found in the default path "{path}". ' + 'Please use the "swanlab watch -l " command to specify the location of the log path."'.format(path=path) + if path == default + else 'SWANLAB_LOG_DIR must be an existing path, now is "{path}"'.format(path=path) + ), + t_desc='SWANLAB_LOG_DIR must be a directory, now is "{path}"'.format(path=path), ) _env[ROOT] = path return path @@ -176,13 +179,7 @@ def is_dev(env: Optional[Env] = None) -> bool: # ---------------------------------- 初始化基础环境变量 ---------------------------------- # 所有的初始化函数 -function_list = [ - get_mode, - get_swanlog_dir, - get_server_port, - get_server_host, - is_dev -] +function_list = [get_mode, get_swanlog_dir, get_server_port, get_server_host, is_dev] def init_env(env: Optional[Env] = None): @@ -199,8 +196,7 @@ def init_env(env: Optional[Env] = None): def reset_env(): - """重置 - """ + """重置""" _env.clear() @@ -282,7 +278,7 @@ def assert_exist(path: str, target_type: str = None, ra: bool = True, desc: str if not is_strict_mode(): return os.path.exists(path) if not os.path.exists(path): - if ra or target_type is not None: + if ra: raise FileNotFoundError(desc or "{path} not existed".format(path=path)) else: return False diff --git a/swanlab/package.json b/swanlab/package.json index abb3d0df7..571dd803d 100644 --- a/swanlab/package.json +++ b/swanlab/package.json @@ -1,6 +1,6 @@ { "name": "swanlab", - "version": "0.3.5", + "version": "0.3.6", "description": "", "python": "true", "host": {