ATLAS Offline Software
AlgScheduler.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
2 
3 # Configuration for the Hive Algorithm Scheduler.
4 #
5 # Allows easy low level replacement of the specific Scheduler, without
6 # requiring clients to know which one is in use.
7 #
8 # the AlgScheduler will be setup with the same number of threads
9 # as are specified on the command line with the "--threads=N" parameter
10 #
11 # usage:
12 # from AthenaCommon.AlgScheduler import AlgScheduler
13 # clients can then configure runtime printouts, threadpool, etc:
14 # AlgScheduler.ShowDataDependencies( True )
15 # AlgScheduler.ShowControlFlow( True )
16 # AlgScheduler.ShowDataFlow( True )
17 # AlgScheduler.setThreadPoolSize( 7 )
18 #
19 # if a specific scheduler lacks that option, a warning message is printed
20 # clients can also replace the default scheduler with another one
21 # from GaudiHive.GaudiHiveConf import ForwardSchedulerSvc
22 # myScheduler = ForwardSchedulerSvc()
23 # AlgScheduler.SetScheduler( myScheduler )
24 # AlgScheduler.setThreadPoolSize( 7 )
25 #
26 # if this is done, the HiveEventLoopMgr also needs to know about it
27 # from AthenaServices.AthenaServicesConf import AthenaHiveEventLoopMgr
28 # svcMgr.AthenaHiveEventLoopMgr.SchedulerSvc = AlgScheduler.getScheduler().getName()
29 #
30 
31 
33  def __init__(self,theSched=None,thePrec=None):
34  """Setup Algorithm Scheduler"""
35 
36  from AthenaCommon.AppMgr import ServiceMgr as svcMgr
37  from AthenaCommon.Constants import INFO
38 
39  from AthenaCommon.ConcurrencyFlags import jobproperties as jps
40  from AthenaCommon.Logging import logging
41 
42  self.log = logging.getLogger( 'AlgScheduler' )
43 
44  if (theSched is None) :
45  from GaudiHive.GaudiHiveConf import AvalancheSchedulerSvc
46  svcMgr += AvalancheSchedulerSvc()
47  self.SchedulerSvc = svcMgr.AvalancheSchedulerSvc
48  else :
49  svcMgr += theSched
50  self.SchedulerSvc = theSched
51 
52  if (thePrec is None) :
53  from GaudiHive.GaudiHiveConf import PrecedenceSvc
54  svcMgr += PrecedenceSvc()
55  self.PrecedenceSvc = svcMgr.PrecedenceSvc
56  else :
57  svcMgr += thePrec
58  self.PrecedenceSvc = thePrec
59 
60  self.SchedulerSvc.OutputLevel = INFO
61  self.PrecedenceSvc.OutputLevel = INFO
62  self.SchedulerSvc.CheckDependencies = True
63  self.SchedulerSvc.ThreadPoolSize = jps.ConcurrencyFlags.NumThreads()
64 
65  self.log.info("setting up " + self.SchedulerSvc.getFullName() + " with " + str(jps.ConcurrencyFlags.NumThreads()) + " threads")
66 
67 
68 #
69 
70  def SetScheduler(self,theSched):
71  """setup a different Scheduler"""
72 
73  if (self.SchedulerSvc.getFullName() != theSched.getFullName()) :
74  self.log.info("replacing " + self.SchedulerSvc.getFullName()
75  + " with " + theSched.getFullName())
76  from AthenaCommon.AppMgr import ServiceMgr as svcMgr
77  svcMgr.remove(self.SchedulerSvc)
78  svcMgr += theSched
79  self.SchedulerSvc = theSched
80 
81 #
82 
83  def OutputLevel(self,level) :
84  self.SchedulerSvc.OutputLevel = level
85  self.PrecedenceSvc.OutputLevel = level
86 
87 #
88 
89  def CheckDependencies(self,check=True):
90  if ( 'CheckDependencies' in self.SchedulerSvc.properties() ):
91  self.SchedulerSvc.CheckDependencies = check
92  else :
93  self.log.warning( self.SchedulerSvc.getFullName() + " has no property \"CheckDependencies\"")
94 
95 #
96 
97  def ShowControlFlow(self,show=True):
98  if ( 'ShowControlFlow' in self.SchedulerSvc.properties() ):
99  self.SchedulerSvc.ShowControlFlow = show
100  else :
101  self.log.warning(self.SchedulerSvc.getFullName() + " has no property \"ShowControlFlow\"")
102 
103 #
104 
105  def ShowDataFlow(self,show=True):
106  if ( 'ShowDataFlow' in self.SchedulerSvc.properties() ):
107  self.SchedulerSvc.ShowDataFlow = show
108  else :
109  self.log.warning(self.SchedulerSvc.getFullName() + " has no property \"ShowDataFlow\"")
110 
111 #
112 
113  def ShowDataDependencies(self,show=True):
114  if ( 'ShowDataDependencies' in self.SchedulerSvc.properties() ):
115  self.SchedulerSvc.ShowDataDependencies = show
116  else :
117  self.log.warning(self.SchedulerSvc.getFullName() + " has no property \"ShowDataDependencies\"")
118 
119 #
120 
121  def setDataLoaderAlg(self,dataLoadAlg):
122  if ( 'DataLoaderAlg' in self.SchedulerSvc.properties() ):
123  self.SchedulerSvc.DataLoaderAlg = dataLoadAlg
124  else :
125  self.log.warning(self.SchedulerSvc.getFullName() + " has no property \"DataLoaderAlg\"")
126 
127 #
128 
129  def EnableConditions(self,enable=True):
130  if ( 'EnableConditions' in self.SchedulerSvc.properties() ):
131  self.SchedulerSvc.EnableConditions = enable
132  else :
133  self.log.warning(self.SchedulerSvc.getFullName() + " has no property \"EnableConditions\"")
134 
135 #
136 
137  def EnableVerboseViews(self,enable=True):
138  if ( 'VerboseSubSlots' in self.SchedulerSvc.properties() ):
139  self.SchedulerSvc.VerboseSubSlots = enable
140  else :
141  self.log.warning(self.SchedulerSvc.getFullName() + " has no property \"VerboseSubSlots\"")
142 
143 #
144 
145  def setAlgRanking(self,rule="PCE"):
146  if ( 'Optimizer' in self.SchedulerSvc.properties() ):
147  self.SchedulerSvc.Optimizer = rule
148  else :
149  self.log.warning(self.SchedulerSvc.getFullName() + " has no property \"Optimizer\"")
150  if ( 'TaskPriorityRule' in self.PrecedenceSvc.properties() ):
151  self.PrecedenceSvc.TaskPriorityRule = rule
152  else :
153  self.log.warning(self.PrecedenceSvc.getFullName() + " has no property \"TaskPriorityRule\"")
154 
155 #
156 
157  def setThreadPoolSize(self,tps) :
158  self.SchedulerSvc.ThreadPoolSize = tps
159 
160 #
161 
162  def getScheduler(self):
163  """Get the Scheduler"""
164  return self.SchedulerSvc
165 
166 AlgScheduler = AlgScheduler()
grepfile.info
info
Definition: grepfile.py:38
python.AlgScheduler.AlgScheduler.PrecedenceSvc
PrecedenceSvc
Definition: AlgScheduler.py:55
python.AlgScheduler.EnableVerboseViews
def EnableVerboseViews(self, enable=True)
enable verbose view state logging
Definition: AlgScheduler.py:137
python.AlgScheduler.AlgScheduler.__init__
def __init__(self, theSched=None, thePrec=None)
Definition: AlgScheduler.py:33
python.AlgScheduler.AlgScheduler.SchedulerSvc
SchedulerSvc
Definition: AlgScheduler.py:47
python.AlgScheduler.setDataLoaderAlg
def setDataLoaderAlg(self, dataLoadAlg)
set the DataLoader Algorithm to handle unmet input data deps
Definition: AlgScheduler.py:121
python.AlgScheduler.EnableConditions
def EnableConditions(self, enable=True)
enable condition handling
Definition: AlgScheduler.py:129
python.AlgScheduler.AlgScheduler.log
log
Definition: AlgScheduler.py:42
python.AlgScheduler.setThreadPoolSize
def setThreadPoolSize(self, tps)
explicitly set the thread pool size
Definition: AlgScheduler.py:157
python.AlgScheduler.SetScheduler
def SetScheduler(self, theSched)
exchange the current scheduler for another one
Definition: AlgScheduler.py:70
python.AlgScheduler.OutputLevel
def OutputLevel(self, level)
change the output level
Definition: AlgScheduler.py:83
Constants
some useful constants -------------------------------------------------—
python.AlgScheduler.ShowDataFlow
def ShowDataFlow(self, show=True)
control printout of data flow at beginning of job
Definition: AlgScheduler.py:105
python.JsonUtils.properties
properties
Definition: JsonUtils.py:96
python.AlgScheduler.setAlgRanking
def setAlgRanking(self, rule="PCE")
set algorithm ranking rule
Definition: AlgScheduler.py:145
python.AlgScheduler.ShowControlFlow
def ShowControlFlow(self, show=True)
control printout of control flow at beginning of job
Definition: AlgScheduler.py:97
python.AlgScheduler.ShowDataDependencies
def ShowDataDependencies(self, show=True)
control printout of data dependencies at beginning of job
Definition: AlgScheduler.py:113
str
Definition: BTagTrackIpAccessor.cxx:11
python.AnaAlgSequence.getFullName
def getFullName(comp)
Definition: AnaAlgSequence.py:12
python.AlgScheduler.AlgScheduler
Definition: AlgScheduler.py:32
python.AlgScheduler.getScheduler
def getScheduler(self)
get the currently configured scheduler
Definition: AlgScheduler.py:162
python.AlgScheduler.CheckDependencies
def CheckDependencies(self, check=True)
control checking of data deps at beginning of job for unmet input deps
Definition: AlgScheduler.py:89