The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
GaudiMP.GMPBase.Subworker Class Reference
Inheritance diagram for GaudiMP.GMPBase.Subworker:
Collaboration diagram for GaudiMP.GMPBase.Subworker:

Public Member Functions

 __init__ (self, workerID, queues, events, params, subworkers)
 Engine (self)
 SetServices (self, a, evt, hvt, fsr, inc, pers, ts, cntr)
 getCheckAlgs (self)
 checkExecutedPassed (self, algName)
 isEventPassed (self)
Public Member Functions inherited from GaudiMP.GMPBase.GMPComponent
 __init__ (self, nodeType, nodeID, queues, events, params, subworkers)
 Start (self)
 processConfiguration (self)
 SetupGaudiPython (self)
 StartGaudiPython (self)
 LoadTES (self, tbufferfile)
 getEventNumber (self)
 IdentifyWriters (self)
 dumpHistograms (self)
 Initialize (self)
 Finalize (self)
 Report (self)

Public Attributes

 writerDict = self.IdentifyWriters()
 acceptAlgs
 requireAlgs
 vetoAlgs = self.getCheckAlgs()
bool eventOutput = True
 filerecordsAgent = FileRecordsAgent(self)
Public Attributes inherited from GaudiMP.GMPBase.GMPComponent
str nodeType = nodeType
 initEvent
 finalEvent = events
 eventLoopSyncer
 lastEvent = eventLoopSyncer
 nWorkers
 sEvent
 config
 log = params
 subworkers = subworkers
int nodeID = nodeID
 msgFormat = self.config["MessageSvc"].Format
 currentEvent = None
 queues = queues
int num = 0
str app = None
 evcom = EventCommunicator(self, qin, qout)
list evcoms = []
 hq = histq
 fq = fq
int nIn = 0
int nOut = 0
 stat = SUCCESS
float iTime = 0.0
float rTime = 0.0
float fTime = 0.0
float firstEvTime = 0.0
float tTime = 0.0
 proc = Process(target=self.Engine)
 a = AppMgr()
 evt = self.a.evtsvc()
 hvt = self.a.histsvc()
 fsr = self.a.filerecordsvc()
 inc = self.a.service("IncidentSvc", "IIncidentSvc")
 pers = self.a.service("EventPersistencySvc", "IAddressCreator")
 ts = gbl.GaudiMP.TESSerializer(self.evt._idp, self.pers)
 TS = TESSerializer(self.ts, self.evt, self.nodeType, self.nodeID, self.log)
 cntr = InterfaceCast(gbl.IEventCounter)(tool.getInterface())

Detailed Description

Definition at line 825 of file GMPBase.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 826 of file GMPBase.py.

826 def __init__(self, workerID, queues, events, params, subworkers):
827 GMPComponent.__init__(
828 self, "Worker", workerID, queues, events, params, subworkers
829 )
830 # Identify the writer streams
831 self.writerDict = self.IdentifyWriters()
832 # Identify the accept/veto checks for each event
833 self.acceptAlgs, self.requireAlgs, self.vetoAlgs = self.getCheckAlgs()
834 self.log.info(f"Subworker-{self.nodeID} Created OK")
835 self.eventOutput = True
836

Member Function Documentation

◆ checkExecutedPassed()

GaudiMP.GMPBase.Subworker.checkExecutedPassed ( self,
algName )

Definition at line 948 of file GMPBase.py.

948 def checkExecutedPassed(self, algName):
949 if (
950 self.a.algorithm(algName)._ialg.isExecuted()
951 and self.a.algorithm(algName)._ialg.filterPassed()
952 ):
953 return True
954 else:
955 return False
956

◆ Engine()

GaudiMP.GMPBase.Subworker.Engine ( self)

Reimplemented from GaudiMP.GMPBase.GMPComponent.

Definition at line 837 of file GMPBase.py.

