The Gaudi Framework  v36r6 (b1ee9983)
GaudiMP.GMPBase.Worker Class Reference
Inheritance diagram for GaudiMP.GMPBase.Worker:
Collaboration diagram for GaudiMP.GMPBase.Worker:

Public Member Functions

def __init__ (self, workerID, queues, events, params, subworkers)
 
def processConfiguration (self)
 
def Engine (self)
 
def getCheckAlgs (self)
 
def checkExecutedPassed (self, algName)
 
def isEventPassed (self)
 
- Public Member Functions inherited from GaudiMP.GMPBase.GMPComponent
def __init__ (self, nodeType, nodeID, queues, events, params, subworkers)
 
def Start (self)
 
def SetupGaudiPython (self)
 
def StartGaudiPython (self)
 
def LoadTES (self, tbufferfile)
 
def getEventNumber (self)
 
def IdentifyWriters (self)
 
def dumpHistograms (self)
 
def Initialize (self)
 
def Finalize (self)
 
def Report (self)
 

Public Attributes

 writerDict
 
 vetoAlgs
 
 eventOutput
 
 app
 
 filerecordsAgent
 
 nIn
 
 firstEvTime
 
 currentEvent
 
 tTime
 
- Public Attributes inherited from GaudiMP.GMPBase.GMPComponent
 nodeType
 
 finalEvent
 
 lastEvent
 
 log
 
 subworkers
 
 nodeID
 
 msgFormat
 
 currentEvent
 
 queues
 
 num
 
 app
 
 evcom
 
 evcoms
 
 hq
 
 fq
 
 nIn
 
 nOut
 
 stat
 
 iTime
 
 rTime
 
 fTime
 
 firstEvTime
 
 tTime
 
 proc
 
 a
 
 evt
 
 hvt
 
 fsr
 
 inc
 
 pers
 
 ts
 
 TS
 
 cntr
 

Detailed Description

Definition at line 1006 of file GMPBase.py.

Constructor & Destructor Documentation

◆ __init__()

def GaudiMP.GMPBase.Worker.__init__ (   self,
  workerID,
  queues,
  events,
  params,
  subworkers 
)

Definition at line 1007 of file GMPBase.py.

1007  def __init__(self, workerID, queues, events, params, subworkers):
1008  GMPComponent.__init__(
1009  self, "Worker", workerID, queues, events, params, subworkers
1010  )
1011  # Identify the writer streams
1012  self.writerDict = self.IdentifyWriters()
1013  # Identify the accept/veto checks for each event
1014  self.acceptAlgs, self.requireAlgs, self.vetoAlgs = self.getCheckAlgs()
1015  self.log.name = "Worker-%i" % (self.nodeID)
1016  self.log.info("Worker-%i Created OK" % (self.nodeID))
1017  self.eventOutput = True
1018 

Member Function Documentation

◆ checkExecutedPassed()

def GaudiMP.GMPBase.Worker.checkExecutedPassed (   self,
  algName 
)

Definition at line 1201 of file GMPBase.py.

1201  def checkExecutedPassed(self, algName):
1202  if (
1203  self.a.algorithm(algName)._ialg.isExecuted()
1204  and self.a.algorithm(algName)._ialg.filterPassed()
1205  ):
1206  return True
1207  else:
1208  return False
1209 

◆ Engine()

def GaudiMP.GMPBase.Worker.Engine (   self)

Reimplemented from GaudiMP.GMPBase.GMPComponent.

Definition at line 1060 of file GMPBase.py.

