tdfs4ds.serve.activity¶
tdfs4ds.serve.activity
¶
What the admin app is doing in the background, for the status bar (0.3.3.15).
A process-wide, thread-safe registry of jobs: each has a key, a label, an
optional done / total count and a one-line detail. Nothing here touches the
database. GET /ui/status reads snapshot().
Two ways in:
start(key, label)returns a handle that an existing worker updates (update) and closes (finish) -- used around the streamed panel jobs (maintenance, documentation, migration, evaluation, benchmark).run_in_background(key, label, fn)runsfn(handle)in a daemon thread. A job whose key is already running is not started twice: one re-run is queued and starts when the running one ends (two builds of one store's index at once would race on the same collections).
Finished jobs stay visible for KEEP_FINISHED_S seconds so the bar can say
"done" or show the error, whole.
_CURRENT_REQUEST
module-attribute
¶
ROUTE_LABELS
module-attribute
¶
ROUTE_LABELS = {'/ui/dashboard/report': 'Overview report', '/ui/dashboard/storage': 'Storage counts', '/ui/dashboard/orphans': 'Orphan scan', '/ui/dashboard': 'Overview', '/ui/workflow': 'Health check', '/ui/efs': 'Store map', '/ui/catalog': 'Feature catalog', '/ui/lineage': 'Lineage', '/ui/doc/coverage': 'Documentation coverage', '/ui/doc': 'Documentation', '/ui/runs': 'Runs', '/ui/sizing': 'Sizing', '/ui/timemgr': 'Time managers', '/ui/framework': 'Framework cost', '/ui/params': 'Parameters', '/ui/home': 'Home', '/ui/dsbuild': 'Dataset builder', '/ui/parallel': 'Execution plan', '/ui/migration': 'Migration', '/ui/attached': 'Attached objects', '/ui/glossary': 'Glossary', '/ui/datasets': 'Datasets', '/ui/impact': 'Impact study', '/ui/qopt': 'Query optimization', '/ui/benchmark': 'Benchmark', '/ui/maintenance': 'Maintenance', '/ui/search': 'Search'}
Handle
¶
A job's handle: update while it runs, finish once.
RequestState
¶
What the middleware keeps for one request: the step text, and the activity once there is one.
request_started
¶
A /ui request that may read the database began (see requests_in_flight).
requests_in_flight
¶
How many panel requests run now. A reconnection replaces teradataml's one process-wide
connection, so the health monitor must not do it under them: a request cut that way fails
with 'NoneType' object has no attribute 'cursor' (seen with several browser sessions).
start
¶
Register a running job and return its handle. kind is "job" or "request"
(an HTTP request still running after a second, see :func:request_activity).
route_label
¶
A readable label for a /ui/... path (the path itself when unknown).
begin_request
¶
Set the current request's state (a ContextVar copied into worker threads). Returns
(state, token); pass the token to :func:end_request.
step
¶
Say what the current request is doing, e.g. activity.step("reading the lineage graph").
Shown in the status bar next to the request. A no-op outside a request (tests, notebooks, background jobs) and never raises. Safe to call from the worker threads of a request.
run_in_background
¶
Run fn(handle) in a daemon thread under key.
Returns 'started', or 'queued' when a job with the same key is
running (one re-run then follows it; queueing again replaces the waiting
one, which is the same work).
snapshot
¶
Running jobs (oldest first) then jobs finished in the last KEEP_FINISHED_S
seconds (newest first). Older finished jobs are dropped.