Belle II Software  release-06-00-14
CalibrationMachine Class Reference
Inheritance diagram for CalibrationMachine:
Collaboration diagram for CalibrationMachine:

Public Member Functions

def __init__ (self, calibration, iov_to_calibrate=None, initial_state="init", iteration=0)
 
def files_containing_iov (self, file_paths, files_to_iovs, iov)
 
def dependencies_completed (self)
 
def automatic_transition (self)
 
def initial_state (self)
 
def initial_state (self, state)
 
def state (self)
 
def state (self, state)
 
def add_state (self, state, enter=None, exit=None)
 
def add_transition (self, trigger, source, dest, conditions=None, before=None, after=None)
 
def __getattr__ (self, name, **kwargs)
 
def get_transitions (self, source)
 
def get_transition_dict (self, state, transition)
 
def save_graph (self, filename, graphname)
 

Static Public Member Functions

def default_condition (**kwargs)
 

Public Attributes

 default_states
 States that are defaults to the CalibrationMachine (could override later)
 
 calibration
 Calibration object whose state we are modelling.
 
 iteration
 Allows calibration object to hold a refernce to the machine controlling it. More...
 
 collector_backend
 Backend used for this calibration machine collector.
 
 iov_to_calibrate
 IoV to be executed, currently will loop over all runs in IoV.
 
 root_dir
 root directory for this Calibration
 
 states
 Valid states for this machine.
 
 initial_state
 Pointless docstring since it's a property.
 
 transitions
 Allowed transitions between states.
 
 state
 Current State of machine.
 

Static Public Attributes

string collector_input_dir = 'collector_input'
 
string collector_output_dir = 'collector_output'
 
string algorithm_output_dir = 'algorithm_output'
 

Private Member Functions

def _update_cal_state (self, **kwargs)
 
def _dump_job_config (self)
 
def _recover_collector_jobs (self)
 
def _iov_requested (self)
 
def _resolve_file_paths (self)
 
def _build_iov_dicts (self)
 
def _below_max_iterations (self)
 
def _increment_iteration (self)
 
def _collection_completed (self)
 
def _collection_failed (self)
 
def _runner_not_failed (self)
 
def _runner_failed (self)
 
def _collector_jobs_ready (self)
 
def _submit_collections (self)
 
def _no_require_iteration (self)
 
def _require_iteration (self)
 
def _log_new_state (self, **kwargs)
 
def _make_output_dir (self)
 
def _make_collector_path (self, name, collection)
 
def _make_pre_collector_path (self, name, collection)
 
def _create_collector_jobs (self)
 
def _check_valid_collector_output (self)
 
def _run_algorithms (self)
 
def _prepare_final_db (self)
 
def _trigger (self, transition_name, transition_dict, **kwargs)
 

Static Private Member Functions

def _callback (func, **kwargs)
 

Private Attributes

 _algorithm_results
 Results of each iteration for all algorithms of this calibration.
 
 _runner_final_state
 Final state of the algorithm runner for the current iteration.
 
 _collector_timing
 Times of various useful updates to the collector job e.g. More...
 
 _collector_jobs
 The collector jobs used for submission.
 
 _state
 
 _initial_state
 Actual attribute holding initial state for this machine.
 

Detailed Description

A state machine to handle `Calibration` objects and the flow of
processing for them.

Definition at line 379 of file state_machines.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  calibration,
  iov_to_calibrate = None,
  initial_state = "init",
  iteration = 0 
)
Takes a Calibration object from the caf framework and lets you
set the initial state.

Definition at line 389 of file state_machines.py.

Member Function Documentation

◆ __getattr__()

def __getattr__ (   self,
  name,
**  kwargs 
)
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 300 of file state_machines.py.

◆ _below_max_iterations()

def _below_max_iterations (   self)
private
 

Definition at line 556 of file state_machines.py.

◆ _build_iov_dicts()

def _build_iov_dicts (   self)
private
Build IoV file dictionary for each collection if required.

Definition at line 533 of file state_machines.py.

◆ _callback()

def _callback (   func,
**  kwargs 
)
staticprivateinherited
Calls a condition/before/after.. function using arguments passed (or not).

Definition at line 336 of file state_machines.py.

◆ _collection_completed()

def _collection_completed (   self)
private
Did all the collections succeed?

Definition at line 567 of file state_machines.py.

◆ _collection_failed()

def _collection_failed (   self)
private
Did any of the collections fail?

Definition at line 575 of file state_machines.py.

◆ _collector_jobs_ready()

def _collector_jobs_ready (   self)
private
 

Definition at line 600 of file state_machines.py.

◆ _create_collector_jobs()

def _create_collector_jobs (   self)
private
Creates a Job object for the collections of this iteration, ready for submission
to backend.

Definition at line 722 of file state_machines.py.

◆ _dump_job_config()

def _dump_job_config (   self)
private
Dumps the `Job` object for the collections to JSON files so that it's configuration can be recovered
later in case of failure.

Definition at line 490 of file state_machines.py.

◆ _increment_iteration()

def _increment_iteration (   self)
private
 

Definition at line 561 of file state_machines.py.

◆ _iov_requested()

def _iov_requested (   self)
private
 

Definition at line 518 of file state_machines.py.

◆ _log_new_state()

def _log_new_state (   self,
**  kwargs 
)
private
 

