The Gaudi Framework  v37r1 (a7f61348)
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

 _initializeDone
 

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

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

◆ _mergeResults()

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

Definition at line 95 of file Parallel.py.

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

◆ _resetOutput()

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

Definition at line 134 of file Parallel.py.

134  def _resetOutput(self):
135  output = (type(self.output) is dict) and self.output.values() or self.output
136  for o in output:
137  if hasattr(o, "Reset"):
138  o.Reset()
139 
140 

◆ finalize()

def GaudiMP.Parallel.Task.finalize (   self)

Definition at line 92 of file Parallel.py.

92  def finalize(self):
93  pass
94 

◆ initializeLocal()

def GaudiMP.Parallel.Task.initializeLocal (   self)

Definition at line 83 of file Parallel.py.

83  def initializeLocal(self):
84  pass
85 

◆ initializeRemote()

def GaudiMP.Parallel.Task.initializeRemote (   self)

Definition at line 86 of file Parallel.py.

86  def initializeRemote(self):
87  pass
88 

◆ process()

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

Definition at line 89 of file Parallel.py.

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

Member Data Documentation

◆ _initializeDone

GaudiMP.Parallel.Task._initializeDone
staticprivate

Definition at line 72 of file Parallel.py.

◆ output

GaudiMP.Parallel.Task.output

Definition at line 105 of file Parallel.py.


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