Belle II Software  release-05-01-25
CalibrationSettings Class Reference
Inheritance diagram for CalibrationSettings:
Collaboration diagram for CalibrationSettings:

Public Member Functions

def __new__ (cls, name, expert_username, description, input_data_formats=None, input_data_names=None, depends_on=None, expert_config=None)
 
def json_dumps (self)
 
def __str__ (self)
 

Static Public Attributes

 allowed_data_formats = frozenset({"raw", "cdst", "mdst", "udst"})
 Allowed data file formats. More...
 

Detailed Description

Simple class to hold and display required information for a prompt calibration script (process).

Parameters:
    name (str): The unique calibration name, not longer than 64 characters.

    expert_username (str): The JIRA username of the expert to contact about this script.
        This username will be used to assign the default responsible person for submitting and checking prompt
        calibration jobs.

    description (str): Long form description of the calibration and what it does. Feel free to make this as long as you need.

    input_data_formats (frozenset(str)): The data formats {'raw', 'cdst', 'mdst', 'udst'} of the input files
        that should be used as input to the process. Used to figure out if this calibration should occur
        before the relevant data production e.g. before cDST files are created.

    input_data_names (frozenset(str)): The names that you will use when accessing the input data given to the
        prompt calibration process i.e. Use these in the ``get_calibrations`` function to access the correct input
        data files.

    depends_on list(CalibrationSettings): The settings variables of the other prompt calibrations that you want
        want to depend on. This will allow the external automatic system to understand the overall ordering of
        scripts to run. If you encounter an import error when trying to run your prompt calibration script, it is
        likely that you have introduced a circular dependency.

    expert_config (dict): Default expert configuration for this calibration script. This is an optional dictionary
        (which must be JSON compliant) of configuration options for your get_calibrations(...) function.
        This is supposed to be used as a catch-all place to send in options for your calibration setup. For example,
        you may want to have an optional list of IoV boundaries so that your prompt script knows that it should split the
        input data between different IoV ranges. Or you might want to send if options like the maximum events per
        input file to process. The value in your settings object will be the *default*, but you can override the value via
        the caf_config.json sent into ``b2caf-prompt-run``.

Definition at line 14 of file __init__.py.

Member Function Documentation

◆ __new__()

def __new__ (   cls,
  name,
  expert_username,
  description,
  input_data_formats = None,
  input_data_names = None,
  depends_on = None,
  expert_config = None 
)
The special method to create the tuple instance. Returning the instance
calls the __init__ method

Definition at line 54 of file __init__.py.

54  def __new__(cls, name, expert_username, description,
55  input_data_formats=None, input_data_names=None, depends_on=None, expert_config=None):
56  """
57  The special method to create the tuple instance. Returning the instance
58  calls the __init__ method
59  """
60  if len(name) > 64:
61  raise ValueError("name cannot be longer than 64 characters!")
62  if not input_data_formats:
63  raise ValueError("You must specify at least one input data format")
64  input_data_formats = frozenset(map(lambda x: x.lower(), input_data_formats))
65  if input_data_formats.difference(cls.allowed_data_formats):
66  raise ValueError("There was a data format that is not in the allowed_data_formats attribute.")
67  if not input_data_names:
68  raise ValueError("You must specify at least one input data name")
69  input_data_names = frozenset(input_data_names)
70 
71  if expert_config:
72  # Check that it's a dictionary and not some other valid JSON object
73  if not isinstance(expert_config, dict):
74  raise TypeError("expert_config must be a dictionary")
75  # Check if it is JSONable since people might put objects in there by mistake
76  try:
77  json.dumps(expert_config)
78  except TypeError as e:
79  basf2.B2ERROR("expert_config could not be serialised to JSON. "
80  "Most likely you used a non-supported type e.g. datetime.")
81  raise e
82  else:
83  expert_config = {}
84 
85  if depends_on:
86  for calibration_settings in depends_on:
87  if not isinstance(calibration_settings, cls):
88  raise TypeError(f"A list of {str(cls)} object is required when setting the 'depends_on' keyword.")
89  else:
90  depends_on = []
91 
92  return super().__new__(cls, name, expert_username, description,
93  input_data_formats, input_data_names, depends_on, expert_config)
94 

◆ json_dumps()

def json_dumps (   self)
Returns:
     str: A valid JSON format string of the attributes.

Definition at line 95 of file __init__.py.

Member Data Documentation

◆ allowed_data_formats

allowed_data_formats = frozenset({"raw", "cdst", "mdst", "udst"})
static

Allowed data file formats.

You should use these values for CalibrationSettings.input_data_formats. Right now you should only use "raw" or "cdst" because we don't actually run calibrations on "mdst" or "udst". They are here for completeness.

Definition at line 52 of file __init__.py.


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