Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] 项目名称是否可以包含“\“”/“字符? #719

Closed
Puiching-Memory opened this issue Oct 12, 2024 · 8 comments
Closed
Assignees
Labels
🐛 bug Something isn't working 🙋 help wanted Extra attention is needed

Comments

@Puiching-Memory
Copy link
Contributor

Puiching-Memory commented Oct 12, 2024

🤔 Question description [Please make everyone to understand it]

在我自定义项目名称的时候,因为包含了路径字符”/“所以报错
我想知道这里是否可以支持”/“”\“字符?
此次我使用的名称是:C:\workspace\github\monolite\experiment\monolite_YOLO11_centernet_2024-10-12 11:48:54.041674

Traceback (most recent call last):
  File "C:\workspace\github\monolite\tools\train.py", line 122, in <module>
    swanlab.init(
  File "C:\Users\11386\.conda\envs\monolite\Lib\site-packages\swanlab\data\sdk.py", line 154, in init
    project = _check_proj_name(project if project else os.path.basename(os.getcwd()))  # 默认实验名称为当前目录名
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\11386\.conda\envs\monolite\Lib\site-packages\swanlab\data\sdk.py", line 49, in _check_proj_name
    _name = check_proj_name_format(name)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\11386\.conda\envs\monolite\Lib\site-packages\swanlab\data\formater.py", line 119, in check_proj_name_format
    raise ValueError(f"Project name `{name}` is invalid, which must be 0-9, a-z, A-Z, _ , -, +, .")
ValueError: Project name `C:\workspace\github\monolite\experiment\monolite_YOLO11_centernet_2024-10-12 11:48:54.041674` is invalid, which must be 0-9, a-z, A-Z, _ , -, +, .

🚑 Any additional [like screenshots]

def check_proj_name_format(name: str, auto_cut: bool = True) -> str:
    """
    检查实验名称格式,最大长度为95个字符,一个中文字符算一个字符
    其他不做限制,实验名称可以包含任何字符

    Parameters
    ----------
    name : str
        待检查的字符串
    auto_cut : bool, optional
        如果超出长度,是否自动截断,默认为True
        如果为False,则超出长度会抛出异常

    Returns
    -------
    str
        检查后的字符串

    Raises
    ------
    TypeError
        name不是字符串,或者name为空字符串
    ValueError
        name不符合规定格式
    IndexError
        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, _ , -, +, .")
    name = name.strip()
    return _auto_cut("project", name, max_len, auto_cut)
  • SwanLab Version:
    0.3.21

  • Platform:

  • windows11

@Puiching-Memory Puiching-Memory added the 🙋 help wanted Extra attention is needed label Oct 12, 2024
@Puiching-Memory Puiching-Memory changed the title [QUESTION] 项目名称是否可以包含空格? [QUESTION] 项目名称是否可以包含“\“”/“字符? Oct 12, 2024
@Puiching-Memory
Copy link
Contributor Author

experiment_name似乎没有这种限制,代码正常工作,我比较困惑project和experiment_name参数之间的区别

    swanlab.init(
        experiment_name=f"{args.cfg}_{datetime.datetime.now()}",
        #project=f"{args.cfg}_{datetime.datetime.now()}",
        logdir="./logs",
        mode="local",
    )

@Puiching-Memory
Copy link
Contributor Author

image
另外,在0.3.21中,experiment_name过长似乎会导致排版错误,这里使用的是local模式

@SAKURA-CAT
Copy link
Contributor

不好意思最近有些忙,回复得晚了

@SAKURA-CAT
Copy link
Contributor

项目名称主要适用线上模式,线上支持多个项目的切换,你观察浏览器地址栏url就会发现项目名称直接影响到了url。
这样的设计主要是为了映射项目和uri地址,github也是这种方式。在github上创建项目时,如果包含“/”字符会直接替换为短横线“-”,至于swanlab创建项目,由于是sdk命令行创建的,直接替换会造成一些困惑,所以还是打算用报错的方式。

@SAKURA-CAT
Copy link
Contributor

另外,在0.3.21中,experiment_name过长似乎会导致排版错误,这里使用的是local模式

感谢反馈,这块我们会进行修复,说实话,本地版本的代码有些老了,我们也正在考虑招人维护

@SAKURA-CAT
Copy link
Contributor

这块我们会进行修复

@Feudalman @SIMON-TANG-Liu

@SAKURA-CAT
Copy link
Contributor

SAKURA-CAT commented Oct 16, 2024

experiment_name似乎没有这种限制,代码正常工作,我比较困惑project和experiment_name参数之间的区别

如上所示,因为我们支持在实验运行中修改实验名称,所以在地址uri中没有包含实验名称,所以不会有类似“/”的限制。

不过您说的确实有道理,因为在local模式下其实本地版本并没有云端项目名称映射的问题,所以按道理不应该报错

不过就目前而言,建议您不要在项目名称添加“/”或""字符,这与系统的路径分隔符有冲突

@SAKURA-CAT
Copy link
Contributor

此问题已转移至 SwanHubX/SwanLab-Dashboard#71

@SAKURA-CAT SAKURA-CAT closed this as not planned Won't fix, can't repro, duplicate, stale Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 🙋 help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants