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.
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
"""Fixtures for end-to-end tomo-queue tests against a running flOMNI sim.
|
|
|
|
Deliberately does NOT use the shipped ``bec_client_lib_with_demo_config`` /
|
|
``bec_ipython_client_with_demo_config`` fixtures from pytest_bec_e2e: both
|
|
call ``bec.config.load_demo_config(force=True)``, which against a running sim
|
|
session overwrites the loaded simulated-flOMNI device config with BEC's demo
|
|
devices. See TOMO_QUEUE_TESTING.md section 3.
|
|
"""
|
|
|
|
import pytest
|
|
from _bootstrap import build_flomni, shutdown
|
|
|
|
_QUEUE_VAR = "tomo_queue"
|
|
_PROGRESS_VAR = "tomo_progress"
|
|
|
|
|
|
@pytest.fixture
|
|
def flomni_sim(bec_redis_fixture, bec_services_config_file_path, bec_servers):
|
|
"""A live ``Flomni`` instance attached to the already-running sim session.
|
|
|
|
See ``_bootstrap.build_flomni()`` for what connecting/constructing this
|
|
involves and why. The ``tomo_queue`` / ``tomo_progress`` global vars are
|
|
snapshotted before the test and restored after, so tests don't leak
|
|
queue/progress state into each other or into a real operator's session
|
|
on the same sim.
|
|
"""
|
|
bec, flomni = build_flomni(bec_services_config_file_path)
|
|
|
|
queue_snapshot = bec.get_global_var(_QUEUE_VAR)
|
|
progress_snapshot = bec.get_global_var(_PROGRESS_VAR)
|
|
|
|
try:
|
|
yield flomni
|
|
finally:
|
|
bec.set_global_var(_QUEUE_VAR, queue_snapshot)
|
|
bec.set_global_var(_PROGRESS_VAR, progress_snapshot)
|
|
shutdown(bec)
|