Skip to content

Commit

Permalink
Feat/bugfix-login (#576)
Browse files Browse the repository at this point in the history
* Update env.py

* Update package.json
  • Loading branch information
Zeyi-Lin authored May 27, 2024
1 parent 4b150ce commit 8ac4e77
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
26 changes: 11 additions & 15 deletions swanlab/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <LOG '
'PATH>" 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 <LOG '
'PATH>" 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
Expand Down Expand Up @@ -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):
Expand All @@ -199,8 +196,7 @@ def init_env(env: Optional[Env] = None):


def reset_env():
"""重置
"""
"""重置"""
_env.clear()


Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion swanlab/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swanlab",
"version": "0.3.5",
"version": "0.3.6",
"description": "",
"python": "true",
"host": {
Expand Down

0 comments on commit 8ac4e77

Please sign in to comment.