The Gaudi Framework  v36r9p1 (5c15b2bb)
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 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 type(result) is not 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  if self.output.keys() <= result.keys():
111  minkeys = self.output.keys()
112  else:
113  minkeys = result.keys()
114  for key in result.keys():
115  if key in self.output:
116  if hasattr(self.output[key], "Add"):
117  self.output[key].Add(result[key])
118  elif hasattr(self.output[key], "__iadd__"):
119  self.output[key] += result[key]
120  elif hasattr(self.output[key], "__add__"):
121  self.output[key] = self.output[key] + result[key]
122  else:
123  raise TypeError("result cannot be added")
124  else:
125  self.output[key] = result[key]
126  # --Anything else (list)
127  else:
128  for i in range(min(len(self.output), len(result))):
129  if hasattr(self.output[i], "Add"):
130  self.output[i].Add(result[i])
131  elif hasattr(self.output[i], "__iadd__"):
132  self.output[i] += result[i]
133  elif hasattr(self.output[i], "__add__"):
134  self.output[i] = self.output[i] + result[i]
135  else:
136  raise TypeError("result cannot be added")
137 

◆ _resetOutput()

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

Definition at line 138 of file Parallel.py.

138  def _resetOutput(self):
139  output = (type(self.output) is 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 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

bool GaudiMP.Parallel.Task._initializeDone = False
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:545
min
EventIDBase min(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:212
gaudirun.type
type
Definition: gaudirun.py:160
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:102
StringKeyEx.keys
list keys
Definition: StringKeyEx.py:67