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

chore: add api and web host to http obj #803

Merged
merged 3 commits into from
Jan 28, 2025
Merged

chore: add api and web host to http obj #803

merged 3 commits into from
Jan 28, 2025

Conversation

SAKURA-CAT
Copy link
Contributor

@SAKURA-CAT SAKURA-CAT commented Jan 27, 2025

此拉取请求包含对swanlab模块的多项更改,主要集中在改进登录功能、URL处理和代码组织上。最重要的更改包括新增了用于处理URL的属性和方法、更新了登录机制,并进行了重构以提高代码清晰度。

主要是为 #792 的实现做准备。

登录功能改进:

  • swanlab/api/__init__.py中添加了is_login函数,通过验证HTTP对象的存在来检查用户是否已登录。

  • 更新了swanlab/api/auth/login.py中的login_requestlogin_by_key函数,使其接受并使用api_hostweb_host参数。[1] [2]

URL处理增强:

  • swanlab/api/http.py中引入了base_urlapi_hostweb_hostweb_proj_urlweb_exp_url属性,以便更好地管理URL。[1] [2]

  • 移除了硬编码的URL,并在多个文件中替换为动态URL属性,包括swanlab/data/callback_cloud.pyswanlab/data/run/metadata/cooperation/__init__.pyswanlab/data/run/public.py[1] [2] [3] [4]

代码重构:

  • 重新组织了导入并移除了多个文件中未使用的导入,以提高代码的清晰度和可维护性。[1] [2] [3]

  • 更新了swanlab/api/__init__.py中的__all__,以包含新的is_login函数。

CLI命令更新:

  • swanlab/cli/commands/auth/login.pyswanlab/cli/commands/auth/logout.py中将is_login替换为has_api_key,以更好地反映检查API密钥存在的功能。[1] [2]

额外改进:

  • 修改了 swanlab/package.py,新增了用于格式化和获取 URL 的函数,例如 fmt_web_hostget_setting_urlget_login_url[1] [2]

顺便修复了一下之前的测试(#797)在action执行时的错误问题。

close #804

chore: rename some func

chore: add a func to judge is login
@SAKURA-CAT SAKURA-CAT added the 💪 enhancement New feature or request label Jan 27, 2025
@SAKURA-CAT SAKURA-CAT requested a review from Zeyi-Lin January 27, 2025 08:29
@SAKURA-CAT SAKURA-CAT self-assigned this Jan 27, 2025
@SAKURA-CAT SAKURA-CAT marked this pull request as draft January 27, 2025 10:19
for #804

fix tuple judgement
@SAKURA-CAT SAKURA-CAT marked this pull request as ready for review January 27, 2025 11:09
@SAKURA-CAT SAKURA-CAT merged commit 1dba7b8 into main Jan 28, 2025
5 checks passed
@SAKURA-CAT SAKURA-CAT deleted the feat/login-host branch January 28, 2025 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] 有关文件修改的单元测试无法通过
2 participants