Stop only waiting validation tasks
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# xc_validation_strategy_vllm_stop
|
# xc_validation_strategy_vllm_stop
|
||||||
|
|
||||||
用于停止 `zhoukaile` 账号当前全部活跃验证任务的 ModelHub XC 策略服务。
|
用于停止 `zhoukaile` 账号当前状态为 `waiting` 的验证任务的 ModelHub XC 策略服务。
|
||||||
|
|
||||||
服务启动后会调用:
|
服务启动后会调用:
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ USER_PASSWORD=<zhoukaile 的登录密码>
|
|||||||
|
|
||||||
## 运行与构建
|
## 运行与构建
|
||||||
|
|
||||||
仓库根目录的 `Dockerfile` 使用平台 Python 基础镜像,暴露 `8080` 端口并以 `python main.py` 启动。策略构建时请将 `XC_TOKEN` 与 `USER_PASSWORD` 都设置为机密变量;构建成功后,策略会先分页读取当前账号的全部活跃任务,再分批停止。
|
仓库根目录的 `Dockerfile` 使用平台 Python 基础镜像,暴露 `8080` 端口并以 `python main.py` 启动。策略构建时请将 `XC_TOKEN` 与 `USER_PASSWORD` 都设置为机密变量;构建成功后,策略会先分页读取当前账号的全部任务,仅筛选状态为 `waiting` 的任务再分批停止。
|
||||||
|
|
||||||
本地验证:
|
本地验证:
|
||||||
|
|
||||||
|
|||||||
8
main.py
8
main.py
@@ -1,4 +1,4 @@
|
|||||||
"""Stop zhoukaile's active ModelHub XC validation tasks.
|
"""Stop zhoukaile's waiting ModelHub XC validation tasks.
|
||||||
|
|
||||||
The service performs the stop requests once at startup and then stays alive so
|
The service performs the stop requests once at startup and then stays alive so
|
||||||
the strategy platform can probe it through ``/health`` and inspect ``/status``.
|
the strategy platform can probe it through ``/health`` and inspect ``/status``.
|
||||||
@@ -31,7 +31,7 @@ MAX_RETRIES = int(os.environ.get("MAX_RETRIES", "3"))
|
|||||||
REQUEST_TIMEOUT = int(os.environ.get("REQUEST_TIMEOUT", "30"))
|
REQUEST_TIMEOUT = int(os.environ.get("REQUEST_TIMEOUT", "30"))
|
||||||
|
|
||||||
PAGE_SIZE = 100
|
PAGE_SIZE = 100
|
||||||
ACTIVE_STATUSES = {"waiting", "running", "pending", "processing", "queued"}
|
STOPPABLE_STATUS = "waiting"
|
||||||
|
|
||||||
_shutdown = threading.Event()
|
_shutdown = threading.Event()
|
||||||
_state: dict[str, Any] = {
|
_state: dict[str, Any] = {
|
||||||
@@ -89,7 +89,7 @@ def _login() -> str:
|
|||||||
|
|
||||||
|
|
||||||
def _current_task_ids() -> list[int]:
|
def _current_task_ids() -> list[int]:
|
||||||
"""Fetch every active task currently submitted by USER_ACCOUNT.
|
"""Fetch every waiting task currently submitted by USER_ACCOUNT.
|
||||||
|
|
||||||
This intentionally queries the user-facing task page at run time. A static
|
This intentionally queries the user-facing task page at run time. A static
|
||||||
list becomes obsolete as soon as zhoukaile submits more validation tasks.
|
list becomes obsolete as soon as zhoukaile submits more validation tasks.
|
||||||
@@ -114,7 +114,7 @@ def _current_task_ids() -> list[int]:
|
|||||||
data = result.get("data") or {}
|
data = result.get("data") or {}
|
||||||
records = data.get("records") or []
|
records = data.get("records") or []
|
||||||
for record in records:
|
for record in records:
|
||||||
if str(record.get("status", "")).lower() not in ACTIVE_STATUSES:
|
if str(record.get("status", "")).lower() != STOPPABLE_STATUS:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
task_ids.append(int(record["taskId"]))
|
task_ids.append(int(record["taskId"]))
|
||||||
|
|||||||
Reference in New Issue
Block a user