| The Gaudi Framework v32r1 (f65d50dc)

Public Member Functions | Public Attributes | Private Member Functions | Static Private Attributes | List of all members
GaudiMP.Parallel.Task Class Reference
Inheritance diagram for GaudiMP.Parallel.Task:
[legend]
Collaboration diagram for GaudiMP.Parallel.Task:
[legend]

## Public Member Functions
def | __new__ (cls, *args, **kwargs)
def | initializeLocal (self)
def | initializeRemote (self)
def | process (self, item)
def | finalize (self)

## Public Attributes
| output

## Private Member Functions
def | _mergeResults (self, result)
def | _resetOutput (self)

## Static Private Attributes
bool | _initializeDone = False

## Detailed Description

    Basic base class to encapsulate any processing that is going to be porcessed in parallel.
        User class much inherit from it and implement the methods initializeLocal,
        initializeRemote, process and finalize.

Definition at line 56 of file Parallel.py.

## Member Function Documentation

## ◆ __new__()

def GaudiMP.Parallel.Task.__new__ | ( |  | cls,
|  | * | args,
|  | ** | kwargs
| ) |  |

Definition at line 62 of file Parallel.py.

62 def __new__(cls, *args, **kwargs):
63 task = object.__new__(cls)
64 task.output = ()
65 task.environ = {}
66 for k, v in os.environ.items():
67 task.environ[k] = v
68 task.cwd = os.getcwd()
69 return task
70

## ◆ _mergeResults()

def GaudiMP.Parallel.Task._mergeResults | ( |  | self,
|  |  | result
| ) |  |
| private

Definition at line 83 of file Parallel.py.

83 def _mergeResults(self, result):
84 if type(result) is not type(self.output):
85 raise TypeError("output type is not same as obtained result")
86 # --No iteratable---
87 if not hasattr(result, '__iter__'):
88 if hasattr(self.output, 'Add'):
89 self.output.Add(result)
90 elif hasattr(self.output, '__iadd__'):
91 self.output += result
92 elif hasattr(self.output, '__add__'):
93 self.output = self.output + result
94 else:
95 raise TypeError('result cannot be added')
96 # --Dictionary---
97 elif type(result) is dict:
98 if self.output.keys() <= result.keys():
99 minkeys = self.output.keys()
100 else:
101 minkeys = result.keys()
102 for key in result.keys():
103 if key in self.output:
104 if hasattr(self.output[key], 'Add'):
105 self.output[key].Add(result[key])
106 elif hasattr(self.output[key], '__iadd__'):
107 self.output[key] += result[key]
108 elif hasattr(self.output[key], '__add__'):
109 self.output[key] = self.output[key] + result[key]
110 else:
111 raise TypeError('result cannot be added')
112 else:
113 self.output[key] = result[key]
114 # --Anything else (list)
115 else:
116 for i in range(min(len(self.output), len(result))):
117 if hasattr(self.output[i], 'Add'):
118 self.output[i].Add(result[i])
119 elif hasattr(self.output[i], '__iadd__'):
120 self.output[i] += result[i]
121 elif hasattr(self.output[i], '__add__'):
122 self.output[i] = self.output[i] + result[i]
123 else:
124 raise TypeError('result cannot be added')
125
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:71
min
EventIDBase min(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:202
gaudirun.type
type
Definition: gaudirun.py:142

## ◆ _resetOutput()

def GaudiMP.Parallel.Task._resetOutput | ( |  | self | ) |
| private

Definition at line 126 of file Parallel.py.

126 def _resetOutput(self):
127 output = (type(self.output) is
128 dict) and self.output.values() or self.output
129 for o in output:
130 if hasattr(o, 'Reset'):
131 o.Reset()
132
133
gaudirun.type
type
Definition: gaudirun.py:142

## ◆ finalize()

def GaudiMP.Parallel.Task.finalize | ( |  | self | ) |

Definition at line 80 of file Parallel.py.

80 def finalize(self):
81 pass
82

## ◆ initializeLocal()

def GaudiMP.Parallel.Task.initializeLocal | ( |  | self | ) |

Definition at line 71 of file Parallel.py.

71 def initializeLocal(self):
72 pass
73

## ◆ initializeRemote()

def GaudiMP.Parallel.Task.initializeRemote | ( |  | self | ) |

Definition at line 74 of file Parallel.py.

74 def initializeRemote(self):
75 pass
76

## ◆ process()

def GaudiMP.Parallel.Task.process | ( |  | self,
|  |  | item
| ) |  |

Definition at line 77 of file Parallel.py.

77 def process(self, item):
78 pass
79

## Member Data Documentation

## ◆ _initializeDone

bool GaudiMP.Parallel.Task._initializeDone = False
| static private

Definition at line 60 of file Parallel.py.

## ◆ output

GaudiMP.Parallel.Task.output

Definition at line 93 of file Parallel.py.

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

- GaudiMP/python/GaudiMP/Parallel.py