|
def | __init__ (self) |
|
def | setupParallelLogging (self) |
|
def | generatePyOutput (self, all=False) |
|
def | generateOptsOutput (self, all=False) |
|
def | printconfig (self, old_format=False, all=False) |
|
def | writeconfig (self, filename, all=False) |
|
def | run (self, attach_debugger, ncpus=None) |
|
def | hookDebugger (self, debugger='gdb') |
|
def | runSerial (self, attach_debugger) |
|
def | runParallel (self, ncpus) |
|
Definition at line 185 of file Main.py.
◆ __init__()
def Gaudi.Main.gaudimain.__init__ |
( |
|
self | ) |
|
Definition at line 186 of file Main.py.
187 from Configurables
import ApplicationMgr
189 if "GAUDIAPPNAME" in os.environ:
190 appMgr.AppName = str(os.environ[
"GAUDIAPPNAME"])
191 if "GAUDIAPPVERSION" in os.environ:
192 appMgr.AppVersion = str(os.environ[
"GAUDIAPPVERSION"])
193 self.log = logging.getLogger(__name__)
194 self.printsequence =
False 195 self.application =
'Gaudi::Application' The Application Manager class.
◆ _writepickle()
def Gaudi.Main.gaudimain._writepickle |
( |
|
self, |
|
|
|
filename |
|
) |
| |
|
private |
Definition at line 256 of file Main.py.
256 def _writepickle(self, filename):
259 output = open(filename,
'wb')
261 from GaudiKernel.Proxy.Configurable
import getNeededConfigurables
264 to_dump[n] = Configuration.allConfigurables[n]
265 pickle.dump(to_dump, output, -1)
◆ generateOptsOutput()
def Gaudi.Main.gaudimain.generateOptsOutput |
( |
|
self, |
|
|
|
all = False |
|
) |
| |
Definition at line 244 of file Main.py.
244 def generateOptsOutput(self, all=False):
245 conf_dict = Configuration.configurationDict(all)
247 names = list(conf_dict.keys())
250 props = list(conf_dict[n].keys())
253 out.append(
'%s.%s = %s;' % (n, p,
toOpt(conf_dict[n][p])))
254 return "\n".join(out)
◆ generatePyOutput()
def Gaudi.Main.gaudimain.generatePyOutput |
( |
|
self, |
|
|
|
all = False |
|
) |
| |
Definition at line 232 of file Main.py.
232 def generatePyOutput(self, all=False):
233 from pprint
import pformat
234 conf_dict = Configuration.configurationDict(all)
235 formatted = pformat(conf_dict)
242 return re.sub(
r'"\n +"',
'', formatted, flags=re.MULTILINE)
◆ hookDebugger()
def Gaudi.Main.gaudimain.hookDebugger |
( |
|
self, |
|
|
|
debugger = 'gdb' |
|
) |
| |
Definition at line 305 of file Main.py.
305 def hookDebugger(self, debugger='gdb'):
307 self.log.info(
'attaching debugger to PID ' + str(os.getpid()))
308 pid = os.spawnvp(os.P_NOWAIT, debugger,
309 [debugger,
'-q',
'python',
317 os.waitpid(pid, os.WNOHANG)
◆ printconfig()
def Gaudi.Main.gaudimain.printconfig |
( |
|
self, |
|
|
|
old_format = False , |
|
|
|
all = False |
|
) |
| |
Definition at line 268 of file Main.py.
268 def printconfig(self, old_format=False, all=False):
269 msg =
'Dumping all configurables and properties' 271 msg +=
' (different from default)' 273 conf_dict = Configuration.configurationDict(all)
275 print(self.generateOptsOutput(all))
277 print(self.generatePyOutput(all))
◆ run()
def Gaudi.Main.gaudimain.run |
( |
|
self, |
|
|
|
attach_debugger, |
|
|
|
ncpus = None |
|
) |
| |
Definition at line 296 of file Main.py.
296 def run(self, attach_debugger, ncpus=None):
299 result = self.runSerial(attach_debugger)
302 result = self.runParallel(ncpus)
◆ runParallel()
def Gaudi.Main.gaudimain.runParallel |
( |
|
self, |
|
|
|
ncpus |
|
) |
| |
Definition at line 384 of file Main.py.
384 def runParallel(self, ncpus):
385 self.setupParallelLogging()
388 c = Configurable.allConfigurables
389 self.log.info(
'-' * 80)
390 self.log.info(
'%s: Parallel Mode : %i ', __name__, ncpus)
392 (
'platrofm',
' '.join(os.uname())),
393 (
'config', os.environ.get(
'BINARY_TAG')
394 or os.environ.get(
'CMTCONFIG')),
395 (
'app. name', os.environ.get(
'GAUDIAPPNAME')),
396 (
'app. version', os.environ.get(
'GAUDIAPPVERSION')),
398 self.log.info(
'%s: %30s : %s ', __name__, name, value
401 events = str(c[
'ApplicationMgr'].EvtMax)
403 events =
"Undetermined" 404 self.log.info(
'%s: Events Specified : %s ', __name__, events)
405 self.log.info(
'-' * 80)
407 Parall = gpp.Coord(ncpus, c, self.log)
410 self.log.info(
'MAIN.PY : received %s from Coordinator' % (sc))
413 sysTime =
time() - sysStart
414 self.log.name =
'Gaudi/Main.py Logger' 415 self.log.info(
'-' * 80)
416 self.log.info(
'%s: parallel system finished, time taken: %5.4fs',
418 self.log.info(
'-' * 80)
◆ runSerial()
def Gaudi.Main.gaudimain.runSerial |
( |
|
self, |
|
|
|
attach_debugger |
|
) |
| |
Definition at line 321 of file Main.py.
321 def runSerial(self, attach_debugger):
323 from GaudiKernel.Proxy.Configurable
import expandvars
329 from GaudiKernel.Proxy.Configurable
import Configurable, getNeededConfigurables
331 self.log.debug(
'runSerial: apply options')
332 conf_dict = {
'ApplicationMgr.JobOptionsType':
'"NONE"'}
336 for c
in list(Configurable.allConfigurables.values()):
337 if hasattr(c,
'getValuedProperties'):
338 c.getValuedProperties()
341 c = Configurable.allConfigurables[n]
342 for p, v
in c.getValuedProperties().
items():
345 if hasattr(Configurable,
"PropertyReference")
and type(
346 v) == Configurable.PropertyReference:
352 v =
'"%s"' % v.replace(
'"',
'\\"')
353 elif sys.version_info < (
354 3, )
and type(v) == long:
356 conf_dict[
'{}.{}'.
format(n, p)] = str(v)
358 if self.printsequence:
359 conf_dict[
'ApplicationMgr.PrintAlgsSequence'] =
'true' 361 if hasattr(Configurable,
"_configurationLocked"):
362 Configurable._configurationLocked =
True 367 self.log.debug(
'-' * 80)
368 self.log.debug(
'%s: running in serial mode', __name__)
369 self.log.debug(
'-' * 80)
376 sysTime =
time() - sysStart
377 self.log.debug(
'-' * 80)
378 self.log.debug(
'%s: serial system finished, time taken: %5.4fs',
380 self.log.debug(
'-' * 80)
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
def create(cls, appType, opts)
◆ setupParallelLogging()
def Gaudi.Main.gaudimain.setupParallelLogging |
( |
|
self | ) |
|
Definition at line 197 of file Main.py.
197 def setupParallelLogging(self):
202 import multiprocessing
204 from time
import ctime
206 datetime = datetime.replace(
' ',
'_')
207 outfile = open(
'gaudirun-%s.log' % (datetime),
'w')
209 streamhandler = logging.StreamHandler(stream=outfile)
210 console = logging.StreamHandler()
212 formatter = logging.Formatter(
213 "%(asctime)s - %(name)s - %(levelname)s - %(message)s")
215 streamhandler.setFormatter(formatter)
216 console.setFormatter(formatter)
220 self.log = multiprocessing.log_to_stderr()
221 self.log.setLevel(logging.INFO)
222 self.log.name =
'Gaudi/Main.py Logger' 223 self.log.handlers = []
225 self.log.addHandler(streamhandler)
226 self.log.addHandler(console)
227 self.log.removeHandler(console)
229 self.log.setLevel = logging.INFO
◆ writeconfig()
def Gaudi.Main.gaudimain.writeconfig |
( |
|
self, |
|
|
|
filename, |
|
|
|
all = False |
|
) |
| |
Definition at line 280 of file Main.py.
280 def writeconfig(self, filename, all=False):
281 write = {
".pkl":
lambda filename, all: self._writepickle(filename),
282 ".py":
lambda filename, all: open(filename,
"w").write(self.generatePyOutput(all) +
"\n"),
283 ".opts":
lambda filename, all: open(filename,
"w").write(self.generateOptsOutput(all) +
"\n"),
285 from os.path
import splitext
286 ext = splitext(filename)[1]
288 write[ext](filename, all)
290 log.error(
"Unknown file type '%s'. Must be any of %r.", ext,
◆ application
Gaudi.Main.gaudimain.application |
◆ log
◆ printsequence
Gaudi.Main.gaudimain.printsequence |
The documentation for this class was generated from the following file: