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

[REQUEST] 将web host、api host相关环境变量集成进 swanlab.login #792

Open
SAKURA-CAT opened this issue Jan 18, 2025 · 4 comments
Assignees
Labels
💪 enhancement New feature or request 🌍 prepare for the future Feature prepare for the future

Comments

@SAKURA-CAT
Copy link
Contributor

🤩 Features description [Please make everyone to understand it]

如题,我打算将设置web host、api host的能力整合进swanlab.login

👍 What problem does this feature solve

我们知道在sdk中SWANLAB_WEB_HOSTSWANLAB_API_HOST两个环境变量分别用于表示云端前端的url和后端url。目前,用户如果需要修改此环境变量必须使用如下方式:

os.environ["SWANLAB_API_HOST"] = "https://xxx"
os.environ["SWANLAB_WEB_HOST"] = "https://xxx"

这通常过于繁琐,也不符合人机交互直觉,因此需要拓展这部分功能——此外,这也为后面私有化部署做准备。

👾 What does the proposed API look like

swanlab.login(api_key="", host="xxx")

设置host参数可以同时设置web hostapi host,我们约定api hostweb host/api子路由下的内容。为了保证函数简洁性,不支持分别设置web hostapi host(如果有这需求,还是用os.environ进行设置)

@SAKURA-CAT SAKURA-CAT added 🌍 prepare for the future Feature prepare for the future 💪 enhancement New feature or request labels Jan 18, 2025
@SAKURA-CAT SAKURA-CAT self-assigned this Jan 18, 2025
@Zeyi-Lin
Copy link
Member

关于CLI的交互用法:

swanlab login --host=https://xxx

@SAKURA-CAT
Copy link
Contributor Author

Image

@SAKURA-CAT
Copy link
Contributor Author

Image

简单来讲:

  1. 如果用户执行了swanlab.login,则此函数完成对host等环境变量的初始化,并生成http对象,在swanlab.init中跳过这段逻辑
  2. 如果用户未执行swanlab.login,则swanlab.init同时担任初始化host等环境变量,并生成http对象的任务,在后端校验的过程中直接报错。

如果未执行swanlab.login,且在swanlab.init中发现用户并没有存储api key,则会进行 #632 的逻辑。这里有个问题是目前并不允许选择host。

@SAKURA-CAT
Copy link
Contributor Author

这里有个问题是目前并不允许选择host

目前先不管此问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 enhancement New feature or request 🌍 prepare for the future Feature prepare for the future
Projects
None yet
Development

No branches or pull requests

2 participants