Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit 71b4c80

Browse files
authored
Fix/some misc (#31)
* fix: SwanHubX/SwanLab#1033 * refactor: change mode backup --> offline * feat: new version
1 parent 74967fc commit 71b4c80

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ build-backend = "hatchling.build"
99

1010
[project]
1111
name = "swankit"
12-
version = "0.2.1"
12+
version = "0.2.2"
1313
dynamic = ["readme", "dependencies"]
1414
description = "Base toolkit for SwanLab"
1515
license = "Apache-2.0"

swankit/env.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class SwanLabMode(Enum):
2222

2323
DISABLED = "disabled"
2424
CLOUD = "cloud"
25-
BACKUP = "backup"
25+
OFFLINE = "offline"
2626
LOCAL = "local"
2727

2828
@classmethod
@@ -107,8 +107,12 @@ def get_save_dir() -> str:
107107
if not os.path.exists(os.path.dirname(folder)):
108108
raise FileNotFoundError(f"{os.path.dirname(folder)} not found")
109109
if not os.path.exists(folder):
110-
# 只创建当前文件夹,不创建父文件夹
111-
os.mkdir(folder)
110+
# 只创建当前文件夹,不创建父文件夹,之所以还要捕捉 FileExistsError,是因为在多线程或多进程环境下,可能会有多个线程或进程同时创建同一个文件夹
111+
# 比如:https://github.com/SwanHubX/SwanLab/issues/1033
112+
try:
113+
os.mkdir(folder)
114+
except FileExistsError:
115+
pass
112116
if not os.path.isdir(folder):
113117
raise NotADirectoryError(f"{folder} is not a directory")
114118
return folder

test/unit/test_env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_list_mode():
2828
assert len(ms) == 4
2929
assert "disabled" in ms
3030
assert "cloud" in ms
31-
assert "backup" in ms
31+
assert "offline" in ms
3232
assert "local" in ms
3333

3434

0 commit comments

Comments
 (0)