STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
backend.descriptions Namespace Reference

Functions

str _now ()
str normalise (str text)
dict[str, dict] _read ()
None _write (dict[str, dict] runs)
dict[str, str] all_texts ()
str get (str run_id)
dict set_text (str run_id, str text)

Variables

int MAX_LEN = 120
int _SCHEMA = 1
 _lock = threading.Lock()

Detailed Description

One shared, editable line of context per run: "hotfire 3, ox lead 200 ms".

A run is identified by a timestamp, which says when it happened and nothing about what
it was. This is the one piece of viewer state that is *written* rather than derived, and
it is deliberately unowned — anybody can set or change any run's line, and everybody sees
the same text. There is no login on this tool, so there is nobody to attribute it to.

Stored beside the run dirs (`<ELODIN_DIR>/run_descriptions.json`), for the same reason
the config snapshot is: that is where the runs themselves live, it is backed up with
them, and it survives the parquet cache being wiped — which docker-compose explicitly
calls safe to do. It must never live under WEBVIEWER_CACHE_DIR for that reason.

Last write wins. Two people editing one line in the same second is not a problem worth a
revision protocol here; the write itself is atomic, so a torn file is not possible.

Function Documentation

◆ _now()

str backend.descriptions._now ( )
protected

Definition at line 37 of file descriptions.py.

Referenced by set_text().

◆ _read()

dict[str, dict] backend.descriptions._read ( )
protected
The whole store. Unreadable or malformed → empty: a description is a convenience,
and losing one must never stop the viewer listing runs.

Definition at line 48 of file descriptions.py.

Referenced by all_texts(), and set_text().

◆ _write()

None backend.descriptions._write ( dict[str, dict] runs)
protected
Replace the store atomically, so a crash or a concurrent reader never sees a
half-written file. Same directory as the target — os.replace is only atomic within
one filesystem.

Definition at line 60 of file descriptions.py.

Referenced by set_text().

◆ all_texts()

dict[str, str] backend.descriptions.all_texts ( )
run_id → description, for decorating a run listing. One file read.

Definition at line 81 of file descriptions.py.

References _read().

Referenced by get().

◆ get()

str backend.descriptions.get ( str run_id)

Definition at line 90 of file descriptions.py.

References all_texts(), and get().

Referenced by get().

◆ normalise()

str backend.descriptions.normalise ( str text)
Force the input to the one line it claims to be: newlines and runs of whitespace
collapse to single spaces, then truncate. A pasted paragraph becomes a sentence
rather than being rejected.

Definition at line 41 of file descriptions.py.

Referenced by set_text().

◆ set_text()

dict backend.descriptions.set_text ( str run_id,
str text )
Set (or, with empty text, clear) one run's description. Returns the stored entry.

Also drops entries for runs that no longer exist — a discarded session takes its DB
dir and its config snapshot with it (session-manager.ts) but knows nothing about this
file, so orphans would otherwise pile up forever.

Definition at line 94 of file descriptions.py.

References _now(), _read(), _write(), and normalise().

Variable Documentation

◆ _lock

backend.descriptions._lock = threading.Lock()
protected

Definition at line 34 of file descriptions.py.

◆ _SCHEMA

int backend.descriptions._SCHEMA = 1
protected

Definition at line 31 of file descriptions.py.

◆ MAX_LEN

int backend.descriptions.MAX_LEN = 120

Definition at line 29 of file descriptions.py.