The Gaudi Framework  v36r1 (3e2fb5a8)
GaudiMP.Parallel.Task Class Reference
Inheritance diagram for GaudiMP.Parallel.Task:
Collaboration diagram for GaudiMP.Parallel.Task:

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 67 of file Parallel.py.

Member Function Documentation

◆ __new__()

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

Definition at line 73 of file Parallel.py.

73  def __new__(cls, *args, **kwargs):
74  task = object.__new__(cls)
75  task.output = ()
76  task.environ = {}
77  for k, v in os.environ.items():
78  task.environ[k] = v
79  task.cwd = os.getcwd()
80  return task
81 

◆ _mergeResults()

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

Definition at line 94 of file Parallel.py.

94  def _mergeResults(self, result):
95  if type(result) is not type(self.output):
96  raise TypeError("output type is not same as obtained result")
97  # --No iteratable---
98  if not hasattr(result, '__iter__'):
99  if hasattr(self.output, 'Add'):
100  self.output.Add(result)
101  elif hasattr(self.output, '__iadd__'):
102  self.output += result
103  elif hasattr(self.output, '__add__'):
104  self.output = self.output + result
105  else:
106  raise TypeError('result cannot be added')
107  # --Dictionary---
108  elif type(result) is dict:
109  if self.output.keys() <= result.keys():
110  minkeys = self.output.keys()
111  else:
112  minkeys = result.keys()
113  for key in result.keys():
114  if key in self.output:
115  if hasattr(self.output[key], 'Add'):
116  self.output[key].Add(result[key])
117  elif hasattr(self.output[key], '__iadd__'):
118  self.output[key] += result[key]
119  elif hasattr(self.output[key], '__add__'):
120  self.output[key] = self.output[key] + result[key]
121  else:
122  raise TypeError('result cannot be added')
123  else:
124  self.output[key] = result[key]
125  # --Anything else (list)
126  else:
127  for i in range(min(len(self.output), len(result))):
128  if hasattr(self.output[i], 'Add'):
129  self.output[i].Add(result[i])
130  elif hasattr(self.output[i], '__iadd__'):
131  self.output[i] += result[i]
132  elif hasattr(self.output[i], '__add__'):
133  self.output[i] = self.output[i] + result[i]
134  else:
135  raise TypeError('result cannot be added')
136 

◆ _resetOutput()

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

Definition at line 137 of file Parallel.py.

137  def _resetOutput(self):
138  output = (type(self.output) is
139  dict) and self.output.values() or self.output
140  for o in output:
141  if hasattr(o, 'Reset'):
142  o.Reset()
143 
144 

◆ finalize()

def GaudiMP.Parallel.Task.finalize (   self)

Definition at line 91 of file Parallel.py.

91  def finalize(self):
92  pass
93 

◆ initializeLocal()

def GaudiMP.Parallel.Task.initializeLocal (   self)

Definition at line 82 of file Parallel.py.

82  def initializeLocal(self):
83  pass
84 

◆ initializeRemote()

def GaudiMP.Parallel.Task.initializeRemote (   self)

Definition at line 85 of file Parallel.py.

85  def initializeRemote(self):
86  pass
87 

◆ process()

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

Definition at line 88 of file Parallel.py.

88  def process(self, item):
89  pass
90 

Member Data Documentation

◆ _initializeDone

bool GaudiMP.Parallel.Task._initializeDone = False
staticprivate

Definition at line 71 of file Parallel.py.

◆ output

GaudiMP.Parallel.Task.output

Definition at line 104 of file Parallel.py.


The documentation for this class was generated from the following file:
min
EventIDBase min(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:212
gaudirun.type
type
Definition: gaudirun.py:154
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:97
StringKeyEx.keys
list keys
Definition: StringKeyEx.py:67