li2895 commited on
Commit
4efb70e
·
1 Parent(s): 839deab

fix: 空账号池允许启动(HF 首启无账号,面板上传后热加载)+ README 部署说明

Browse files
Files changed (2) hide show
  1. README.md +4 -3
  2. app/account.py +6 -4
README.md CHANGED
@@ -20,17 +20,18 @@ pinned: false
20
  - **SDK**: **Docker**(重要)
21
  - 点 **Create Space**
22
 
23
- 2. 本地把这个目录内容推到 Space:
24
  ```bash
25
  cd hf_space
26
  # 在 Space 页面 Settings → Repo → 复制 git 地址(形如 https://huggingface.co/spaces/<你>/anuma2api)
27
  git init
28
- git add Dockerfile init_and_run.sh README.md
29
  git commit -m "anuma2api HF space"
30
  git remote add origin https://huggingface.co/spaces/<你>/anuma2api
31
  git push -u origin main
32
  ```
33
- (Space 上 Docker SDK 会自己构建并运行 `Dockerfile`。)
 
34
 
35
  3. **启用持久存储**(关键):Space 页面 **Settings → Persistent Storage → New Volume**
36
  - 挂载点填 **`/data`**,存储选默认(免费档 50GB)。
 
20
  - **SDK**: **Docker**(重要)
21
  - 点 **Create Space**
22
 
23
+ 2. 本地把这个目录内容推到 Space(目录已自包含 App 代码,直接全量推):
24
  ```bash
25
  cd hf_space
26
  # 在 Space 页面 Settings → Repo → 复制 git 地址(形如 https://huggingface.co/spaces/<你>/anuma2api)
27
  git init
28
+ git add .
29
  git commit -m "anuma2api HF space"
30
  git remote add origin https://huggingface.co/spaces/<你>/anuma2api
31
  git push -u origin main
32
  ```
33
+ (Space 上 Docker SDK 会自己构建并运行 `Dockerfile`;覆盖旧项目用 `git push -f`。)
34
+ ⚠️ 若在前一版部署过(hf_space 缺构建源),Docker 构建上下文错误可导致 `COPY pyproject.toml not found` —— 本目录已含 `app/ registrar/ scripts/ pyproject.toml` 全部构建源。
35
 
36
  3. **启用持久存储**(关键):Space 页面 **Settings → Persistent Storage → New Volume**
37
  - 挂载点填 **`/data`**,存储选默认(免费档 50GB)。
app/account.py CHANGED
@@ -104,12 +104,14 @@ class AccountPool:
104
 
105
  @classmethod
106
  def load(cls, account_dir: Path) -> AccountPool:
107
- """扫 account_dir 下的 *.json 构造账号池。目录不存在或无 json 抛 RuntimeError。"""
 
 
 
 
108
  if not account_dir.is_dir():
109
- raise RuntimeError(f"账号目录不存在: {account_dir}(请运行注册机注册账号)")
110
  files = sorted(account_dir.glob("*.json"))
111
- if not files:
112
- raise RuntimeError(f"账号目录无 *.json: {account_dir}(请运行注册机注册账号)")
113
  accounts = [Account.from_file(f) for f in files]
114
  return cls(accounts, account_dir)
115
 
 
104
 
105
  @classmethod
106
  def load(cls, account_dir: Path) -> AccountPool:
107
+ """扫 account_dir 下的 *.json 构造账号池。
108
+
109
+ 目录不存在或无 json **不抛错**(返回空池):HF 云端首启无账号,
110
+ 面板上传后热加载即用;本地误配也只是空池,请求时报“无可用账号”。
111
+ """
112
  if not account_dir.is_dir():
113
+ return cls([], account_dir)
114
  files = sorted(account_dir.glob("*.json"))
 
 
115
  accounts = [Account.from_file(f) for f in files]
116
  return cls(accounts, account_dir)
117