Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Preparation.py
Go to the documentation of this file.
1 
2 import AthenaCommon.Include as AthCIncMod
3 if opts.showincludes:
4  AthCIncMod.marker = ' -#-' # distinguish bootstrap from other jo-code
5 
6 
7 if opts.interactive:
8  from AthenaCommon.Interactive import configureInteractivePrompt
10  del configureInteractivePrompt
11 
12 
13 from AthenaCommon.Debugging import hookDebugger, allowPtrace
15 
16 
17 from AthenaCommon.Configurable import *
18 
19 
20 from AthenaCommon.Constants import *
21 # namespace these constants: Lvl.INFO
22 # so we can write e.g: Units.GeV
23 import AthenaCommon.Constants as Lvl
24 import AthenaCommon.SystemOfUnits as Units
25 
26 
27 from AthenaCommon import CfgMgr
28 from AthenaCommon.AppMgr import ( athAlgSeq, theApp, ToolSvc, theAuditorSvc,
29  ServiceMgr, ServiceMgr as svcMgr )
30 from AthenaCommon.Logging import log
31 
32 # load all entries so far into the workspace of include()
33 
34 if opts.interactive: # i.e. interactive
35  theApp.EventLoop = "PyAthenaEventLoopMgr" # from AthenaServices
36 
37 
38 theApp.setOutputLevel( globals()[opts.loglevel] )
39 theApp._opts = opts # FIXME
40 
41 
42 if not "POOL_OUTMSG_LEVEL" in os.environ:
43  os.environ[ "POOL_OUTMSG_LEVEL" ] = str(globals()[opts.loglevel])
44 
45 
46 import AthenaCommon.AtlasUnixStandardJob
47 
48 from PyUtils.Helpers import ROOT6Setup
49 ROOT6Setup(batch=not opts.interactive)
50 # Make sure that batch mode gets set properly.
51 # ROOT6Setup will set things up so that whenever we do an `import ROOT',
52 # then gROOT.SetBatch will be called properly.
53 # However, if someone instead writes `from ROOT import gSystem'
54 # (or anything other than gROOT), then the ROOT python update thread
55 # will be started before ROOT6Setup calls SetBatch.
56 # (This was then problematic for some MP jobs which used python
57 # algorithms.)
58 # So include the import here explictly to ensure that batch mode gets set.
59 # The following call to SetBatch is strictly redundant, but included
60 # for clarity.
61 import ROOT
62 ROOT.gROOT.SetBatch(not opts.interactive)
63 
64 
65 
69 
70 
71 from AthenaCommon.Include import IncludeError
72 try:
73  include( "$HOME/.athenarc" )
74 except IncludeError:
75  pass
76 
77 
78 from AthenaCommon.ResourceLimits import SetMaxLimits
80 del SetMaxLimits
81 del sys.modules[ 'AthenaCommon.ResourceLimits' ]
82 
83 
84 if opts.interactive:
85  import atexit
86 
87  # finalize on exit (^D)
88  atexit.register( theApp.exit )
89 
90  del atexit
91 
92 if opts.command:
93  _msg.info( 'executing CLI (-c) command: "%s"' % opts.command )
94  exec (opts.command)
95 
96 if DbgStage.value == "conf":
97  hookDebugger()
98 
99 if opts.showincludes:
100  AthCIncMod.marker = AthCIncMod.__marker__ # reset
101 del AthCIncMod
102 
103 if opts.do_leak_chk:
104  from Hephaestus.Auditor import HephaestusAuditor
105  theApp.AuditAlgorithms = True
106  svcMgr.AuditorSvc += HephaestusAuditor(
107  mode = opts.memchk_mode, auditOn = opts.do_leak_chk )
108 
109 
110 
111 from AthenaCommon.ConcurrencyFlags import jobproperties as jps
112 if opts.nprocs and (opts.nprocs >= 1 or opts.nprocs==-1):
113  jps.ConcurrencyFlags.NumProcs = opts.nprocs
114  _msg.info ("configuring AthenaMP with [%s] sub-workers",
115  jps.ConcurrencyFlags.NumProcs())
116 
117  if (opts.debug_worker is True) :
118  jps.ConcurrencyFlags.DebugWorkers = True
119  _msg.info (" Workers will pause after fork until SIGUSR1 signal received")
120 
121 if (opts.threads or opts.concurrent_events) :
122 
123  if (opts.threads is None and opts.concurrent_events is not None) :
124 
125  jps.ConcurrencyFlags.NumThreads = opts.concurrent_events
126  jps.ConcurrencyFlags.NumConcurrentEvents = opts.concurrent_events
127  elif (opts.threads is not None and opts.concurrent_events is None) :
128 
129  jps.ConcurrencyFlags.NumThreads = opts.threads
130  jps.ConcurrencyFlags.NumConcurrentEvents = opts.threads
131  else :
132 
133  jps.ConcurrencyFlags.NumThreads = opts.threads
134  jps.ConcurrencyFlags.NumConcurrentEvents = opts.concurrent_events
135 
136 
137  if (jps.ConcurrencyFlags.NumProcs() > 0) :
138  _msg.info ("configuring hybrid AthenaMP/AthenaMT with [%s] concurrent threads and [%s] concurrent events per AthenaMP worker", jps.ConcurrencyFlags.NumThreads, jps.ConcurrencyFlags.NumConcurrentEvents)
139  elif (jps.ConcurrencyFlags.NumProcs() == 0) :
140  _msg.info ("configuring AthenaHive with [%s] concurrent threads and [%s] concurrent events", jps.ConcurrencyFlags.NumThreads(), jps.ConcurrencyFlags.NumConcurrentEvents())
141  else:
142  # we should never get here
143  _msg.error ("ConcurrencyFlags.NumProcs() cannot == -1 !!")
144  sys.exit()
145 
146  import AthenaCommon.AtlasThreadedJob
SystemOfUnits
python.ResourceLimits.SetMaxLimits
def SetMaxLimits()
max out soft resource limits to hard ones -----------------------------—
Definition: ResourceLimits.py:57
python.Debugging.allowPtrace
def allowPtrace()
Definition: Debugging.py:68
Constants
some useful constants -------------------------------------------------—
python.Helpers.ROOT6Setup
def ROOT6Setup(batch=False)
Definition: Tools/PyUtils/python/Helpers.py:19
Configurable
athena/gaudi ----------------------------------------------------------—
python.Interactive.configureInteractivePrompt
def configureInteractivePrompt(completionDict=None)
Definition: Interactive.py:80
python.Include.include
include
Definition: Include.py:318
str
Definition: BTagTrackIpAccessor.cxx:11
python.Debugging.hookDebugger
def hookDebugger()
Definition: Debugging.py:22