Belle II Software  release-06-01-15
AlgorithmStrategy Class Reference
Inheritance diagram for AlgorithmStrategy:
Collaboration diagram for AlgorithmStrategy:

Public Member Functions

def __init__ (self, algorithm)
 
def run (self, iov, iteration, queue)
 
def setup_from_dict (self, params)
 
def is_valid (self)
 
def find_iov_gaps (self)
 
def any_failed_iov (self)
 
def send_result (self, result)
 
def send_final_state (self, state)
 

Public Attributes

 algorithm
 Algorithm() class that we're running.
 
 input_files
 Collector output files, will contain all files retured by the output patterns.
 
 output_dir
 The algorithm output directory which is mostly used to store the stdout file.
 
 output_database_dir
 The output database directory for the localdb that the algorithm will commit to.
 
 database_chain
 User defined database chain i.e. More...
 
 dependent_databases
 CAF created local databases from previous calibrations that this calibration/algorithm depends on.
 
 ignored_runs
 Runs that will not be included in ANY execution of the algorithm. More...
 
 results
 The list of results objects which will be sent out before the end.
 
 queue
 The multiprocessing Queue we use to pass back results one at a time.
 

Static Public Attributes

list required_attrs
 Required attributes that must exist before the strategy can run properly. More...
 
list required_true_attrs
 Attributes that must have a value that returns True when tested by :py:meth:is_valid. More...
 
list allowed_granularities = ["run", "all"]
 Granularity of collector that can be run by this algorithm properly.
 
string FINISHED_RESULTS = "DONE"
 Signal value that is put into the Queue when there are no more results left.
 
string COMPLETED = "COMPLETED"
 Completed state.
 
string FAILED = "FAILED"
 Failed state.
 

Detailed Description

Base class for Algorithm strategies. These do the actual execution of a single
algorithm on collected data. Each strategy may be quite different in terms of how fast it may be,
how database payloads are passed between executions, and whether or not final payloads have an IoV
that is independent to the actual runs used to calculates them.

Parameters:
    algorithm (:py:class:`caf.framework.Algorithm`): The algorithm we will run

This base class defines the basic attributes and methods that will be automatically used by the selected AlgorithmRunner.
When defining a derived class you are free to use these attributes or to implement as much functionality as you want.

If you define your derived class with an __init__ method, then you should first call the base class
`AlgorithmStrategy.__init__()`  method via super() e.g.

>>> def __init__(self):
>>>     super().__init__()

The most important method to implement is :py:meth:`AlgorithmStrategy.run` which will take an algorithm and execute it
in the required way defined by the options you have selected/attributes set.

Definition at line 25 of file strategies.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  algorithm 
)
 

Reimplemented in SequentialBoundaries, SimpleRunByRun, SequentialRunByRun, and SingleIOV.

Definition at line 77 of file strategies.py.

77  def __init__(self, algorithm):
78  """
79  """
80 
81  self.algorithm = algorithm
82 
83  self.input_files = []
84 
85  self.output_dir = ""
86 
87  self.output_database_dir = ""
88 
89  self.database_chain = []
90 
91  self.dependent_databases = []
92 
94  self.ignored_runs = []
95 
96  self.results = []
97 
98  self.queue = None
99 

Member Function Documentation

◆ any_failed_iov()

def any_failed_iov (   self)
Returns:
    bool: If any result in the current results list has a failed algorithm code we return True

Definition at line 153 of file strategies.py.

◆ find_iov_gaps()

def find_iov_gaps (   self)
Finds and prints the current gaps between the IoVs of the strategy results. Basically these are the IoVs
not covered by any payload. It CANNOT find gaps if they exist across an experiment boundary. Only gaps
within the same experiment are found.

Returns:
    iov_gaps(list[IoV])

Definition at line 133 of file strategies.py.

◆ is_valid()

def is_valid (   self)
Returns:
    bool: Whether or not this strategy has been set up correctly with all its necessary attributes.

Definition at line 115 of file strategies.py.

◆ run()

def run (   self,
  iov,
  iteration,
  queue 
)
Abstract method that needs to be implemented. It will be called to actually execute the
algorithm.

Reimplemented in SequentialBoundaries, SimpleRunByRun, SequentialRunByRun, and SingleIOV.

Definition at line 101 of file strategies.py.

◆ setup_from_dict()

def setup_from_dict (   self,
  params 
)
Parameters:
    params (dict): Dictionary containing values to be assigned to the strategy attributes of the same name.

Definition at line 107 of file strategies.py.

Member Data Documentation

◆ database_chain

database_chain

User defined database chain i.e.

the default global tag, or if you have localdb's/tags for custom alignment etc

Definition at line 89 of file strategies.py.

◆ ignored_runs

ignored_runs

Runs that will not be included in ANY execution of the algorithm.

Usually set by Calibration.ignored_runs. The different strategies may handle the resulting run gaps differently.

Definition at line 94 of file strategies.py.

◆ required_attrs

list required_attrs
static
Initial value:
= ["algorithm",
"database_chain",
"dependent_databases",
"output_dir",
"output_database_dir",
"input_files",
"ignored_runs"
]

Required attributes that must exist before the strategy can run properly.

Base class for Algorithm strategies. These do the actual execution of a single
algorithm on collected data. Each strategy may be quite different in terms of how fast it may be,
how database payloads are passed between executions, and whether or not final payloads have an IoV
that is independent to the actual runs used to calculates them.

Parameters:
    algorithm (:py:class:`caf.framework.Algorithm`): The algorithm we will run

This base class defines the basic attributes and methods that will be automatically used by the selected AlgorithmRunner.
When defining a derived class you are free to use these attributes or to implement as much functionality as you want.

If you define your derived class with an __init__ method, then you should first call the base class
`AlgorithmStrategy.__init__()`  method via super() e.g.

>>> def __init__(self):
>>>     super().__init__()

The most important method to implement is :py:meth:`AlgorithmStrategy.run` which will take an algorithm and execute it
in the required way defined by the options you have selected/attributes set.

Some are allowed be values that return False whe tested e.g. "" or []

Definition at line 49 of file strategies.py.

◆ required_true_attrs

list required_true_attrs
static
Initial value:
= ["algorithm",
"output_dir",
"output_database_dir",
"input_files"
]

Attributes that must have a value that returns True when tested by :py:meth:is_valid.

Definition at line 59 of file strategies.py.


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