Type-tags queue jobs with a "kind" field (back-compat: missing kind defaults to "tomo"), and adds "command" jobs that reconfigure the beamline (currently: absolute moves on an allow-listed device, plus an optimize_idgap stub) between tomograms instead of running a scan. Command jobs are added via tomo_queue_add_command() against a curated named-action registry (_TOMO_QUEUE_ACTIONS) - not arbitrary code - so every queued action is auditable and safe to persist across a kernel restart. Validation is two-layer: schema checks at add time, and each action re-checks its own arguments against live hardware at execution time, which is the actual safety boundary. Crash-resume for a command job re-runs the whole step sequence from the top if every step is idempotent, or prompts the operator otherwise. flomni_webpage_generator.py is guarded against command jobs, which have no "params" key. See AI_docs/TOMO_QUEUE_COMMAND_JOBS_PLAN.md for the full design.
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
"""Standalone script: connect to the running sim and call
|
|
flomni.tomo_queue_execute(). Run as a real OS subprocess (its own main
|
|
thread) rather than a Python thread inside the test process: BECIPythonClient
|
|
's live-update machinery installs a SIGINT handler per scan request, which
|
|
Python only allows from a process's real main thread (see
|
|
_queue_helpers.ProgressSampler for the same constraint hit from the thread
|
|
side). Section B/C tests spawn this and SIGKILL it (or edit the queue
|
|
concurrently from a second client) to simulate a crashed kernel / a second
|
|
operator session.
|
|
|
|
Usage: python _run_queue_subprocess.py <services_config_path> [start_index]
|
|
Exit code is 0 on a clean run, 1 if tomo_queue_execute() raised.
|
|
"""
|
|
|
|
import sys
|
|
|
|
from _bootstrap import build_flomni, shutdown
|
|
|
|
|
|
def main() -> int:
|
|
services_config_path = sys.argv[1]
|
|
start_index = int(sys.argv[2]) if len(sys.argv) > 2 else 0
|
|
|
|
bec, flomni = build_flomni(services_config_path)
|
|
try:
|
|
flomni.tomo_queue_execute(start_index=start_index)
|
|
except Exception as exc: # noqa: BLE001 - reported via exit code, not re-raised
|
|
print(f"_run_queue_subprocess: tomo_queue_execute() raised: {exc}", file=sys.stderr)
|
|
return 1
|
|
finally:
|
|
shutdown(bec)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|