STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
runs.py
Go to the documentation of this file.
1"""Discover past Elodin runs (timestamped daq_[sim_]YYYYMMDD_HHMMSS dirs only)."""
2
3from __future__ import annotations
4
5from datetime import datetime
6
7from . import config, descriptions, export_cache
8
9
10def list_runs() -> list[dict]:
11 """List timestamped runs, newest first. Intentionally cheap: no per-run `du`
12 (that would stat thousands of DB subdirs across every run). Size/duration are
13 filled in by the per-run index once a run is opened."""
14 runs = []
15 if not config.ELODIN_DIR.is_dir():
16 return runs
17 # One read for the whole listing, not one per run.
18 texts = descriptions.all_texts()
19 for entry in config.ELODIN_DIR.iterdir():
20 if not entry.is_dir():
21 continue
22 m = config.RUN_RE.match(entry.name)
23 if not m:
24 continue
25 try:
26 started = datetime.strptime(m.group("date") + m.group("time"), "%Y%m%d%H%M%S")
27 except ValueError:
28 continue
29 runs.append(
30 {
31 "id": entry.name,
32 "name": entry.name,
33 "started": started.isoformat(),
34 "cached": export_cache.is_cached(entry.name),
35 # Synthetic data from a sim session. Surfaced so the UI can badge
36 # it — weeks later the directory prefix is the only thing that
37 # distinguishes it from real test-stand data.
38 "simulated": m.group("sim") is not None,
39 # Shared, operator-written one-liner saying what this run was. "" when
40 # nobody has labelled it yet. See backend/descriptions.py.
41 "description": texts.get(entry.name, ""),
42 }
43 )
44 runs.sort(key=lambda r: r["started"], reverse=True)
45 return runs
list[dict] list_runs()
Definition runs.py:10