clean up Dockerfile

This commit is contained in:
zhousha
2026-06-14 23:54:02 +08:00
parent 87d4ae1c18
commit 5b92f129d2
2 changed files with 10 additions and 35 deletions

View File

@@ -1,10 +1,6 @@
FROM modelhubxc-4pd.tencentcloudcr.com/xc_agent_platform/python:3.11-slim
ENV PYTHONUNBUFFERED=1 \
CONTEST_API_TOKEN="ef1ef82f3c9efee413d602345fbe224d" \
CONTRIBUTORS="zhoushasha" \
GPU_TYPE="Cambricon_mlu-370-x8"
ENV PYTHONUNBUFFERED=1
WORKDIR /app

39
main.py
View File

@@ -9,7 +9,6 @@ import json
import os
import signal
import threading
import traceback
from datetime import datetime
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from typing import List, Tuple
@@ -20,16 +19,15 @@ import requests
# 配置(全部从环境变量读取,不硬编码敏感信息)
# ══════════════════════════════════════════════════════════
BASE_URL = os.environ.get("BASE_URL", "https://modelhub.org.cn")
LOGIN_ENDPOINT = "/adminApi/user/login"
SUBMIT_ENDPOINT = "/adminApi/async/task/create-contest-task"
USER_ACCOUNT = os.environ["USER_ACCOUNT"] # 必填
USER_PASSWORD = os.environ["USER_PASSWORD"] # 必填
CONTEST_API_TOKEN = os.environ["CONTEST_API_TOKEN"] # 必填
STRATEGY_ID = os.environ.get("STRATEGY_ID", "") # 平台注入
CONTRIBUTORS = os.environ.get("CONTRIBUTORS", USER_ACCOUNT)
GPU_TYPE = os.environ.get("GPU_TYPE", "Cambricon_mlu-370-x8")
TASK_TYPE = os.environ.get("TASK_TYPE", "text-generation")
# 通过 curl -X POST https://modelhub.org.cn/adminApi/user/login 获取后填入
AUTH_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyQWNjb3VudCI6Inpob3VzaGFzaGEiLCJpZCI6MTQsInVzZXJSb2xlIjoibGVhZGVyYm9hcmQiLCJleHAiOjE3ODE4NTE0NzcsImlhdCI6MTc4MTI0NjY3N30.p3uvCpG50aLNifNVVXxvzmWJahbLM5K1671FVCtj8E8"
CONTEST_API_TOKEN = "ef1ef82f3c9efee413d602345fbe224d"
CONTRIBUTORS = "zhoushasha"
GPU_TYPE = "Cambricon_mlu-370-x8"
TASK_TYPE = "text-generation"
STRATEGY_ID = os.environ.get("STRATEGY_ID", "") # 平台自动注入,无需修改
HTTP_HOST = "0.0.0.0"
HTTP_PORT = 8080
@@ -110,21 +108,6 @@ def _run_http():
# ══════════════════════════════════════════════════════════
# 业务逻辑
# ══════════════════════════════════════════════════════════
def _login() -> str:
headers = {"Content-Type": "application/json"}
resp = requests.post(
BASE_URL + LOGIN_ENDPOINT,
headers=headers,
json={"userAccount": USER_ACCOUNT, "userPassword": USER_PASSWORD},
timeout=30,
)
data = resp.json()
if data.get("code") != 0:
raise RuntimeError(f"登录失败: {data.get('message')}")
print("[worker] 登录成功", flush=True)
return data["data"]["token"]
def _submit_task(token: str, model_id: str) -> Tuple[bool, str]:
headers = {
"Content-Type": "application/json",
@@ -192,12 +175,8 @@ def _run_worker():
_state["phase"] = "submitting"
successful: List[Tuple[str, str]] = []
try:
token = _login()
except Exception:
traceback.print_exc()
_state["phase"] = "error"
return
token = AUTH_TOKEN
print("[worker] 使用预设 Token跳过登录", flush=True)
for model_id in ALL_MODEL_IDS:
if _shutdown.is_set():