The Gaudi Framework  master (37c0b60a)
ViewIsolationTest.py
Go to the documentation of this file.
1 #!/usr/bin/env gaudirun.py
2 
12 """
13 A test for issue 13 in gitlab.
14 Two different sets of sub-event contexts are created, and the
15 same algorithms (attached to a common control flow node) run in each
16 
17 The ViewTester is an algorithm specifically designed to create sub-event
18 contexts, pass them to the scheduler, and report on the current context.
19 
20 Five instances of ViewTester are used as follows:
21  - Algorithm A1 creates two sub-event contexts
22  - Algorithms A2 and A3 run within the sub-event contexts
23  - Algorithm A4 creates two more sub-event contexts
24  - Algorithms A2 and A3 run again, in the new contexts
25  - Algorithm A5 runs in the whole event context, after the sub-events
26 
27 """
28 
29 from Configurables import (
30  AlgResourcePool,
31  AvalancheSchedulerSvc,
32  Gaudi__Sequencer,
33  HiveSlimEventLoopMgr,
34  HiveWhiteBoard,
35  Test__ViewTester,
36 )
37 from Gaudi.Configuration import *
38 
39 # metaconfig -------------------------------------------------------------------
40 # It's confortable to collect the relevant parameters at the top of the optionfile
41 evtslots = 1
42 evtMax = 10
43 cardinality = 1
44 threads = 1
45 viewsPerEvt = 2
46 # -------------------------------------------------------------------------------
47 
48 # The configuration of the whiteboard ------------------------------------------
49 # It is useful to call it EventDataSvc to replace the usual data service with
50 # the whiteboard transparently.
51 
52 whiteboard = HiveWhiteBoard("EventDataSvc", EventSlots=evtslots)
53 
54 # -------------------------------------------------------------------------------
55 
56 # Event Loop Manager -----------------------------------------------------------
57 # It's called slim since it has less functionalities overall than the good-old
58 # event loop manager. Here we just set its outputlevel to DEBUG.
59 
60 slimeventloopmgr = HiveSlimEventLoopMgr(
61  SchedulerName="AvalancheSchedulerSvc", OutputLevel=INFO
62 )
63 
64 # -------------------------------------------------------------------------------
65 
66 # ForwardScheduler -------------------------------------------------------------
67 # We just decide how many algorithms in flight we want to have and how many
68 # threads in the pool. The default value is -1, which is for TBB equivalent
69 # to take over the whole machine.
70 
71 scheduler = AvalancheSchedulerSvc(ThreadPoolSize=threads, OutputLevel=INFO)
72 
73 # -------------------------------------------------------------------------------
74 
75 # Algo Resource Pool -----------------------------------------------------------
76 # Nothing special here, we just set the debug level.
77 AlgResourcePool(OutputLevel=INFO)
78 
79 # -------------------------------------------------------------------------------
80 
81 # Set up of the crunchers, daily business --------------------------------------
82 
83 a1 = Test__ViewTester("A1")
84 a1.baseViewName = "viewOne"
85 a1.viewNumber = viewsPerEvt
86 a1.viewNodeName = "viewNodeOne"
87 
88 a2 = Test__ViewTester("A2")
89 a2.viewNodeName = ""
90 
91 a3 = Test__ViewTester("A3")
92 a3.viewNodeName = ""
93 
94 a4 = Test__ViewTester("A4")
95 a4.baseViewName = "viewTwo"
96 a4.viewNumber = viewsPerEvt
97 a4.viewNodeName = "viewNodeTwo"
98 
99 a5 = Test__ViewTester("A5")
100 a5.viewNodeName = ""
101 
102 for algo in [a1, a2, a3, a4, a5]:
103  algo.Cardinality = cardinality
104  algo.OutputLevel = INFO
105 
106 extraNode = Gaudi__Sequencer(
107  "extraNode", Members=[a2, a3], Sequential=True, OutputLevel=INFO
108 )
109 
110 viewNodeOne = Gaudi__Sequencer(
111  "viewNodeOne",
112  Members=[extraNode],
113  Sequential=False,
114  ShortCircuit=False,
115  OutputLevel=INFO,
116 )
117 
118 viewNodeTwo = Gaudi__Sequencer(
119  "viewNodeTwo",
120  Members=[extraNode],
121  Sequential=False,
122  ShortCircuit=False,
123  OutputLevel=INFO,
124 )
125 
126 createViewSeq = Gaudi__Sequencer(
127  "createViewSeq",
128  Members=[a1, viewNodeOne, a4, viewNodeTwo, a5],
129  Sequential=True,
130  OutputLevel=INFO,
131 )
132 
133 # Application Manager ----------------------------------------------------------
134 # We put everything together and change the type of message service
135 
137  EvtMax=evtMax,
138  EvtSel="NONE",
139  ExtSvc=[whiteboard],
140  EventLoop=slimeventloopmgr,
141  TopAlg=[createViewSeq],
142  MessageSvcType="InertMessageSvc",
143 )
144 
145 # -------------------------------------------------------------------------------
Gaudi.Configuration
Definition: Configuration.py:1
ApplicationMgr
Definition: ApplicationMgr.h:57