Spaces:
Running
Running
chore(sync): mirror backend .py + Dockerfile to Space (hf-sync-backend)
Browse filesAutomated backend sync from szl-holdings/a11oy main via hf-sync-backend.
Updated (differed from the Space): szl_energy_operator.py
Deleted (gone from the repo + Dockerfile COPY set): (none)
Keeps the Space-built backend (serve.py + the Dockerfile-COPY'd .py
modules) identical to GitHub main so the Space never rebuilds from a
stale backend, new endpoints don't 404 there, and orphaned modules
removed from the repo don't linger in the Space tree.
- szl_energy_operator.py +15 -3
szl_energy_operator.py
CHANGED
|
@@ -121,6 +121,7 @@ class NodeCfg:
|
|
| 121 |
gen_model: str # small token-generation model tag
|
| 122 |
embed_model: str # embeddings model tag
|
| 123 |
exporter_node: str # label this node reports in the joule-meter engines list
|
|
|
|
| 124 |
|
| 125 |
|
| 126 |
def _default_nodes() -> list[NodeCfg]:
|
|
@@ -150,6 +151,10 @@ def _default_nodes() -> list[NodeCfg]:
|
|
| 150 |
gen_model=os.environ.get("A11OY_CHASKI_GEN_MODEL", "qwen2.5:32b"),
|
| 151 |
embed_model=os.environ.get("A11OY_CHASKI_EMBED_MODEL", "mistral"),
|
| 152 |
exporter_node=os.environ.get("A11OY_CHASKI_GPU_LABEL", "chaski"),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
),
|
| 154 |
]
|
| 155 |
|
|
@@ -497,8 +502,11 @@ class OperatorDaemon:
|
|
| 497 |
break
|
| 498 |
reachable = _http_reachable(node.base_url)
|
| 499 |
if not reachable:
|
|
|
|
|
|
|
|
|
|
| 500 |
with self._lock:
|
| 501 |
-
self._node_status[node.name] = "DEGRADED"
|
| 502 |
continue
|
| 503 |
any_reachable = True
|
| 504 |
with self._lock:
|
|
@@ -646,6 +654,7 @@ class OperatorDaemon:
|
|
| 646 |
computing = [n for n, s in self._node_status.items()
|
| 647 |
if s in ("computing", "computing (STUB)")]
|
| 648 |
degraded = [n for n, s in self._node_status.items() if s == "DEGRADED"]
|
|
|
|
| 649 |
st = self._state
|
| 650 |
return {
|
| 651 |
"service": "energy-operator",
|
|
@@ -662,6 +671,7 @@ class OperatorDaemon:
|
|
| 662 |
"sample_jobs": st.sample_jobs,
|
| 663 |
"nodes_computing": computing,
|
| 664 |
"nodes_degraded": degraded,
|
|
|
|
| 665 |
"node_status": dict(self._node_status),
|
| 666 |
"by_node": {k: dict(v) for k, v in st.by_node.items()},
|
| 667 |
"uptime_s": round(uptime, 3),
|
|
@@ -675,8 +685,10 @@ class OperatorDaemon:
|
|
| 675 |
"honesty": (
|
| 676 |
"joules_measured_total is the SUM of per-job MEASURED NVML deltas "
|
| 677 |
"(fresh <30s) ONLY — the billable figure. SAMPLE energy (stale meter "
|
| 678 |
-
"or stub mode) is tracked separately and NEVER billable.
|
| 679 |
-
"
|
|
|
|
|
|
|
| 680 |
"reachable from this process; stub energy is SAMPLE by construction."
|
| 681 |
),
|
| 682 |
"computed_at": _now_iso(),
|
|
|
|
| 121 |
gen_model: str # small token-generation model tag
|
| 122 |
embed_model: str # embeddings model tag
|
| 123 |
exporter_node: str # label this node reports in the joule-meter engines list
|
| 124 |
+
standby: bool = False # configured but intentionally not started: unreachable => "standby", not DEGRADED
|
| 125 |
|
| 126 |
|
| 127 |
def _default_nodes() -> list[NodeCfg]:
|
|
|
|
| 151 |
gen_model=os.environ.get("A11OY_CHASKI_GEN_MODEL", "qwen2.5:32b"),
|
| 152 |
embed_model=os.environ.get("A11OY_CHASKI_EMBED_MODEL", "mistral"),
|
| 153 |
exporter_node=os.environ.get("A11OY_CHASKI_GPU_LABEL", "chaski"),
|
| 154 |
+
# chaski is founder-started (replit-chaski Repl): standby until the founder
|
| 155 |
+
# sets A11OY_CHASKI_STANDBY=0. Unreachable-while-standby reads "standby"
|
| 156 |
+
# (intentionally not started), NOT DEGRADED (supposed-to-be-up but failed).
|
| 157 |
+
standby=os.environ.get("A11OY_CHASKI_STANDBY", "1") not in ("0", "false", "False", ""),
|
| 158 |
),
|
| 159 |
]
|
| 160 |
|
|
|
|
| 502 |
break
|
| 503 |
reachable = _http_reachable(node.base_url)
|
| 504 |
if not reachable:
|
| 505 |
+
# Honest distinction: a standby node (configured but intentionally not
|
| 506 |
+
# started) reads "standby"; a node expected up but failed is DEGRADED.
|
| 507 |
+
# Neither produces a job/joule — unreachable is never faked as computing.
|
| 508 |
with self._lock:
|
| 509 |
+
self._node_status[node.name] = "standby" if node.standby else "DEGRADED"
|
| 510 |
continue
|
| 511 |
any_reachable = True
|
| 512 |
with self._lock:
|
|
|
|
| 654 |
computing = [n for n, s in self._node_status.items()
|
| 655 |
if s in ("computing", "computing (STUB)")]
|
| 656 |
degraded = [n for n, s in self._node_status.items() if s == "DEGRADED"]
|
| 657 |
+
standby = [n for n, s in self._node_status.items() if s == "standby"]
|
| 658 |
st = self._state
|
| 659 |
return {
|
| 660 |
"service": "energy-operator",
|
|
|
|
| 671 |
"sample_jobs": st.sample_jobs,
|
| 672 |
"nodes_computing": computing,
|
| 673 |
"nodes_degraded": degraded,
|
| 674 |
+
"nodes_standby": standby,
|
| 675 |
"node_status": dict(self._node_status),
|
| 676 |
"by_node": {k: dict(v) for k, v in st.by_node.items()},
|
| 677 |
"uptime_s": round(uptime, 3),
|
|
|
|
| 685 |
"honesty": (
|
| 686 |
"joules_measured_total is the SUM of per-job MEASURED NVML deltas "
|
| 687 |
"(fresh <30s) ONLY — the billable figure. SAMPLE energy (stale meter "
|
| 688 |
+
"or stub mode) is tracked separately and NEVER billable. A node "
|
| 689 |
+
"configured as standby (intentionally not started) reads 'standby', "
|
| 690 |
+
"not DEGRADED; a node that fails when expected up is DEGRADED; neither "
|
| 691 |
+
"is ever faked as computing. STUB MODE means no GPU node was "
|
| 692 |
"reachable from this process; stub energy is SAMPLE by construction."
|
| 693 |
),
|
| 694 |
"computed_at": _now_iso(),
|