fix: replace duplicate submissions while refilling queues
This commit is contained in:
5
main.py
5
main.py
@@ -10,6 +10,7 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
from pathlib import Path
|
||||
|
||||
from modelhub_submmit_api.defaults import EMBEDDED_MODELHUB_XC_TOKEN, EMBEDDED_MODELSCOPE_TOKEN
|
||||
from modelhub_submmit_api.version import AGENT_VERSION
|
||||
|
||||
|
||||
HOST = "0.0.0.0"
|
||||
@@ -74,6 +75,7 @@ def _worker_command() -> list[str]:
|
||||
|
||||
def _config() -> dict[str, object]:
|
||||
return {
|
||||
"agent_version": AGENT_VERSION,
|
||||
"strategy_id_present": bool(os.getenv("STRATEGY_ID")),
|
||||
"modelscope_token_present": bool(os.getenv("MODELSCOPE_API_TOKEN") or os.getenv("MODELSCOPE_TOKEN") or EMBEDDED_MODELSCOPE_TOKEN),
|
||||
"modelhub_auth_present": _has_modelhub_auth(),
|
||||
@@ -92,7 +94,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if worker is not None and worker.poll() is not None:
|
||||
self._send_json({"status": "worker_exited", "config": _config()}, status=500)
|
||||
return
|
||||
self._send_json({"status": "ok"})
|
||||
self._send_json({"status": "ok", "config": _config()})
|
||||
return
|
||||
|
||||
if self.path == "/":
|
||||
@@ -135,6 +137,7 @@ def _handle_signal(signum: int, _frame: object) -> None:
|
||||
|
||||
def main() -> int:
|
||||
global config_error, worker
|
||||
print(f"modelhub-submmit-agent version={AGENT_VERSION}", flush=True)
|
||||
signal.signal(signal.SIGTERM, _handle_signal)
|
||||
signal.signal(signal.SIGINT, _handle_signal)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user