|
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 314 of file Main.py.
◆ __init__()
def Gaudi.Main.gaudimain.__init__ |
( |
|
self | ) |
|
Definition at line 315 of file Main.py.
316 from Configurables
import ApplicationMgr
318 if "GAUDIAPPNAME" in os.environ:
319 appMgr.AppName = str(os.environ[
"GAUDIAPPNAME"])
320 if "GAUDIAPPVERSION" in os.environ:
321 appMgr.AppVersion = str(os.environ[
"GAUDIAPPVERSION"])
322 self.log = logging.getLogger(__name__)
323 self.printsequence =
False
324 self.application =
'Gaudi::Application'
◆ _writepickle()
def Gaudi.Main.gaudimain._writepickle |
( |
|
self, |
|
|
|
filename |
|
) |
| |
|
private |
Definition at line 384 of file Main.py.
384 def _writepickle(self, filename):
387 output = open(filename,
'wb')
389 from GaudiKernel.Proxy.Configurable
import getNeededConfigurables
392 to_dump[n] = Configuration.allConfigurables[n]
393 pickle.dump(to_dump, output, -1)
◆ generateOptsOutput()
def Gaudi.Main.gaudimain.generateOptsOutput |
( |
|
self, |
|
|
|
all = False |
|
) |
| |
Definition at line 378 of file Main.py.
378 def generateOptsOutput(self, all=False):
◆ generatePyOutput()
def Gaudi.Main.gaudimain.generatePyOutput |
( |
|
self, |
|
|
|
all = False |
|
) |
| |
Definition at line 361 of file Main.py.
361 def generatePyOutput(self, all=False):
362 from pprint
import pformat
363 from collections
import defaultdict
364 optDict = defaultdict(dict)
367 c, p = key.rsplit(
'.', 1)
368 optDict[c][p] =
parseOpt(allOpts[key])
369 formatted = pformat(dict(optDict))
376 return re.sub(
r'"\n +"',
'', formatted, flags=re.MULTILINE)
◆ hookDebugger()
def Gaudi.Main.gaudimain.hookDebugger |
( |
|
self, |
|
|
|
debugger = 'gdb' |
|
) |
| |
Definition at line 432 of file Main.py.
432 def hookDebugger(self, debugger='gdb'):
434 self.log.info(
'attaching debugger to PID ' + str(os.getpid()))
435 pid = os.spawnvp(os.P_NOWAIT, debugger,
436 [debugger,
'-q',
'python',
444 os.waitpid(pid, os.WNOHANG)
◆ printconfig()
def Gaudi.Main.gaudimain.printconfig |
( |
|
self, |
|
|
|
old_format = False , |
|
|
|
all = False |
|
) |
| |
Definition at line 396 of file Main.py.
396 def printconfig(self, old_format=False, all=False):
397 msg =
'Dumping all configurables and properties'
399 msg +=
' (different from default)'
402 print(self.generateOptsOutput(all))
404 print(self.generatePyOutput(all))
◆ run()
def Gaudi.Main.gaudimain.run |
( |
|
self, |
|
|
|
attach_debugger, |
|
|
|
ncpus = None |
|
) |
| |
Definition at line 423 of file Main.py.
423 def run(self, attach_debugger, ncpus=None):
426 result = self.runSerial(attach_debugger)
429 result = self.runParallel(ncpus)
◆ runParallel()
def Gaudi.Main.gaudimain.runParallel |
( |
|
self, |
|
|
|
ncpus |
|
) |
| |
Definition at line 488 of file Main.py.
488 def runParallel(self, ncpus):
489 self.setupParallelLogging()
492 c = Configurable.allConfigurables
493 self.log.info(
'-' * 80)
494 self.log.info(
'%s: Parallel Mode : %i ', __name__, ncpus)
496 (
'platform',
' '.join(os.uname())),
497 (
'config', os.environ.get(
'BINARY_TAG')
498 or os.environ.get(
'CMTCONFIG')),
499 (
'app. name', os.environ.get(
'GAUDIAPPNAME')),
500 (
'app. version', os.environ.get(
'GAUDIAPPVERSION')),
502 self.log.info(
'%s: %30s : %s ', __name__, name, value
505 events = str(c[
'ApplicationMgr'].EvtMax)
507 events =
"Undetermined"
508 self.log.info(
'%s: Events Specified : %s ', __name__, events)
509 self.log.info(
'-' * 80)
511 Parall = gpp.Coord(ncpus, c, self.log)
514 self.log.info(
'MAIN.PY : received %s from Coordinator' % (sc))
517 sysTime =
time() - sysStart
518 self.log.name =
'Gaudi/Main.py Logger'
519 self.log.info(
'-' * 80)
520 self.log.info(
'%s: parallel system finished, time taken: %5.4fs',
522 self.log.info(
'-' * 80)
◆ runSerial()
def Gaudi.Main.gaudimain.runSerial |
( |
|
self, |
|
|
|
attach_debugger |
|
) |
| |
Definition at line 448 of file Main.py.
448 def runSerial(self, attach_debugger):
450 from GaudiKernel.Proxy.Configurable
import expandvars
456 from GaudiKernel.Proxy.Configurable
import Configurable
458 self.log.debug(
'runSerial: apply options')
460 conf_dict[
'ApplicationMgr.JobOptionsType'] =
'"NONE"'
462 if self.printsequence:
463 conf_dict[
'ApplicationMgr.PrintAlgsSequence'] =
'true'
465 if hasattr(Configurable,
"_configurationLocked"):
466 Configurable._configurationLocked =
True
471 self.log.debug(
'-' * 80)
472 self.log.debug(
'%s: running in serial mode', __name__)
473 self.log.debug(
'-' * 80)
480 sysTime =
time() - sysStart
481 self.log.debug(
'-' * 80)
482 self.log.debug(
'%s: serial system finished, time taken: %5.4fs',
484 self.log.debug(
'-' * 80)
◆ setupParallelLogging()
def Gaudi.Main.gaudimain.setupParallelLogging |
( |
|
self | ) |
|
Definition at line 326 of file Main.py.
326 def setupParallelLogging(self):
331 import multiprocessing
333 from time
import ctime
335 datetime = datetime.replace(
' ',
'_')
336 outfile = open(
'gaudirun-%s.log' % (datetime),
'w')
338 streamhandler = logging.StreamHandler(stream=outfile)
339 console = logging.StreamHandler()
341 formatter = logging.Formatter(
342 "%(asctime)s - %(name)s - %(levelname)s - %(message)s")
344 streamhandler.setFormatter(formatter)
345 console.setFormatter(formatter)
349 self.log = multiprocessing.log_to_stderr()
350 self.log.setLevel(logging.INFO)
351 self.log.name =
'Gaudi/Main.py Logger'
352 self.log.handlers = []
354 self.log.addHandler(streamhandler)
355 self.log.addHandler(console)
356 self.log.removeHandler(console)
358 self.log.setLevel = logging.INFO
◆ writeconfig()
def Gaudi.Main.gaudimain.writeconfig |
( |
|
self, |
|
|
|
filename, |
|
|
|
all = False |
|
) |
| |
Definition at line 407 of file Main.py.
407 def writeconfig(self, filename, all=False):
408 write = {
".pkl":
lambda filename, all: self._writepickle(filename),
409 ".py":
lambda filename, all: open(filename,
"w").write(self.generatePyOutput(all) +
"\n"),
410 ".opts":
lambda filename, all: open(filename,
"w").write(self.generateOptsOutput(all) +
"\n"),
412 from os.path
import splitext
413 ext = splitext(filename)[1]
415 write[ext](filename, all)
417 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: