Sequence#
Module: exa.core.sequence.sequence
- class Sequence(observation_stash=None, **kwargs)#
Bases:
ABCBase class for Sequences. New sequences are defined by subclassing this.
A subclass of Sequence should at least define
nameas a class attribute, and implementexecute(), which is the main body of the sequence execution.- Parameters:
observation_stash (ObservationStash | None) – If provided, the observations created by the execution nodes will not be saved to the DB but to the given stash instead. In this case, any subsequences will by default copy that stash, add their observations to the copy, and only at the end of the subsequence execution, save them to the parent’s stash. The user may turn off the merging of stashes via the attribute
save_stashand/or use a different stash (or no stash) for a given execution node in the actual implementation ofexecute().kwargs – All keyword arguments to the constructor are copied to
optionsattribute. Theexecute()can refer to the options to modify the behavior of the execution. The meaning of the options depends entirely on how they are used byexecute(). The user may apply options to specific execution nodes via prefixing them with the node’s class names. E.g. to apply optionfoo = 1for experiment classMyExperimentthat is a part of the subsequenceMySequence, the user should addMySequence_MyExperiment_foo = 1to the kwargs.
Attributes
Required keys for the sequence
optionsand their default values.Ignore analyze errors for this sequence and its subsequences.
Whether to save this sequence's stash to the parent sequence's stash (or the DB if the parent does not have stash).
Identifier of the sequence type.
Options that modify the execution.
Methods
Function that performs sequence-level analysis based on the results of the executed nodes.
Generate a context manager inside
execute().Executes the sequence.
Set the attribute values from options for the options defined in
ATTRIBUTE_OPTIONS.- static analysis(result, **kwargs)#
Function that performs sequence-level analysis based on the results of the executed nodes. It must take a
SequenceResultas the first argument and return aSequenceAnalyzeResult. Other arguments are optional. analysis should be given as a class attribute, decorated withstaticmethod. If a subclass does not defineanalysis,default_analysis()is used.- Parameters:
result (SequenceExecuteResult)
- Return type:
- default_options: dict[str, Any] = {}#
Required keys for the sequence
optionsand their default values.
- tracker_class#
ExperimentTrackeror a subclass of it. This class will be used when creating a tracker object in the execution context withtrack(). Giving your own tracker class allows modifying the execution of all experiments, for example by wrapping the run logic with custom conditions.alias of
ExperimentTracker
- sequence_executor_class#
SequenceExecutoror a subclass of it. This class will be used when executing a sequence, and can be used to modify the sequence execution.alias of
SequenceExecutor
- save_stash: bool = True#
Whether to save this sequence’s stash to the parent sequence’s stash (or the DB if the parent does not have stash). This attribute has an effect only if set at the subsequence level, and effect will not propagate to further subsequences. This attribute is also settable by including
save_stashin the sequence options.
- ignore_analyze_errors: bool | None = None#
Ignore analyze errors for this sequence and its subsequences. The observations and other analyze results will be retained if they were created successfully, but any analyze errors will still be shown in the report. If set, as True or False, the effect will propagate recursively to all subsequences and their experiments. This attribute is also settable by including
ignore_analyze_errorsin the sequence options.
- options: dict[str, Any]#
Options that modify the execution. The values are either class-level defaults from
default_optionsor kwargs given in the constructor. Options must contain only basic Python types.
- context(sequence_run_id=None)#
Generate a context manager inside
execute().- Parameters:
sequence_run_id (UUID | None) – If specified uses this id for the sequence.
- Returns:
A new instance of SequenceContext.
- Return type:
- set_attribute_options()#
Set the attribute values from options for the options defined in
ATTRIBUTE_OPTIONS.
- abstractmethod execute()#
Executes the sequence.
This is the main body of the execution code and should be implemented in a subclass.
Inside this method
A
SequenceContextshould be created by making awith self.context() as context:statement.Under the
withstatement, all calls toExperiment.run(),Experiment.analyze(), andSequence.execute()(of subsequences) should be made using the methods ofcontext. Otherwise, those actions will not be tracked.The method must end with
return context.to_result(), called outside the scope of the above-mentionedwithstatement. It converts the captured results for further processing.
- Returns:
A new instance of SequenceExecuteResult.
- Return type:
Inheritance