1060  def Engine(self):
1061 
1062  # rename process
1063  import ctypes
1064  import os
1065 
1066  libc = ctypes.CDLL("libc.so.6")
1067  name = str(self.nodeType) + str(self.nodeID) + "\0"
1068  libc.prctl(15, name, 0, 0, 0)
1069 
1070  startEngine = time.time()
1071  self.log.info("Worker %i starting Engine" % (self.nodeID))
1072  self.Initialize()
1073  self.filerecordsAgent = FileRecordsAgent(self)
1074 
1075  # populate the TESSerializer itemlist
1076  self.log.info("EVT WRITERS ON WORKER : %i" % (len(self.writerDict["events"])))
1077 
1078  nEventWriters = len(self.writerDict["events"])
1079  if nEventWriters:
1080  itemList = set()
1081  optItemList = set()
1082  for m in self.writerDict["events"]:
1083  for item in m.ItemList:
1084  hsh = item.find("#")
1085  if hsh != -1:
1086  item = item[:hsh]
1087  itemList.add(item)
1088  for item in m.OptItemList:
1089  hsh = item.find("#")
1090  if hsh != -1:
1091  item = item[:hsh]
1092  optItemList.add(item)
1093  # If an item is mandatory and optional, keep it only in the optional list
1094  itemList -= optItemList
1095  for item in sorted(itemList):
1096  self.log.info(" adding ItemList Item to ts : %s" % (item))
1097  self.ts.addItem(item)
1098  for item in sorted(optItemList):
1099  self.log.info(" adding Optional Item to ts : %s" % (item))
1100  self.ts.addOptItem(item)
1101  else:
1102  self.log.info("There is no Event Output for this app")
1103  self.eventOutput = False
1104 
1105  # Begin processing
1106  Go = True
1107  while Go:
1108  packet = self.evcom.receive()
1109  if packet:
1110  pass
1111  else:
1112  continue
1113  if packet == "FINISHED":
1114  break
1115  evtNumber, tbin = packet # unpack
1116  if self.cntr != None:
1117  self.cntr.setEventCounter(evtNumber)
1118 
1119  # subworkers are forked before the first event is processed
1120  if self.nIn == 0:
1121  self.log.info("Fork new subworkers")
1122 
1123  # Fork subworkers and share services
1124  for k in self.subworkers:
1125  k.SetServices(
1126  self.a,
1127  self.evt,
1128  self.hvt,
1129  self.fsr,
1130  self.inc,
1131  self.pers,
1132  self.ts,
1133  self.cntr,
1134  )
1135  k.Start()
1136  self.a.addAlgorithm(CollectHistograms(self))
1137  self.nIn += 1
1138  self.TS.Load(tbin)
1139 
1140  t = time.time()
1141  sc = self.a.executeEvent()
1142  if self.nIn == 1:
1143  self.firstEvTime = time.time() - t
1144  else:
1145  self.rTime += time.time() - t
1146  if sc.isSuccess():
1147  pass
1148  else:
1149  self.log.warning("Did not Execute Event")
1150  self.evt.clearStore()
1151  continue
1152  if self.isEventPassed():
1153  pass
1154  else:
1155  self.log.warning("Event did not pass : %i" % (evtNumber))
1156  self.evt.clearStore()
1157  continue
1158  if self.eventOutput:
1159  # It may be the case of generating Event Tags; hence
1160  # no event output
1161  self.currentEvent = self.getEventNumber()
1162  tb = self.TS.Dump()
1163  self.evcom.send((self.currentEvent, tb))
1164  self.nOut += 1
1165  self.inc.fireIncident(gbl.Incident("Worker", "EndEvent"))
1166  self.eventLoopSyncer.set()
1167  self.evt.clearStore()
1168  self.log.info("Setting <Last> Event")
1169  self.lastEvent.set()
1170 
1171  self.evcom.finalize()
1172  self.log.info("Worker-%i Finished Processing Events" % (self.nodeID))
1173  # Now send the FileRecords and stop/finalize the appMgr
1174  self.filerecordsAgent.SendFileRecords()
1175  self.Finalize()
1176  self.tTime = time.time() - startEngine
1177  self.Report()
1178 
1179  for k in self.subworkers:
1180  self.log.info("Join subworkers")
1181  k.proc.join()
1182 

◆ getCheckAlgs()

def GaudiMP.GMPBase.Worker.getCheckAlgs (   self)
For some output writers, a check is performed to see if the event has
executed certain algorithms.
These reside in the AcceptAlgs property for those writers

Definition at line 1183 of file GMPBase.py.

1183  def getCheckAlgs(self):
1184  """
1185  For some output writers, a check is performed to see if the event has
1186  executed certain algorithms.
1187  These reside in the AcceptAlgs property for those writers
1188  """
1189  acc = []
1190  req = []
1191  vet = []
1192  for m in self.writerDict["events"]:
1193  if hasattr(m.w, "AcceptAlgs"):
1194  acc += m.w.AcceptAlgs
1195  if hasattr(m.w, "RequireAlgs"):
1196  req += m.w.RequireAlgs
1197  if hasattr(m.w, "VetoAlgs"):
1198  vet += m.w.VetoAlgs
1199  return (acc, req, vet)
1200 

◆ isEventPassed()

def GaudiMP.GMPBase.Worker.isEventPassed (   self)
Check the algorithm status for an event.
Depending on output writer settings, the event
  may be declined based on various criteria.
This is a transcript of the check that occurs in GaudiSvc::OutputStream

Definition at line 1210 of file GMPBase.py.

