Files
jobboard/pipeline/web/__init__.py
T
WolfandClaude Fable 5.1 3a240e51df Pull pipeline/ from boilerplate a80ad8a: cadence picker, queue badge, label refresh
The schedule cadence is a picker, the add row is behind a button and off
here, a running-jobs chip with Kill and Stop run sits in every header, and
a declared schedule's label is refreshed at startup.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-28 16:22:46 +02:00

62 lines
3.0 KiB
Python

"""The parts of a web app that are the pipeline's, not the application's.
from pipeline.web import connect
queue = connect(app, Jobs("app.db"), config, store)
An app of this shape has a queue, and therefore has the same endpoints and the
same socket over it: list, kinds, enqueue, cancel, and `/ws/jobs`. None of that
knows what the work is *for*, so it is here rather than copied into each app —
and a socket's reconnect and fan-out behaviour is exactly the sort of thing a
second copy gets subtly wrong.
app.py `connect`: all of the below wired into a FastAPI app, and
the worker started and stopped with it, in one call
broadcaster.py one message out to every connected socket
jobs.py the queue over HTTP, the socket that reports on it, and
the one route that serves the element below
schedules.py schedules over HTTP: list, add, edit, delete, run now,
with the readable refusals a thing that runs while nobody
is watching has to have
deps.py how those routes reach the queue and the bus
schemas.py the request bodies they take
static/jobs.js `<desk-jobs>`: the queue on screen. Two lines in a
template and a new app has a job list with progress and a
Kill button, before it has written any UI of its own.
`<desk-queue>` in the same file: the queue as a chip for
a top bar, the list in a popover
static/schedules.js
`<desk-schedules>`: the same two lines for the schedule
table, themed from the same custom properties
<script type="module" src="/_jobs/jobs.js"></script>
<desk-jobs></desk-jobs>
The element is the one thing here with an opinion about how something looks,
and it is deliberate: this is the part nobody wants to write twice. It keeps
to a shadow root and themes from custom properties, so an app overrides it
without forking it, and it says nothing about *failures* — it raises an event
and leaves the wording to the app, which is the same split `notices.py` makes
on the server. newsdesk does not use it: it had a richer strip of its own
before this existed, which is what an app is expected to grow into.
What an app still owns: its own factory, its own store and config
dependencies, its own routers, its own page.
"""
from __future__ import annotations
from pipeline.web.app import connect
from pipeline.web.broadcaster import Broadcaster
from pipeline.web.deps import BroadcasterDep, QueueDep, get_broadcaster, get_queue
from pipeline.web.jobs import STATIC, router as jobs_router
from pipeline.web.schedules import router as schedules_router, served
from pipeline.web.schemas import (
EnqueueBody, JobKind, NewSchedule, ScheduleEdit, ScheduleRow,
)
__all__ = ["STATIC", "Broadcaster", "BroadcasterDep", "EnqueueBody",
"JobKind", "NewSchedule", "QueueDep", "ScheduleEdit", "ScheduleRow",
"connect", "get_broadcaster", "get_queue", "jobs_router",
"schedules_router", "served",
]