Belle II Software development
AlgorithmsRunner Class Reference
Inheritance diagram for AlgorithmsRunner:
Runner SeqAlgorithmsRunner

Public Member Functions

 __init__ (self, name)
 
 run (self)
 

Public Attributes

 name = name
 The name of this runner instance.
 
list input_files = []
 All of the output files made by the collector job and recovered by the "output_patterns".
 
list database_chain = []
 User set databases, can be used to apply your own constants and global tags.
 
list dependent_databases = []
 List of local databases created by previous CAF calibrations/iterations.
 
str output_database_dir = ""
 The directory of the local database we use to store algorithm payloads from this execution.
 
dict results = {}
 Algorithm results from each algorithm we execute.
 
 final_state = None
 Final state of runner.
 
 algorithms = None
 The list of algorithms that this runner executes.
 
str output_dir = ""
 Output directory of these algorithms, for logging mostly.
 

Static Public Attributes

str FAILED = "FAILED"
 failed
 
str COMPLETED = "COMPLETED"
 completed
 

Detailed Description

Base class for `AlgorithmsRunner` classes. Defines the necessary information that will be provided to every
`AlgorithmsRunner` used by the `framework.CAF`

An `AlgorithmsRunner` will be given a list of `framework.Algorithm` objects defined during the setup of a
`framework.Calibration` instance. The `AlgorithmsRunner` describes how to run each of the `strategies.AlgorithmStrategy`
objects. As an example, assume that a single `framework.Calibration` was given and list of two `framework.Algorithm`
instances to run.

In this example the chosen :py:meth:`AlgorithmsRunner.run()` is simple and just loops over the list of `caf.framework.Algorithm`
calling each one's :py:meth:`caf.strategies.AlgorithmStrategy.run()` methods in order.
Thereby generating a localdb with the only communication between the `strategies.AlgorithmStrategy` instances coming from the
database payloads being available from one algorithm to the next.

But you could imagine a more complex situation. The `AlgorithmsRunner` might take the first `framework.Algorithm` and
call its `AlgorithmStrategy.run` for only the first (exp,run) in the collected data. Then it might not commit the payloads
to a localdb but instead pass some calculated values to the next algorithm to run on the same IoV. Then it might go back
and re-run the first AlgorithmStrategy with new information and commit payloads this time. Then move onto the next IoV.

Hopefully you can see that while the default provided `AlgorithmsRunner` and `AlgorithmStrategy` classes should be good for
most situations, you have lot of freedom to define your own strategy if needed. By following the basic requirements for the
interface to the `framework.CAF` you can easily plugin a different special case, or mix and match a custom class with
default CAF ones.

The run(self) method should be defined for every derived `AlgorithmsRunner`. It will be called once and only once for each
iteration of (collector -> algorithm).

Input files are automatically given via the `framework.Calibration.output_patterns` which constructs
a list of all files in the collector output directories that match the output_patterns. If you have multiple types of
output data it is your job to filter through the input files and assign them correctly.

A list of local database paths are given to the `AlgorithmsRunner` based on the `framework.Calibration` dependencies and
any overall database chain given to the Calibration before running.
By default you can call the "setup_algorithm" transition of the `caf.state_machines.AlgorithmMachine` to automatically
set a database chain based on this list.
But you have freedom to not call this at all in `run`, or to implement a different method to deal with this.

Definition at line 27 of file runners.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ ( self,
name )
 

Definition at line 71 of file runners.py.

71 def __init__(self, name):
72 """
73 """
74
75 self.name = name
76
77 self.input_files = []
78
79 self.database_chain = []
80
81 self.dependent_databases = []
82
83 self.output_database_dir = ""
84
85 self.results = {}
86
87 self.final_state = None
88
89 self.algorithms = None
90
91 self.output_dir = ""
92
93

Member Function Documentation

◆ run()

run ( self)
inherited
 

Reimplemented in SeqAlgorithmsRunner.

Definition at line 22 of file runners.py.

22 def run(self):
23 """
24 """
25
26

Member Data Documentation

◆ algorithms

algorithms = None

The list of algorithms that this runner executes.

Definition at line 89 of file runners.py.

◆ COMPLETED

str COMPLETED = "COMPLETED"
static

completed

Definition at line 69 of file runners.py.

◆ database_chain

list database_chain = []

User set databases, can be used to apply your own constants and global tags.

Definition at line 79 of file runners.py.

◆ dependent_databases

list dependent_databases = []

List of local databases created by previous CAF calibrations/iterations.

Definition at line 81 of file runners.py.

◆ FAILED

str FAILED = "FAILED"
static

failed

Definition at line 67 of file runners.py.

◆ final_state

final_state = None

Final state of runner.

Definition at line 87 of file runners.py.

◆ input_files

list input_files = []

All of the output files made by the collector job and recovered by the "output_patterns".

Definition at line 77 of file runners.py.

◆ name

name = name

The name of this runner instance.

Definition at line 75 of file runners.py.

◆ output_database_dir

str output_database_dir = ""

The directory of the local database we use to store algorithm payloads from this execution.

Definition at line 83 of file runners.py.

◆ output_dir

str output_dir = ""

Output directory of these algorithms, for logging mostly.

Definition at line 91 of file runners.py.

◆ results

dict results = {}

Algorithm results from each algorithm we execute.

Definition at line 85 of file runners.py.


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