Skip to content

Commit

Permalink
fix: temporary domain (#756)
Browse files Browse the repository at this point in the history
add temporary domain
  • Loading branch information
swpfY authored Dec 23, 2024
1 parent 6b9302d commit 7121343
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions swanlab/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@

import swankit.env as E
from swankit.env import SwanLabSharedEnv
import requests


DOMAIN = 'swanlab.cn'
DOMAIN1 = 'swanlab.115.zone' # temporary domain

# domain state detection
try:
response = requests.get(f'https://{DOMAIN}/api', timeout=3)
if response.status_code != 200:
DOMAIN = DOMAIN1
except Exception:
DOMAIN = DOMAIN1


# ---------------------------------- 环境变量枚举类 ----------------------------------
Expand Down Expand Up @@ -73,9 +86,13 @@ def set_default(cls):
"""
设置默认的环境变量值
"""
api_host = f'https://api.{DOMAIN}/api'
if DOMAIN == DOMAIN1:
api_host = f'https://{DOMAIN}/api'

envs = {
cls.WEB_HOST.value: "https://swanlab.cn",
cls.API_HOST.value: "https://api.swanlab.cn/api",
cls.WEB_HOST.value: f"https://{DOMAIN}",
cls.API_HOST.value: api_host,
cls.RUNTIME.value: "user",
}
for k, v in envs.items():
Expand Down

0 comments on commit 7121343

Please sign in to comment.