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

Public Member Functions

def __init__ (self, algorithm)
 
def apply_experiment_settings (self, algorithm, experiment)
 
def run (self, iov, iteration, queue)
 
def execute_over_run_list (self, iteration, run_list, lowest_exprun, highest_exprun)
 
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

 machine
 :py:class:caf.state_machines.AlgorithmMachine used to help set up and execute CalibrationAlgorithm It gets setup properly in :py:func:run
 
 first_execution
 
 queue
 
 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.
 

Static Public Attributes

dictionary usable_params
 The params that you could set on the Algorithm object which this Strategy would use. More...
 
list allowed_granularities = ["run"]
 Granularity of collector that can be run by this algorithm properly.
 
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...
 
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

Algorithm strategy to do run-by-run calibration of collected data.
Runs the algorithm over the input data contained within the requested IoV, starting with the first run's data only.
If the algorithm returns 'not enough data' on the current run set, it won't commit the payloads, but instead adds
the next run's data and tries again.

Once an execution on a set of runs return 'iterate' or 'ok' we move onto the next runs (if any are left)
and start the same procedure again. Committing of payloads to the outputdb only happens once we're sure that there
is enough data in the remaining runs to get a full execution. If there isn't enough data remaining, the last runs
are merged with the previous successful execution's runs and a final execution is performed on all remaining runs.

Additionally this strategy will automatically make sure that IoV gaps in your input data are covered by a payload.
This means that there shouldn't be any IoVs that don't get a new payload by the  end of runnning an iteration.

This uses a `caf.state_machines.AlgorithmMachine` to actually execute the various steps rather than operating on
a CalibrationAlgorithm C++ class directly.

Definition at line 259 of file strategies.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  algorithm 
)
 

Reimplemented from AlgorithmStrategy.

Definition at line 288 of file strategies.py.

Member Function Documentation

◆ any_failed_iov()

def any_failed_iov (   self)
inherited
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.

◆ apply_experiment_settings()

def apply_experiment_settings (   self,
  algorithm,
  experiment 
)
Apply experiment-dependent settings.
This is the default version, which does not do anything.
If necessary, it should be reimplemented by derived classes.

Definition at line 299 of file strategies.py.

◆ find_iov_gaps()

def find_iov_gaps (   self)
inherited
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)
inherited
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 
)
Runs the algorithm machine over the collected data and fills the results.

Reimplemented from AlgorithmStrategy.

Definition at line 307 of file strategies.py.

◆ setup_from_dict()

def setup_from_dict (   self,
  params 
)
inherited
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
inherited

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
inherited

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
staticinherited
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
staticinherited
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.

◆ usable_params

dictionary usable_params
static
Initial value:
= {
"has_experiment_settings": bool,
"iov_coverage": IoV,
"step_size": int
}

The params that you could set on the Algorithm object which this Strategy would use.

Just here for documentation reasons.

Definition at line 279 of file strategies.py.


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