Definition at line 647 of file state_machines.py.

◆ _make_collector_path()

def _make_collector_path (   self,
  name,
  collection 
)
private
Creates a basf2 path for the correct collector and serializes it in the
self.output_dir/<calibration_name>/<iteration>/paths directory

Definition at line 688 of file state_machines.py.

◆ _make_output_dir()

def _make_output_dir (   self)
private
Creates the overall root directory of the Calibration. Will not overwrite if it already exists.
Also creates s

Definition at line 681 of file state_machines.py.

◆ _make_pre_collector_path()

def _make_pre_collector_path (   self,
  name,
  collection 
)
private
Creates a basf2 path for the collectors setup path (Collection.pre_collector_path) and serializes it in the
self.output_dir/<calibration_name>/<iteration>/<colector_output>/<name> directory.

Definition at line 707 of file state_machines.py.

◆ _no_require_iteration()

def _no_require_iteration (   self)
private
 

Definition at line 623 of file state_machines.py.

◆ _prepare_final_db()

def _prepare_final_db (   self)
private
Take the last iteration's outputdb and copy it to a more easily findable place.

Definition at line 906 of file state_machines.py.

◆ _recover_collector_jobs()

def _recover_collector_jobs (   self)
private
Recovers the `Job` object for the collector from a JSON file in the event that we are starting from a reset.

Definition at line 507 of file state_machines.py.

◆ _require_iteration()

def _require_iteration (   self)
private
 

Definition at line 634 of file state_machines.py.

◆ _resolve_file_paths()

def _resolve_file_paths (   self)
private
 

Definition at line 528 of file state_machines.py.

◆ _run_algorithms()

def _run_algorithms (   self)
private
Runs the Calibration Algorithms for this calibration machine.

Will run them sequentially locally (possible benefits to using a
processing pool for low memory algorithms later on.)

Definition at line 842 of file state_machines.py.

◆ _runner_failed()

def _runner_failed (   self)
private
Returns:
    bool: If AlgorithmsRunner failed return True.

Definition at line 590 of file state_machines.py.

◆ _runner_not_failed()

def _runner_not_failed (   self)
private
Returns:
    bool: If AlgorithmsRunner succeeded return True.

Definition at line 583 of file state_machines.py.

◆ _submit_collections()

def _submit_collections (   self)
private
 

Definition at line 616 of file state_machines.py.

◆ _trigger()

def _trigger (   self,
  transition_name,
  transition_dict,
**  kwargs 
)
privateinherited
Runs the transition logic. Callbacks are evaluated in the order:
conditions -> before -> <new state set here> -> after.

Definition at line 312 of file state_machines.py.

◆ add_state()

def add_state (   self,
  state,
  enter = None,
  exit = None 
)
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 187 of file state_machines.py.

◆ add_transition()

def add_transition (   self,
  trigger,
  source,
  dest,
  conditions = None,
  before = None,
  after = None 
)
inherited
Adds a single transition to the dictionary of possible ones.
Trigger is the method name that begins the transtion 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 258 of file state_machines.py.

◆ automatic_transition()

def automatic_transition (   self)
Automatically try all transitions out of this state once. Tries fail last.

Definition at line 663 of file state_machines.py.

◆ default_condition()

def default_condition ( **  kwargs)
staticinherited
Method to always return True.

Definition at line 252 of file state_machines.py.

◆ dependencies_completed()

def dependencies_completed (   self)
Condition function to check that the dependencies of our calibration are in the 'completed' state.
Technically only need to check explicit dependencies.

Definition at line 652 of file state_machines.py.

◆ files_containing_iov()

def files_containing_iov (   self,
  file_paths,
  files_to_iovs,
  iov 
)
Lookup function that returns all files from the file_paths that
overlap with this IoV.

Definition at line 477 of file state_machines.py.

◆ get_transition_dict()

def get_transition_dict (   self,
  state,
  transition 
)
inherited
Returns the transition dictionary for a state and transition out of it.

Definition at line 353 of file state_machines.py.

◆ get_transitions()

def get_transitions (   self,
  source 
)
inherited
Returns allowed transitions from a given state.

Definition at line 342 of file state_machines.py.

◆ initial_state() [1/2]

def initial_state (   self)
inherited
The initial state of the machine. Needs a special property to prevent trying to run on_enter callbacks when set.

Definition at line 203 of file state_machines.py.

◆ initial_state() [2/2]

def initial_state (   self,
  state 
)
inherited
 

Definition at line 210 of file state_machines.py.

◆ save_graph()

def save_graph (   self,
  filename,
  graphname 
)
inherited
Does a simple dot file creation to visualise states and transiitons.

Definition at line 364 of file state_machines.py.

◆ state() [1/2]

def state (   self)
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 221 of file state_machines.py.

◆ state() [2/2]

def state (   self,
  state 
)
inherited
 

Definition at line 230 of file state_machines.py.

Member Data Documentation

◆ _collector_timing

_collector_timing
private

Times of various useful updates to the collector job e.g.

start, elapsed, last update Used to periodically call update_status on the collector job and find out an overall number of jobs remaining + estimated remaining time

Definition at line 438 of file state_machines.py.

◆ iteration

iteration

Allows calibration object to hold a refernce to the machine controlling it.

Which iteration step are we in

Definition at line 423 of file state_machines.py.


The documentation for this class was generated from the following file: