Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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 pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build-backend = "hatchling.build"

[project]
name = "swankit"
version = "0.2.1"
version = "0.2.2"
dynamic = ["readme", "dependencies"]
description = "Base toolkit for SwanLab"
license = "Apache-2.0"
Expand Down
10 changes: 7 additions & 3 deletions swankit/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SwanLabMode(Enum):

DISABLED = "disabled"
CLOUD = "cloud"
BACKUP = "backup"
OFFLINE = "offline"
LOCAL = "local"

@classmethod
Expand Down Expand Up @@ -107,8 +107,12 @@ def get_save_dir() -> str:
if not os.path.exists(os.path.dirname(folder)):
raise FileNotFoundError(f"{os.path.dirname(folder)} not found")
if not os.path.exists(folder):
# 只创建当前文件夹,不创建父文件夹
os.mkdir(folder)
# 只创建当前文件夹,不创建父文件夹,之所以还要捕捉 FileExistsError,是因为在多线程或多进程环境下,可能会有多个线程或进程同时创建同一个文件夹
# 比如:https://github.com/SwanHubX/SwanLab/issues/1033
try:
os.mkdir(folder)
except FileExistsError:
pass
if not os.path.isdir(folder):
raise NotADirectoryError(f"{folder} is not a directory")
return folder
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_list_mode():
assert len(ms) == 4
assert "disabled" in ms
assert "cloud" in ms
assert "backup" in ms
assert "offline" in ms
assert "local" in ms


Expand Down