![]() |
Belle II Software development
|
Public Member Functions | |
__init__ (self, algorithm=None, initial_state="init") | |
setup_from_dict (self, params) | |
is_valid (self) | |
initial_state (self) | |
initial_state (self, state) | |
state (self) | |
state (self, state) | |
add_state (self, state, enter=None, exit=None) | |
add_transition (self, trigger, source, dest, conditions=None, before=None, after=None) | |
__getattr__ (self, name, **kwargs) | |
get_transitions (self, source) | |
get_transition_dict (self, state, transition) | |
save_graph (self, filename, graphname) | |
Static Public Member Functions | |
default_condition (**kwargs) | |
Public Attributes | |
list | default_states |
Default states for the AlgorithmMachine. | |
algorithm = algorithm | |
Algorithm() object whose state we are modelling. | |
list | input_files = [] |
Collector output files, will contain all files returned by the output patterns. | |
list | dependent_databases = [] |
CAF created local databases from previous calibrations that this calibration/algorithm depends on. | |
list | database_chain = [] |
Assigned database chain to the overall Calibration object, or to the 'default' Collection. | |
str | output_dir = "" |
The algorithm output directory which is mostly used to store the stdout file. | |
str | output_database_dir = "" |
The output database directory for the localdb that the algorithm will commit to. | |
result = None | |
IoV_Result object for a single execution, will be reset upon a new execution. | |
dict | states = {} |
Valid states for this machine. | |
initial_state = initial_state | |
Pointless docstring since it's a property. | |
transitions = defaultdict(list) | |
Allowed transitions between states. | |
state = dest | |
Current State of machine. | |
Static Public Attributes | |
list | required_attrs |
Required attributes that must exist before the machine can run properly. | |
list | required_true_attrs |
Attributes that must have a value that returns True when tested. | |
Protected Member Functions | |
_create_output_dir (self, **kwargs) | |
_setup_database_chain (self, **kwargs) | |
_setup_logging (self, **kwargs) | |
_change_working_dir (self, **kwargs) | |
_pre_algorithm (self, **kwargs) | |
_execute_over_iov (self, **kwargs) | |
_set_input_data (self, **kwargs) | |
_trigger (self, transition_name, transition_dict, **kwargs) | |
Static Protected Member Functions | |
_callback (func, **kwargs) | |
Protected Attributes | |
dict | _initial_state = State(initial_state) |
Actual attribute holding initial state for this machine. | |
dict | _state = self.initial_state |
Actual attribute holding the Current state. | |
A state machine to handle the logic of running the algorithm on the overall runs contained in the data.
Definition at line 929 of file state_machines.py.
__init__ | ( | self, | |
algorithm = None, | |||
initial_state = "init" ) |
Takes an Algorithm object from the caf framework and defines the transitions.
Definition at line 951 of file state_machines.py.
|
inherited |
Allows us to create a new method for each trigger on the fly. If there is no trigger name in the machine to match, then the normal AttributeError is called.
Definition at line 302 of file state_machines.py.
|
staticprotectedinherited |
Calls a condition/before/after.. function using arguments passed (or not).
Definition at line 340 of file state_machines.py.
|
protected |
Definition at line 1074 of file state_machines.py.
|
protected |
Create working/output directory of algorithm. Any old directory is overwritten.
Definition at line 1020 of file state_machines.py.
|
protected |
Does the actual execute of the algorithm on an IoV and records the result.
Definition at line 1090 of file state_machines.py.
|
protected |
Call the user defined algorithm setup function.
Definition at line 1080 of file state_machines.py.
|
protected |
set input data
Definition at line 1105 of file state_machines.py.
|
protected |
Apply all databases in the correct order.
Definition at line 1026 of file state_machines.py.
|
protected |
Definition at line 1064 of file state_machines.py.
|
protectedinherited |
Runs the transition logic. Callbacks are evaluated in the order: conditions -> before -> <new state set here> -> after.
Definition at line 316 of file state_machines.py.
|
inherited |
Adds a single state to the list of possible ones. Should be a unique string or a State object with a unique name.
Definition at line 189 of file state_machines.py.
|
inherited |
Adds a single transition to the dictionary of possible ones. Trigger is the method name that begins the transition between the source state and the destination state. The condition is an optional function that returns True or False depending on the current state/input.
Definition at line 260 of file state_machines.py.
|
staticinherited |
Method to always return True.
Definition at line 254 of file state_machines.py.
|
inherited |
Returns the transition dictionary for a state and transition out of it.
Definition at line 357 of file state_machines.py.
|
inherited |
Returns allowed transitions from a given state.
Definition at line 346 of file state_machines.py.
|
inherited |
The initial state of the machine. Needs a special property to prevent trying to run on_enter callbacks when set.
Definition at line 205 of file state_machines.py.
|
inherited |
Definition at line 212 of file state_machines.py.
is_valid | ( | self | ) |
Returns: bool: Whether or not this machine has been set up correctly with all its necessary attributes.
Definition at line 1002 of file state_machines.py.
|
inherited |
Does a simple dot file creation to visualise states and transiitons.
Definition at line 368 of file state_machines.py.
setup_from_dict | ( | self, | |
params ) |
Parameters: params (dict): Dictionary containing values to be assigned to the machine's attributes of the same name.
Definition at line 994 of file state_machines.py.
|
inherited |
The current state of the machine. Actually a `property` decorator. It will call the exit method of the current state and enter method of the new one. To get around the behaviour e.g. for setting initial states, either use the `initial_state` property or directly set the _state attribute itself (at your own risk!).
Definition at line 223 of file state_machines.py.
|
inherited |
Definition at line 232 of file state_machines.py.
|
protectedinherited |
Actual attribute holding initial state for this machine.
Definition at line 182 of file state_machines.py.
|
protectedinherited |
Actual attribute holding the Current state.
Definition at line 185 of file state_machines.py.
algorithm = algorithm |
Algorithm() object whose state we are modelling.
Definition at line 965 of file state_machines.py.
list database_chain = [] |
Assigned database chain to the overall Calibration object, or to the 'default' Collection.
Database chains for manually created Collections have no effect here.
Definition at line 972 of file state_machines.py.
default_states |
Default states for the AlgorithmMachine.
Definition at line 956 of file state_machines.py.
list dependent_databases = [] |
CAF created local databases from previous calibrations that this calibration/algorithm depends on.
Definition at line 969 of file state_machines.py.
|
inherited |
Pointless docstring since it's a property.
Definition at line 178 of file state_machines.py.
input_files = [] |
Collector output files, will contain all files returned by the output patterns.
Definition at line 967 of file state_machines.py.
output_database_dir = "" |
The output database directory for the localdb that the algorithm will commit to.
Definition at line 976 of file state_machines.py.
output_dir = "" |
The algorithm output directory which is mostly used to store the stdout file.
Definition at line 974 of file state_machines.py.
|
static |
Required attributes that must exist before the machine can run properly.
Some are allowed to be values that return False when tested e.g. "" or []
Definition at line 936 of file state_machines.py.
|
static |
Attributes that must have a value that returns True when tested.
Definition at line 945 of file state_machines.py.
result = None |
IoV_Result object for a single execution, will be reset upon a new execution.
Definition at line 978 of file state_machines.py.
|
inherited |
Current State of machine.
Definition at line 332 of file state_machines.py.
|
inherited |
Valid states for this machine.
Definition at line 172 of file state_machines.py.
|
inherited |
Allowed transitions between states.
Definition at line 187 of file state_machines.py.