Procedure
- class caqtus.experiment_control.Procedure
Bases:
AbstractContextManager,ABCUsed to perform a procedure on the experiment.
A procedure is anything more complex than a single sequence. It can be a sequence with some analysis performed afterward, a sequence that is run multiple times with different parameters, multiple sequences that must be run cohesively, etc…
Procedures are created with
ExperimentManager.create_procedure().The procedure must be active to start running sequences. A procedure is activated by using it as a context manager. No two procedures can be active at the same time. If a previous procedure is active, entering another procedure will block until the first procedure is exited.
To run a sequence once a procedure is active, use
run_sequence().Examples:
experiment_manager: ExperimentManager = ... with experiment_manager.create_procedure("my procedure") as procedure: procedure.run_sequence(PureSequencePath("my sequence")) # do analysis, overwrite parameters, etc... procedure.run_sequence(PureSequencePath("another sequence"))
- abstractmethod is_active() bool
Indicates if the procedure is currently active and can run sequences.
- abstractmethod is_running_sequence() bool
Indicates if the procedure is currently running a sequence.
- abstractmethod exception() BaseException | None
Retrieve the exception that occurred while running the last sequence.
If a sequence is currently running, this method will block until the sequence is finished.
- abstractmethod start_sequence(
- sequence: PureSequencePath,
- global_parameters: ParameterNamespace | None = None,
- device_configurations: Mapping[DeviceName, DeviceConfiguration] | None = None,
Start running the sequence on the setup.
This method returns immediately, and the sequence is launched in a separate thread.
Exceptions that occur while running the sequence are not raised by this method, but can be retrieved with the exception method.
- Parameters:
sequence – the sequence to run.
global_parameters – The parameters to set for this sequence.
passed (If nothing is)
the (it will take the current global parameters from)
session.
device_configurations – the device configurations to use for running this
sequence.
None (If)
configurations. (this will use the session default device)
- Raises:
ProcedureNotActiveError – if the procedure is not active.
SequenceAlreadyRunningError – if a sequence is already running.
- abstractmethod interrupt_sequence() bool
Interrupt the currently running sequence.
This method only signals the sequence that it must interrupt as soon as possible, but it does not wait for the sequence to finish. To wait for the sequence to finish, use
wait_until_sequence_finished()after callinginterrupt_sequence().- Returns:
True if a sequence was running and was interrupted. False if no sequence was running.
- run_sequence(
- sequence: PureSequencePath,
- global_parameters: ParameterNamespace | None = None,
- device_configurations: Mapping[DeviceName, DeviceConfiguration] | None = None,
Run a sequence on the setup.
This method blocks until the sequence is finished.
Arguments are the same as
start_sequence().- Raises:
ProcedureNotActiveError – if the procedure is not active.
SequenceAlreadyRunningError – if a sequence is already running.
Exception – if an exception occurs while running the sequence.
- abstractmethod sequences() list[PureSequencePath]
Retrieve the list of sequences that were started by the procedure.
- Returns:
A list of sequences that were started by the procedure since it was started, ordered by execution order. If the procedure is currently running a sequence, the sequence will be the last element of the list.