1210  def isEventPassed(self):
1211  """
1212  Check the algorithm status for an event.
1213  Depending on output writer settings, the event
1214  may be declined based on various criteria.
1215  This is a transcript of the check that occurs in GaudiSvc::OutputStream
1216  """
1217  passed = False
1218 
1219  self.log.debug("self.acceptAlgs is %s" % (str(self.acceptAlgs)))
1220  if self.acceptAlgs:
1221  for name in self.acceptAlgs:
1222  if self.checkExecutedPassed(name):
1223  passed = True
1224  break
1225  else:
1226  passed = True
1227 
1228  self.log.debug("self.requireAlgs is %s" % (str(self.requireAlgs)))
1229  for name in self.requireAlgs:
1230  if self.checkExecutedPassed(name):
1231  pass
1232  else:
1233  self.log.info("Evt declined (requireAlgs) : %s" % (name))
1234  passed = False
1235 
1236  self.log.debug("self.vetoAlgs is %s" % (str(self.vetoAlgs)))
1237  for name in self.vetoAlgs:
1238  if self.checkExecutedPassed(name):
1239  pass
1240  else:
1241  self.log.info("Evt declined : (vetoAlgs) : %s" % (name))
1242  passed = False
1243  return passed
1244 
1245 
1246 # =============================================================================
1247 
1248 

◆ processConfiguration()

def GaudiMP.GMPBase.Worker.processConfiguration (   self)

Reimplemented from GaudiMP.GMPBase.GMPComponent.

Definition at line 1019 of file GMPBase.py.

1019  def processConfiguration(self):
1020 
1021  # Worker :
1022  # No input
1023  # No output
1024  # No Histos
1025  self.config["EventSelector"].Input = []
1026  self.config["ApplicationMgr"].OutStream = []
1027  if "HistogramPersistencySvc" in self.config.keys():
1028  self.config["HistogramPersistencySvc"].OutputFile = ""
1029  formatHead = "[Worker-%i]" % (self.nodeID)
1030  self.config["MessageSvc"].Format = "%-13s " % formatHead + self.msgFormat
1031 
1032  for key, lst in self.writerDict.iteritems():
1033  self.log.info("Writer Type : %s\t : %i" % (key, len(lst)))
1034 
1035  for m in self.writerDict["tuples"]:
1036  # rename Tuple output file with an appendix
1037  # based on worker id, for merging later
1038  newName = m.getNewName(".", ".w%i." % (self.nodeID))
1039  self.config[m.key].Output = newName
1040 
1041  # Suppress INFO Output for all but Worker-0
1042  # if self.nodeID == 0 :
1043  # pass
1044  # else :
1045  # self.config[ 'MessageSvc' ].OutputLevel = ERROR
1046 
1047  if self.app == "Gauss":
1048  try:
1049  if "ToolSvc.EvtCounter" not in self.config:
1050  from Configurables import EvtCounter
1051 
1052  counter = EvtCounter()
1053  else:
1054  counter = self.config["ToolSvc.EvtCounter"]
1055  counter.UseIncident = False
1056  except:
1057  # ignore errors when trying to change the configuration of the EvtCounter
1058  self.log.warning("Cannot configure EvtCounter")
1059 

Member Data Documentation

◆ app

GaudiMP.GMPBase.Worker.app

Definition at line 1047 of file GMPBase.py.

◆ currentEvent

GaudiMP.GMPBase.Worker.currentEvent

Definition at line 1161 of file GMPBase.py.

◆ eventOutput

GaudiMP.GMPBase.Worker.eventOutput

Definition at line 1017 of file GMPBase.py.

◆ filerecordsAgent

GaudiMP.GMPBase.Worker.filerecordsAgent

Definition at line 1073 of file GMPBase.py.

◆ firstEvTime

GaudiMP.GMPBase.Worker.firstEvTime

Definition at line 1143 of file GMPBase.py.

◆ nIn

GaudiMP.GMPBase.Worker.nIn

Definition at line 1120 of file GMPBase.py.

◆ tTime

GaudiMP.GMPBase.Worker.tTime

Definition at line 1176 of file GMPBase.py.

◆ vetoAlgs

GaudiMP.GMPBase.Worker.vetoAlgs

Definition at line 1014 of file GMPBase.py.

◆ writerDict

GaudiMP.GMPBase.Worker.writerDict

Definition at line 1012 of file GMPBase.py.


The documentation for this class was generated from the following file:
GaudiPython.Pythonizations.executeEvent
executeEvent
Helpers for re-entrant interfaces.
Definition: Pythonizations.py:584
GaudiPython.Pythonizations.iteritems
iteritems
Definition: Pythonizations.py:545
StringKeyEx.keys
list keys
Definition: StringKeyEx.py:67