Belle II Software  release-08-01-10
Basf2IPythonHandler Class Reference
Inheritance diagram for Basf2IPythonHandler:
Collaboration diagram for Basf2IPythonHandler:

Public Member Functions

def __init__ (self)
 
def process (self, path, result_queue=None, max_event=0)
 
def process (self, result_queue=None, **kwargs)
 
def process_parameter_space (self, kwargs_creator_function, **parameter_lists)
 
def next_log_file_name (self)
 

Static Public Member Functions

def style ()
 
def create_queue ()
 

Public Attributes

 information
 A shortcut for returning information on the ipython_handler_basf2 environment.
 
 modules
 A shortcut for returning module information.
 
 log_files
 A list of open log files.
 

Private Attributes

 _calculation_type
 Use our own calculation type.
 

Detailed Description

Handler class to start processes in an IPython notebook in a convenient way.
From this whole framework you should not need to create any instances by yourself but rather use the
given ipython handler for this.

Usage
-----

Create a handler object in the beginning of your NB and use the two methods `process`
and `process_parameter_space` to turn a path or a path creator function into a Basf2Calculation.
Do not create calculations on you own.

    from tracking.validation.ipython_handler import handler

    path = ...

    calculation = handler.process(path)

Definition at line 14 of file ipython_handler.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)
Set the ipython_handler_basf2 related shortcuts.

Reimplemented from IPythonHandler.

Definition at line 35 of file ipython_handler.py.

35  def __init__(self):
36  """
37  Set the ipython_handler_basf2 related shortcuts.
38  """
39  super().__init__()
40 
41 
42  self.information = Basf2EnvironmentInformation()
43 
44 
45  self.modules = Basf2ModulesInformation()
46 
47 
48  self._calculation_type = Basf2Calculation
49 

Member Function Documentation

◆ create_queue()

def create_queue ( )
staticinherited
Create a Calculation queue. You need to do this if you want to pass it to your modules
and write to it while processing the events.

Definition at line 138 of file ipython_handler.py.

◆ next_log_file_name()

def next_log_file_name (   self)
inherited
Return the name of the next log file.
If there are more than 20 log files present,
start deleting the oldest ones.

Definition at line 117 of file ipython_handler.py.

◆ process() [1/2]

def process (   self,
  path,
  result_queue = None,
  max_event = 0 
)
Shortcut for convenience.

Definition at line 50 of file ipython_handler.py.

◆ process() [2/2]

def process (   self,
  result_queue = None,
**  kwargs 
)
inherited
Turn a parameter set into a Calculation that you can start, stop or whatever you want.

Arguments:
    result_queue: The CalculationQueue you want to use. Without giving
        this as a parameter the function creates one for you. Create
        one on your own with the function create_queue.

Definition at line 47 of file ipython_handler.py.

◆ process_parameter_space()

def process_parameter_space (   self,
  kwargs_creator_function,
**  parameter_lists 
)
inherited
Create a list of calculations by combining all parameters with all parameters you provide and
feeding the tuple into the parameter_creator_function.
If the kwargs_creator_function has a parameter named queue, the function feeds the corresponding
created queue into the parameter_creator_function.
The parameter_creator_function must return a dictionary for every combination of parameters it gets,
which will be used to construct a process out of it.
See ipython_handler_basf2/ipython_handler for an example.

Please note that a list of calculations acts the same as a single calculation you would get from
the process function. You can handle 10 calculations the same way you would handle a single one.

The kwargs_creator_function can transform the incoming parameters into different ones. To make this
more clear, the resulting dictionary created by the kwargs_creator_function is called kwargs.
These are the ones, that will be used to create a calculation process, so they must be compatible to the
calculation you chose (namely compatible with the append function of the _calculation_type).

Arguments:
    kwargs_creator_function: A function with as many input parameters
        as parameters you provide.  If the function has an additional
        queue parameter it is fed with the corresponding queue for this
        calculation.
    parameter_lists: As many lists as you want. Every list is one
        parameter. If you do not want a specific parameter
        constellation to occur, you can return None in your
        parameter_creator_function for this combination.

Usage::

    def kwargs_creator_function(par_1, par_2, par_3, queue):
        kwargs = {... f(par_1) ... g(par_2) ... h(par_3)}
        queue.put(..., ...)
        return kwargs

    calculations = handler.process_parameter_space(kwargs_creator_function,
                                                   par_1=[1, 2, 3], par_2=["x", "y", "z"], par_3=[3, 4, 5])

The calculations will be created with the kwargs arguments.

Definition at line 65 of file ipython_handler.py.

◆ style()

def style ( )
static
Show a nice styling :-)

Definition at line 57 of file ipython_handler.py.


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