ExperimentSession

class caqtus.session.ExperimentSession(*args, **kwargs)

Bases: AbstractContextManager[ExperimentSession], Protocol

Provides a transactional connection to the storage of the experiment.

An ExperimentSession object allows to read and write configurations and data of the experiment. Every function and method that read or write data do so through an experiment session object.

An experiment session object must be activated before it can be used. This is done by using the with statement on the session, inside which the session is active. If an error occurs inside the with block of the session, the data will be rolled back to the state it was in before the with block was entered in order to prevent leaving the storage in an inconsistent state. Data is only committed to the permanent storage when the with block is exited and will only be visible to other sessions after that point. For this reason, it is recommended to keep the with block as short as possible.

A given session is not meant to be used concurrently. It can’t be pickled and must not be passed to other processes. It is also not thread safe. It is not meant to be used by several coroutines at the same time, even if they belong to the same thread.

It is possible to create multiple sessions connecting to the same storage using an caqtus.session.ExperimentSessionMaker.

property paths: PathHierarchy

The hierarchy of paths in the experiment session.

property sequences: SequenceCollection

The collection of sequences in the experiment session.

default_device_configurations: DeviceConfigurationCollection

The default device configurations used to run a sequence.

get_sequence(path: PureSequencePath | str) Sequence

Get a sequence object from the session.

Parameters:

path – The path of the sequence to get.

Returns:

The sequence object.

Raises:

SequenceNotFoundError – If the sequence does not exist.

get_global_parameters() ParameterNamespace

Returns a copy of the global parameters of the session.

Global parameters are parameters that are not specific to a sequence, but are relevant for all the sequences.

set_global_parameters(
parameters: ParameterNamespace,
) None

Overwrite the global parameters of the session with the given parameters.