feat: host params for login cli #818
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
该拉取请求(Pull Request)对
swanlab
项目进行了重要更新,重点涉及HostFormatter
类及其在多个模块中的集成。主要改动包括HostFormatter
类的迁移与增强、登录功能的更新,以及额外的测试以确保系统的健壮性。主要变更:
重构与增强:
HostFormatter
类已从swanlab/data/sdk.py
移动到swanlab/package.py
,并增强了对host
和web_host
参数的处理能力。该类现在负责验证和格式化主机 URL,并设置相关的环境变量。[1] [2]登录功能:
swanlab/cli/commands/auth/login.py
中的login
函数,新增host
和web_host
选项,允许用户在登录时指定服务器和 Web 主机。HostFormatter
类进行主机地址的验证和格式化。代码优化:
swanlab/data/sdk.py
中冗余的HostFormatter
类定义,并更新login
函数以使用swanlab/package.py
中的新HostFormatter
类。[1] [2]测试:
test/unit/cli/test_cli_login.py
和test/unit/test_package.py
中新增测试用例,以验证HostFormatter
类的功能以及不同主机输入下的登录过程。[1] [2]test/unit/data/test_sdk.py
中针对旧HostFormatter
类的过时测试用例。导入与依赖项:
os
、sys
和re
模块的必要导入,以支持新功能。[1] [2] [3] [4]注意:在交互上,重新登录需要使用
--relogin
参数,此时host也会被重置为官方的。close #792