|
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 323 of file Main.py.
◆ __init__()
def Gaudi.Main.gaudimain.__init__ |
( |
|
self | ) |
|
Definition at line 324 of file Main.py.
325 from Configurables
import ApplicationMgr
328 if os.environ.get(
"GAUDIAPPNAME"):
329 appMgr.AppName = str(os.environ[
"GAUDIAPPNAME"])
330 if os.environ.get(
"GAUDIAPPVERSION"):
331 appMgr.AppVersion = str(os.environ[
"GAUDIAPPVERSION"])
332 self.log = logging.getLogger(__name__)
333 self.printsequence =
False
334 self.application =
"Gaudi::Application"
◆ _writepickle()
def Gaudi.Main.gaudimain._writepickle |
( |
|
self, |
|
|
|
filename |
|
) |
| |
|
private |
Definition at line 396 of file Main.py.
396 def _writepickle(self, filename):
400 output = open(filename,
"wb")
402 from GaudiKernel.Proxy.Configurable
import getNeededConfigurables
406 to_dump[n] = Configuration.allConfigurables[n]
407 pickle.dump(to_dump, output, -1)
◆ generateOptsOutput()
def Gaudi.Main.gaudimain.generateOptsOutput |
( |
|
self, |
|
|
|
all = False |
|
) |
| |
Definition at line 389 of file Main.py.
389 def generateOptsOutput(self, all=False):
◆ generatePyOutput()
def Gaudi.Main.gaudimain.generatePyOutput |
( |
|
self, |
|
|
|
all = False |
|
) |
| |
Definition at line 374 of file Main.py.
374 def generatePyOutput(self, all=False):
376 from collections
import defaultdict
377 from pprint
import pformat
379 optDict = defaultdict(dict)
382 c, p = key.rsplit(
".", 1)
383 optDict[c][p] =
parseOpt(allOpts[key])
384 formatted = pformat(dict(optDict))
387 return re.sub(
r'"\n +"',
"", formatted, flags=re.MULTILINE)
◆ hookDebugger()
def Gaudi.Main.gaudimain.hookDebugger |
( |
|
self, |
|
|
|
debugger = "gdb" |
|
) |
| |
Definition at line 468 of file Main.py.
468 def hookDebugger(self, debugger="gdb"):
471 self.log.info(
"attaching debugger to PID " + str(os.getpid()))
473 os.P_NOWAIT, debugger, [debugger,
"-q",
"python", str(os.getpid())]
482 os.waitpid(pid, os.WNOHANG)
◆ printconfig()
def Gaudi.Main.gaudimain.printconfig |
( |
|
self, |
|
|
|
old_format = False , |
|
|
|
all = False |
|
) |
| |
Definition at line 410 of file Main.py.
410 def printconfig(self, old_format=False, all=False):
411 msg =
"Dumping all configurables and properties"
413 msg +=
" (different from default)"
416 print(self.generateOptsOutput(all))
418 print(self.generatePyOutput(all))
◆ run()
def Gaudi.Main.gaudimain.run |
( |
|
self, |
|
|
|
attach_debugger, |
|
|
|
ncpus = None |
|
) |
| |
Definition at line 459 of file Main.py.
459 def run(self, attach_debugger, ncpus=None):
462 result = self.runSerial(attach_debugger)
465 result = self.runParallel(ncpus)
◆ runParallel()
def Gaudi.Main.gaudimain.runParallel |
( |
|
self, |
|
|
|
ncpus |
|
) |
| |
Definition at line 528 of file Main.py.
528 def runParallel(self, ncpus):
529 self.setupParallelLogging()
533 c = Configurable.allConfigurables
534 self.log.info(
"-" * 80)
535 self.log.info(
"%s: Parallel Mode : %i ", __name__, ncpus)
537 (
"platform",
" ".join(os.uname())),
538 (
"config", os.environ.get(
"BINARY_TAG")
or os.environ.get(
"CMTCONFIG")),
539 (
"app. name", os.environ.get(
"GAUDIAPPNAME")),
540 (
"app. version", os.environ.get(
"GAUDIAPPVERSION")),
542 self.log.info(
"%s: %30s : %s ", __name__, name, value
or "Undefined")
544 events = str(c[
"ApplicationMgr"].EvtMax)
546 events =
"Undetermined"
547 self.log.info(
"%s: Events Specified : %s ", __name__, events)
548 self.log.info(
"-" * 80)
550 Parall = gpp.Coord(ncpus, c, self.log)
553 self.log.info(
"MAIN.PY : received %s from Coordinator" % (sc))
556 sysTime =
time() - sysStart
557 self.log.name =
"Gaudi/Main.py Logger"
558 self.log.info(
"-" * 80)
560 "%s: parallel system finished, time taken: %5.4fs", __name__, sysTime
562 self.log.info(
"-" * 80)
◆ runSerial()
def Gaudi.Main.gaudimain.runSerial |
( |
|
self, |
|
|
|
attach_debugger |
|
) |
| |
Definition at line 486 of file Main.py.
486 def runSerial(self, attach_debugger):
488 from GaudiKernel.Proxy.Configurable
import expandvars
494 from GaudiKernel.Proxy.Configurable
import Configurable
496 self.log.debug(
"runSerial: apply options")
498 conf_dict[
"ApplicationMgr.JobOptionsType"] =
'"NONE"'
500 if self.printsequence:
501 conf_dict[
"ApplicationMgr.PrintAlgsSequence"] =
"true"
503 if hasattr(Configurable,
"_configurationLocked"):
504 Configurable._configurationLocked =
True
509 self.log.debug(
"-" * 80)
510 self.log.debug(
"%s: running in serial mode", __name__)
511 self.log.debug(
"-" * 80)
519 sysTime =
time() - sysStart
520 self.log.debug(
"-" * 80)
522 "%s: serial system finished, time taken: %5.4fs", __name__, sysTime
524 self.log.debug(
"-" * 80)
◆ setupParallelLogging()
def Gaudi.Main.gaudimain.setupParallelLogging |
( |
|
self | ) |
|
Definition at line 336 of file Main.py.
336 def setupParallelLogging(self):
341 import multiprocessing
344 from time
import ctime
347 datetime = datetime.replace(
" ",
"_")
348 outfile = open(
"gaudirun-%s.log" % (datetime),
"w")
350 streamhandler = logging.StreamHandler(stream=outfile)
351 console = logging.StreamHandler()
353 formatter = logging.Formatter(
354 "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
357 streamhandler.setFormatter(formatter)
358 console.setFormatter(formatter)
362 self.log = multiprocessing.log_to_stderr()
363 self.log.setLevel(logging.INFO)
364 self.log.name =
"Gaudi/Main.py Logger"
365 self.log.handlers = []
367 self.log.addHandler(streamhandler)
368 self.log.addHandler(console)
369 self.log.removeHandler(console)
371 self.log.setLevel = logging.INFO
◆ writeconfig()
def Gaudi.Main.gaudimain.writeconfig |
( |
|
self, |
|
|
|
filename, |
|
|
|
all = False |
|
) |
| |
Definition at line 421 of file Main.py.
421 def writeconfig(self, filename, all=False):
425 ".pkl":
lambda filename, all: self._writepickle(filename),
426 ".py":
lambda filename, all: open(filename,
"w").write(
427 self.generatePyOutput(all) +
"\n"
429 ".opts":
lambda filename, all: open(filename,
"w").write(
430 self.generateOptsOutput(all) +
"\n"
432 ".json":
lambda filename, all: json.dump(
433 getAllOpts(all), open(filename,
"w"), indent=2, sort_keys=
True
439 write[
".yaml"] =
lambda filename, all: yaml.safe_dump(
442 write[
".yml"] = write[
".yaml"]
446 from os.path
import splitext
448 ext = splitext(filename)[1]
450 write[ext](filename, all)
453 "Unknown file type '%s'. Must be any of %r.", ext, sorted(write.keys())
◆ application
Gaudi.Main.gaudimain.application |
◆ log
◆ printsequence
Gaudi.Main.gaudimain.printsequence |
The documentation for this class was generated from the following file: