Make documentation standalone and generalize examples
This commit is contained in:
@@ -38,7 +38,7 @@ router = APIRouter(prefix="/cloud", tags=["cloud"])
|
||||
|
||||
|
||||
class EnrollBody(BaseModel):
|
||||
#: Where the portal's API lives, e.g. https://hub.fluksio.com
|
||||
#: Where the portal's API lives, e.g. https://portal.example.com
|
||||
portal_url: str = Field(min_length=1, max_length=255)
|
||||
claim_code: str = Field(min_length=1, max_length=32)
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ def socket_token(headers: Mapping[str, str], ticket: str = "", token: str = "")
|
||||
|
||||
`token` is the query parameter clients sent before the other two existed.
|
||||
It is read for one more release so an engine can be upgraded before its
|
||||
workers; remove it after that (see NOTEPAD).
|
||||
workers. New clients should use the Authorization header.
|
||||
"""
|
||||
header = headers.get("authorization") or ""
|
||||
if header.lower().startswith("bearer "):
|
||||
|
||||
@@ -205,11 +205,8 @@ class ExecutionService:
|
||||
def _sleep_until_due(self) -> bool:
|
||||
"""Wait for the soonest deadline, the housekeeping cap, or a new one.
|
||||
|
||||
A fixed poll here made every delayed item late by 0-1000ms whatever the
|
||||
load — on a rollershutter driven for a measured 26 seconds, 2-4% of its
|
||||
travel every time, accumulating in the position its node believes it is
|
||||
at. Sleeping to the deadline instead leaves a wake-up and a promotion,
|
||||
which is milliseconds.
|
||||
Sleeping until the deadline avoids adding a fixed polling delay to
|
||||
timed work. New deadlines wake the timer so earlier work is not missed.
|
||||
"""
|
||||
self._timer_wake.clear()
|
||||
try:
|
||||
|
||||
@@ -150,7 +150,7 @@ class WebSocketNode(Node):
|
||||
"A WebSocket node needs either inputs (to send) or outputs (to listen)"
|
||||
)
|
||||
# ponytail: one direction per node, as mqtt and http. Inputs and
|
||||
# outputs over one socket is the NOTEPAD follow-up.
|
||||
# outputs over one socket is not supported yet.
|
||||
self.mode = (
|
||||
WebSocketNode.Mode.SENDER if requires else WebSocketNode.Mode.LISTENER
|
||||
)
|
||||
|
||||
@@ -79,17 +79,12 @@ _NUMBERS = {w: n for n, w in enumerate(_ONES)} | {
|
||||
|
||||
|
||||
def _plain(command: str) -> str:
|
||||
"""The command as the model was trained on it: lower case, no sentence marks.
|
||||
|
||||
A transcript's "Turn on the kitchen light." reads less sure than the same
|
||||
words plain, 0.80 against 0.99 with every area shown.
|
||||
"""
|
||||
"""Normalize case and sentence punctuation to match the training format."""
|
||||
return re.sub(r"[.,!?;:]+(?=\s|$)", "", command).strip().lower()
|
||||
|
||||
|
||||
def _aliased(prompt: str, aliases: dict[str, str]) -> str:
|
||||
"""``prompt`` with the house's words in wren's, whole words in any case:
|
||||
"the traverse" as "the living room light", "page too" as "patio"."""
|
||||
"""Replace whole-word aliases with target names, ignoring case."""
|
||||
if not aliases:
|
||||
return prompt
|
||||
words = {k.lower(): v for k, v in aliases.items()}
|
||||
@@ -103,8 +98,7 @@ def _aliased(prompt: str, aliases: dict[str, str]) -> str:
|
||||
|
||||
|
||||
def _digits(command: str) -> str:
|
||||
"""Number words as digits: "in five minutes" kept its delay only as "in 5
|
||||
minutes", and "twenty two degrees" read as 21."""
|
||||
"""Convert number words to digits, as expected by the model."""
|
||||
tens, ones = "|".join(_TENS), "|".join(_ONES[1:10])
|
||||
command = re.sub(
|
||||
rf"\b({tens})[ -]({ones})\b",
|
||||
@@ -266,8 +260,8 @@ class WrenNode(Node):
|
||||
)
|
||||
aliases: dict[str, str] = Field(
|
||||
default_factory=dict,
|
||||
description="Your own words, and words heard wrong, in the model's: "
|
||||
'{"traverse": "living room light", "page too": "patio"}.',
|
||||
description="Map your own names to the model's target names: "
|
||||
'{"desk lamp": "office light"}.',
|
||||
)
|
||||
examples: list[dict[str, Any]] = Field(
|
||||
default_factory=list,
|
||||
|
||||
@@ -6,11 +6,8 @@ listens any more. The supervisor restarts those tasks with a growing delay and
|
||||
stands a flow down when one keeps failing, because a flow crash-looping every
|
||||
second is worse than a flow that is visibly stopped.
|
||||
|
||||
Standing down is a rest, not a verdict. It used to be the end of the task: the
|
||||
flow stayed dead until somebody published it or the engine restarted. On a
|
||||
house that runs unattended that turns a broker rebooting at four in the morning
|
||||
into a hole in the record until someone notices — so the rest expires, the
|
||||
budget comes back, and the task tries again on a much longer clock.
|
||||
Quarantined tasks retry after a longer cooldown with a fresh restart budget.
|
||||
This lets unattended flows recover from extended connection failures.
|
||||
|
||||
Deliberately a plain task registry rather than a `TaskGroup`: a group cancels
|
||||
its siblings when one member fails, which is the opposite of what supervision
|
||||
@@ -38,8 +35,7 @@ BACKOFF = settings.FLOW_RESTART_BACKOFF
|
||||
# Per task rather than per flow: a flow whose subscriber and its keepalive
|
||||
# publisher both go down with the same broker spends one shared budget twice as
|
||||
# fast as it was sized for, and gives up before the backoff above has reached
|
||||
# its longest step. That is what took the house's inverter readings out for
|
||||
# nearly five hours — six crashes across two tasks inside 41 seconds.
|
||||
# its longest step.
|
||||
FAILURE_BUDGET = 5
|
||||
FAILURE_WINDOW = 300.0
|
||||
# How long a task sits out before its budget is handed back. Minutes rather
|
||||
|
||||
@@ -21,9 +21,8 @@ from urllib.parse import urlsplit, urlunsplit
|
||||
#: the engine's own supervision backs off with.
|
||||
BACKOFF = (1.0, 5.0, 30.0, 60.0)
|
||||
|
||||
#: How long a read waits before looking at `stop`. The socket is otherwise
|
||||
#: silent for as long as the house is, and a dashboard that is closing should
|
||||
#: not wait for the next event to notice.
|
||||
#: How long a read waits before checking `stop`, so an idle connection does
|
||||
#: not delay closing the dashboard.
|
||||
POLL_S = 1.0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user