Experiment manager
The core experiment execution engine: takes tasks from the experiment queue and schedules them by measurement/sequence/run hierarchy.
Overview
quatm/GUI/experiment/experiment_manager.py provides the experiment manager (ExperimentManager): the engine that takes tasks from the experiment queue (ExperimentQueue) and executes them. Its queue polling runs in a worker thread, and tasks are scheduled in the hierarchy measurement → repetition → sequence/scan → run.
Execution flow
queue_fn (worker thread polls the queue continuously)
└─→ run (task wrapper: cleanup is guaranteed however the task ends)
├─→ start_measurement (measurement start hook)
├─→ start_sequence (sequence/scan start hook)
│ └─→ … several run calls with varying parameters …
├─→ end_sequence (sequence end hook)
└─→ end_measurement (measurement end hook; clears the task table)
Key methods
| Method | Description |
|---|---|
queue_fn | Continuously polls the queue for task dictionaries: selects tasks by priority, task number and scheduled time |
run | Task run wrapper: finalises cleanly whether the task ends as Done/Terminated/Failed or is deleted |
pause | Pauses the current experiment; calling it again resumes it |
terminate_experiment | Graceful termination: lets the current run finish naturally before stopping |
start_measurement, etc. | Invokes the experiment’s start/end hooks for each stage |
set_dict | Writes a single parameter to an attribute of the experiment instance |
set_run_nr / set_rep_nr | Synchronises the run/repetition index into the task dictionary and refreshes the table |
due_check | Determines whether a task has reached its scheduled execution time |
start_queue / shutdown | Starts / stops the resident queue worker |
update_table | Notifies the GUI to refresh the displayed task table |
Usage
from quatm.GUI.experiment.experiment_manager import ExperimentManager
manager = ExperimentManager(browser) # browser supplies the queue and the UI
manager.start_queue() # start the resident queue worker
Tasks execute in a dedicated worker thread and do not block the GUI; when the browser closes it calls shutdown to stop the queue worker so that the process exits cleanly.