Skip to content

Commit

Permalink
add rule (#646)
Browse files Browse the repository at this point in the history
增加 . 和 + 两个字符串作为项目名称的合法输入
更新swanboard依赖,修复ujson问题:SwanHubX/SwanLab-Dashboard#45
更新版本:0.3.14
  • Loading branch information
SAKURA-CAT authored Jul 20, 2024
1 parent e3f227e commit 53c52c8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
swankit==0.1.1b1
swanboard==0.1.3b1
swanboard==0.1.3b2
cos-python-sdk-v5
requests
click
Expand Down
6 changes: 3 additions & 3 deletions swanlab/data/formater.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def _auto_cut(name: str, value: str, max_len: int, cut: bool) -> str:

def check_proj_name_format(name: str, auto_cut: bool = True) -> str:
"""
检查项目名格式,必须是0-9a-zA-Z以及连字符(_-)
检查项目名格式,必须是0-9a-zA-Z以及连字符(_-.+)
最大长度为100个字符
Parameters
Expand All @@ -119,8 +119,8 @@ def check_proj_name_format(name: str, auto_cut: bool = True) -> str:
name超出长度
"""
max_len = 100
if not check_string(name) or not re.match(r"^[0-9a-zA-Z_-]+$", name):
raise ValueError(f"Project name `{name}` is invalid, which must be 0-9, a-z, A-Z, _ , -")
if not check_string(name) or not re.match(r"^[0-9a-zA-Z_\-+.]+$", name):
raise ValueError(f"Project name `{name}` is invalid, which must be 0-9, a-z, A-Z, _ , -, +, .")
name = name.strip()
return _auto_cut("project", name, max_len, auto_cut)

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.13",
"version": "0.3.14",
"description": "",
"python": "true"
}
6 changes: 6 additions & 0 deletions test/unit/data/test_fomater.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ class TestProjName:
generate(size=1),
"-",
"_",
".12",
"1",
"1.b",
"a.b",
"+",
"1+1"
],
)
def test_proj_name_common(self, value):
Expand Down

0 comments on commit 53c52c8

Please sign in to comment.