837 def Engine(self):
838 # rename process
839 import ctypes
840
841 libc = ctypes.CDLL("libc.so.6")
842 name = str(self.nodeType) + str(self.nodeID) + "\0"
843 libc.prctl(15, ctypes.create_unicode_buffer(name), 0, 0, 0)
844
845 self.initEvent.set()
846 startEngine = time.time()
847 msg = self.a.service("MessageSvc")
848 msg.Format = "{:<13s} ".format(f"[{self.log.name}]") + self.msgFormat
849
850 self.log.name = f"Worker-{self.nodeID}"
851 self.log.info(f"Subworker {self.nodeID} starting Engine")
852 self.filerecordsAgent = FileRecordsAgent(self)
853
854 # populate the TESSerializer itemlist
855 self.log.info(f"EVT WRITERS ON WORKER : {len(self.writerDict['events'])}")
856
857 self.a.addAlgorithm(CollectHistograms(self))
858
859 # Begin processing
860 Go = True
861 while Go:
862 packet = self.evcom.receive()
863 if packet:
864 pass
865 else:
866 continue
867 if packet == "FINISHED":
868 break
869 evtNumber, tbin = packet # unpack
870 if self.cntr != cppyy.nullptr:
871 self.cntr.setEventCounter(evtNumber)
872
873 self.nIn += 1
874 self.TS.Load(tbin)
875
876 t = time.time()
877 sc = self.a.executeEvent()
878 if self.nIn == 1:
879 self.firstEvTime = time.time() - t
880 else:
881 self.rTime += time.time() - t
882 if sc.isSuccess():
883 pass
884 else:
885 self.log.name = f"Worker-{self.nodeID}"
886 self.log.warning("Did not Execute Event")
887 self.evt.clearStore()
888 continue
889 if self.isEventPassed():
890 pass
891 else:
892 self.log.name = f"Worker-{self.nodeID}"
893 self.log.warning(f"Event did not pass : {evtNumber}")
894 self.evt.clearStore()
895 continue
896 if self.eventOutput:
897 # It may be the case of generating Event Tags; hence
898 # no event output
899 self.currentEvent = self.getEventNumber()
900 tb = self.TS.Dump()
901 self.evcom.send((self.currentEvent, tb))
902 self.nOut += 1
903 self.inc.fireIncident(gbl.Incident("Subworker", "EndEvent"))
904 self.eventLoopSyncer.set()
905 self.evt.clearStore()
906 self.log.name = f"Worker-{self.nodeID}"
907 self.log.info(f"Setting <Last> Event {self.nodeID}")
908 self.lastEvent.set()
909
910 self.evcom.finalize()
911 # Now send the FileRecords and stop/finalize the appMgr
912 self.filerecordsAgent.SendFileRecords()
913 self.tTime = time.time() - startEngine
914 self.Finalize()
915 self.Report()
916 # self.finalEvent.set()
917
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition MsgStream.cpp:93

◆ getCheckAlgs()

GaudiMP.GMPBase.Subworker.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 930 of file GMPBase.py.

930 def getCheckAlgs(self):
931 """
932 For some output writers, a check is performed to see if the event has
933 executed certain algorithms.
934 These reside in the AcceptAlgs property for those writers
935 """
936 acc = []
937 req = []
938 vet = []
939 for m in self.writerDict["events"]:
940 if hasattr(m.w, "AcceptAlgs"):
941 acc += m.w.AcceptAlgs
942 if hasattr(m.w, "RequireAlgs"):
943 req += m.w.RequireAlgs
944 if hasattr(m.w, "VetoAlgs"):
945 vet += m.w.VetoAlgs
946 return (acc, req, vet)
947

◆ isEventPassed()

GaudiMP.GMPBase.Subworker.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 957 of file GMPBase.py.

957 def isEventPassed(self):
958 """
959 Check the algorithm status for an event.
960 Depending on output writer settings, the event
961 may be declined based on various criteria.
962 This is a transcript of the check that occurs in GaudiSvc::OutputStream
963 """
964 passed = False
965
966 self.log.debug(f"self.acceptAlgs is {self.acceptAlgs}")
967 if self.acceptAlgs:
968 for name in self.acceptAlgs:
969 if self.checkExecutedPassed(name):
970 passed = True
971 break
972 else:
973 passed = True
974
975 self.log.debug(f"self.requireAlgs is {self.requireAlgs}")
976 for name in self.requireAlgs:
977 if self.checkExecutedPassed(name):
978 pass
979 else:
980 self.log.info(f"Evt declined (requireAlgs) : {name}")
981 passed = False
982
983 self.log.debug(f"self.vetoAlgs is {self.vetoAlgs}")
984 for name in self.vetoAlgs:
985 if self.checkExecutedPassed(name):
986 pass
987 else:
988 self.log.info(f"Evt declined : (vetoAlgs) : {name}")
989 passed = False
990 return passed
991
992
993# =============================================================================
994
995

◆ SetServices()

GaudiMP.GMPBase.Subworker.SetServices ( self,
a,
evt,
hvt,
fsr,
inc,
pers,
ts,
cntr )

Definition at line 918 of file GMPBase.py.

918 def SetServices(self, a, evt, hvt, fsr, inc, pers, ts, cntr):
919 self.a = a
920 self.evt = evt
921 self.hvt = hvt
922 self.fsr = fsr
923 # self.inc = inc
924 self.inc = self.a.service("IncidentSvc", "IIncidentSvc")
925 self.pers = pers
926 self.ts = ts
927 self.cntr = cntr
928 self.TS = TESSerializer(self.ts, self.evt, self.nodeType, self.nodeID, self.log)
929

Member Data Documentation

◆ acceptAlgs

GaudiMP.GMPBase.Subworker.acceptAlgs

Definition at line 833 of file GMPBase.py.

◆ eventOutput

bool GaudiMP.GMPBase.Subworker.eventOutput = True

Definition at line 835 of file GMPBase.py.

◆ filerecordsAgent

GaudiMP.GMPBase.Subworker.filerecordsAgent = FileRecordsAgent(self)

Definition at line 852 of file GMPBase.py.

◆ requireAlgs

GaudiMP.GMPBase.Subworker.requireAlgs

Definition at line 833 of file GMPBase.py.

◆ vetoAlgs

GaudiMP.GMPBase.Subworker.vetoAlgs = self.getCheckAlgs()

Definition at line 833 of file GMPBase.py.

◆ writerDict

GaudiMP.GMPBase.Subworker.writerDict = self.IdentifyWriters()

Definition at line 831 of file GMPBase.py.


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