Spaces:
Running
Running
Deploy GitHub main a3d79b5cbaf5
Browse files- cloud/web.py +6 -3
- deployment.json +1 -1
- scripts/push_results_to_hf.py +6 -0
cloud/web.py
CHANGED
|
@@ -20,6 +20,9 @@ def health_report(root: Path = ROOT):
|
|
| 20 |
supervisor = read(".cloud-state/supervisor.json")
|
| 21 |
checkpoint = read(".cloud-state/checkpoint.json")
|
| 22 |
status = read("space/results/online_status.json")
|
|
|
|
|
|
|
|
|
|
| 23 |
stamp = checkpoint.get("checkpointed_at")
|
| 24 |
def age_seconds(stamp):
|
| 25 |
try:
|
|
@@ -27,13 +30,13 @@ def health_report(root: Path = ROOT):
|
|
| 27 |
except (ValueError, TypeError):
|
| 28 |
return None
|
| 29 |
age = age_seconds(stamp)
|
| 30 |
-
push_age = age_seconds(
|
| 31 |
failures = status.get("failed_forecasts", [])
|
| 32 |
model_failures = sum(item.get("model") != "*" for item in failures)
|
| 33 |
healthy = bool(supervisor.get("worker_running") and supervisor.get("evaluator_enabled")
|
| 34 |
and 0 <= time.time() - supervisor.get("updated_at", 0) < 90
|
| 35 |
and age is not None and 0 <= age < 3600
|
| 36 |
-
and status.get("aggregate_status") == "ok" and
|
| 37 |
and push_age is not None and 0 <= push_age < 3600 and model_failures == 0)
|
| 38 |
return {"ok": healthy, "source_revision": supervisor.get("source_revision"),
|
| 39 |
"evaluator_enabled": supervisor.get("evaluator_enabled", False),
|
|
@@ -44,7 +47,7 @@ def health_report(root: Path = ROOT):
|
|
| 44 |
"model_failure_count": model_failures,
|
| 45 |
"unavailable_source_count": len(failures) - model_failures,
|
| 46 |
"pending_tasks": status.get("pending_tasks"),
|
| 47 |
-
"push_status":
|
| 48 |
|
| 49 |
|
| 50 |
def main():
|
|
|
|
| 20 |
supervisor = read(".cloud-state/supervisor.json")
|
| 21 |
checkpoint = read(".cloud-state/checkpoint.json")
|
| 22 |
status = read("space/results/online_status.json")
|
| 23 |
+
publication = read("space/results/publication_status.json") or status
|
| 24 |
+
if status.get("push_status") == "failed":
|
| 25 |
+
publication = status
|
| 26 |
stamp = checkpoint.get("checkpointed_at")
|
| 27 |
def age_seconds(stamp):
|
| 28 |
try:
|
|
|
|
| 30 |
except (ValueError, TypeError):
|
| 31 |
return None
|
| 32 |
age = age_seconds(stamp)
|
| 33 |
+
push_age = age_seconds(publication.get("pushed_at"))
|
| 34 |
failures = status.get("failed_forecasts", [])
|
| 35 |
model_failures = sum(item.get("model") != "*" for item in failures)
|
| 36 |
healthy = bool(supervisor.get("worker_running") and supervisor.get("evaluator_enabled")
|
| 37 |
and 0 <= time.time() - supervisor.get("updated_at", 0) < 90
|
| 38 |
and age is not None and 0 <= age < 3600
|
| 39 |
+
and status.get("aggregate_status") == "ok" and publication.get("push_status") == "ok"
|
| 40 |
and push_age is not None and 0 <= push_age < 3600 and model_failures == 0)
|
| 41 |
return {"ok": healthy, "source_revision": supervisor.get("source_revision"),
|
| 42 |
"evaluator_enabled": supervisor.get("evaluator_enabled", False),
|
|
|
|
| 47 |
"model_failure_count": model_failures,
|
| 48 |
"unavailable_source_count": len(failures) - model_failures,
|
| 49 |
"pending_tasks": status.get("pending_tasks"),
|
| 50 |
+
"push_status": publication.get("push_status"), "pushed_at": publication.get("pushed_at")}
|
| 51 |
|
| 52 |
|
| 53 |
def main():
|
deployment.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
"source_repository": "https://github.com/Thinkcat-Lab/LiveHouse-TS",
|
| 3 |
"source_branch": "main",
|
| 4 |
-
"source_revision": "
|
| 5 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"source_repository": "https://github.com/Thinkcat-Lab/LiveHouse-TS",
|
| 3 |
"source_branch": "main",
|
| 4 |
+
"source_revision": "a3d79b5cbaf5ece22b8ad6dc4338b2a2a0515f81"
|
| 5 |
}
|
scripts/push_results_to_hf.py
CHANGED
|
@@ -148,6 +148,12 @@ def update_push_status(results: Path, *, ok: bool, detail: str = "") -> None:
|
|
| 148 |
if detail:
|
| 149 |
payload["push_detail"] = detail
|
| 150 |
status_path.write_text(json.dumps(payload, indent=4) + "\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
|
| 152 |
|
| 153 |
def restart_space(token: str, repo_id: str) -> None:
|
|
|
|
| 148 |
if detail:
|
| 149 |
payload["push_detail"] = detail
|
| 150 |
status_path.write_text(json.dumps(payload, indent=4) + "\n")
|
| 151 |
+
# Evaluation rewrites online_status while rapid cycles wait for publication.
|
| 152 |
+
# Keep the last actual publish attempt independently for the watchdog.
|
| 153 |
+
receipt = results / "publication_status.json"
|
| 154 |
+
temporary = receipt.with_suffix(".tmp")
|
| 155 |
+
temporary.write_text(json.dumps({key: payload[key] for key in ("push_status", "pushed_at")}))
|
| 156 |
+
temporary.replace(receipt)
|
| 157 |
|
| 158 |
|
| 159 |
def restart_space(token: str, repo_id: str) -> None:
|