|
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 330 of file Main.py.
◆ __init__()
def Gaudi.Main.gaudimain.__init__ |
( |
|
self | ) |
|
Definition at line 331 of file Main.py.
332 from Configurables
import ApplicationMgr
335 if os.environ.get(
"GAUDIAPPNAME"):
336 appMgr.AppName = str(os.environ[
"GAUDIAPPNAME"])
337 if os.environ.get(
"GAUDIAPPVERSION"):
338 appMgr.AppVersion = str(os.environ[
"GAUDIAPPVERSION"])
339 self.log = logging.getLogger(__name__)
340 self.printsequence =
False
341 self.application =
"Gaudi::Application"
◆ _writepickle()
def Gaudi.Main.gaudimain._writepickle |
( |
|
self, |
|
|
|
filename |
|
) |
| |
|
private |
Definition at line 407 of file Main.py.
407 def _writepickle(self, filename):
411 output = open(filename,
"wb")
413 from GaudiKernel.Proxy.Configurable
import getNeededConfigurables
417 to_dump[n] = Configuration.allConfigurables[n]
418 pickle.dump(to_dump, output, -1)
◆ generateOptsOutput()
def Gaudi.Main.gaudimain.generateOptsOutput |
( |
|
self, |
|
|
|
all = False |
|
) |
| |
Definition at line 400 of file Main.py.
400 def generateOptsOutput(self, all=False):
◆ generatePyOutput()
def Gaudi.Main.gaudimain.generatePyOutput |
( |
|
self, |
|
|
|
all = False |
|
) |
| |
Definition at line 381 of file Main.py.
381 def generatePyOutput(self, all=False):
382 from collections
import defaultdict
383 from pprint
import pformat
385 optDict = defaultdict(dict)
388 c, p = key.rsplit(
".", 1)
389 optDict[c][p] =
parseOpt(allOpts[key])
390 formatted = pformat(dict(optDict))
398 return re.sub(
r'"\n +"',
"", formatted, flags=re.MULTILINE)
◆ hookDebugger()
def Gaudi.Main.gaudimain.hookDebugger |
( |
|
self, |
|
|
|
debugger = "gdb" |
|
) |
| |
Definition at line 479 of file Main.py.
479 def hookDebugger(self, debugger="gdb"):
482 self.log.info(
"attaching debugger to PID " + str(os.getpid()))
484 os.P_NOWAIT, debugger, [debugger,
"-q",
"python", str(os.getpid())]
493 os.waitpid(pid, os.WNOHANG)
◆ printconfig()
def Gaudi.Main.gaudimain.printconfig |
( |
|
self, |
|
|
|
old_format = False , |
|
|
|
all = False |
|
) |
| |
Definition at line 421 of file Main.py.
421 def printconfig(self, old_format=False, all=False):
422 msg =
"Dumping all configurables and properties"
424 msg +=
" (different from default)"
427 print(self.generateOptsOutput(all))
429 print(self.generatePyOutput(all))
◆ run()
def Gaudi.Main.gaudimain.run |
( |
|
self, |
|
|
|
attach_debugger, |
|
|
|
ncpus = None |
|
) |
| |
Definition at line 470 of file Main.py.
470 def run(self, attach_debugger, ncpus=None):
473 result = self.runSerial(attach_debugger)
476 result = self.runParallel(ncpus)
◆ runParallel()
def Gaudi.Main.gaudimain.runParallel |
( |
|
self, |
|
|
|
ncpus |
|
) |
| |
Definition at line 539 of file Main.py.
539 def runParallel(self, ncpus):
540 self.setupParallelLogging()
544 c = Configurable.allConfigurables
545 self.log.info(
"-" * 80)
546 self.log.info(
"%s: Parallel Mode : %i ", __name__, ncpus)
548 (
"platform",
" ".join(os.uname())),
549 (
"config", os.environ.get(
"BINARY_TAG")
or os.environ.get(
"CMTCONFIG")),
550 (
"app. name", os.environ.get(
"GAUDIAPPNAME")),
551 (
"app. version", os.environ.get(
"GAUDIAPPVERSION")),
553 self.log.info(
"%s: %30s : %s ", __name__, name, value
or "Undefined")
555 events = str(c[
"ApplicationMgr"].EvtMax)
557 events =
"Undetermined"
558 self.log.info(
"%s: Events Specified : %s ", __name__, events)
559 self.log.info(
"-" * 80)
561 Parall = gpp.Coord(ncpus, c, self.log)
564 self.log.info(
"MAIN.PY : received %s from Coordinator" % (sc))
567 sysTime =
time() - sysStart
568 self.log.name =
"Gaudi/Main.py Logger"
569 self.log.info(
"-" * 80)
571 "%s: parallel system finished, time taken: %5.4fs", __name__, sysTime
573 self.log.info(
"-" * 80)
◆ runSerial()
def Gaudi.Main.gaudimain.runSerial |
( |
|
self, |
|
|
|
attach_debugger |
|
) |
| |
Definition at line 497 of file Main.py.
497 def runSerial(self, attach_debugger):
499 from GaudiKernel.Proxy.Configurable
import expandvars
505 from GaudiKernel.Proxy.Configurable
import Configurable
507 self.log.debug(
"runSerial: apply options")
509 conf_dict[
"ApplicationMgr.JobOptionsType"] =
'"NONE"'
511 if self.printsequence:
512 conf_dict[
"ApplicationMgr.PrintAlgsSequence"] =
"true"
514 if hasattr(Configurable,
"_configurationLocked"):
515 Configurable._configurationLocked =
True
520 self.log.debug(
"-" * 80)
521 self.log.debug(
"%s: running in serial mode", __name__)
522 self.log.debug(
"-" * 80)
530 sysTime =
time() - sysStart
531 self.log.debug(
"-" * 80)
533 "%s: serial system finished, time taken: %5.4fs", __name__, sysTime
535 self.log.debug(
"-" * 80)
◆ setupParallelLogging()
def Gaudi.Main.gaudimain.setupParallelLogging |
( |
|
self | ) |
|
Definition at line 343 of file Main.py.
343 def setupParallelLogging(self):
348 import multiprocessing
351 from time
import ctime
354 datetime = datetime.replace(
" ",
"_")
355 outfile = open(
"gaudirun-%s.log" % (datetime),
"w")
357 streamhandler = logging.StreamHandler(stream=outfile)
358 console = logging.StreamHandler()
360 formatter = logging.Formatter(
361 "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
364 streamhandler.setFormatter(formatter)
365 console.setFormatter(formatter)
369 self.log = multiprocessing.log_to_stderr()
370 self.log.setLevel(logging.INFO)
371 self.log.name =
"Gaudi/Main.py Logger"
372 self.log.handlers = []
374 self.log.addHandler(streamhandler)
375 self.log.addHandler(console)
376 self.log.removeHandler(console)
378 self.log.setLevel = logging.INFO
◆ writeconfig()
def Gaudi.Main.gaudimain.writeconfig |
( |
|
self, |
|
|
|
filename, |
|
|
|
all = False |
|
) |
| |
Definition at line 432 of file Main.py.
432 def writeconfig(self, filename, all=False):
436 ".pkl":
lambda filename, all: self._writepickle(filename),
437 ".py":
lambda filename, all: open(filename,
"w").write(
438 self.generatePyOutput(all) +
"\n"
440 ".opts":
lambda filename, all: open(filename,
"w").write(
441 self.generateOptsOutput(all) +
"\n"
443 ".json":
lambda filename, all: json.dump(
444 getAllOpts(all), open(filename,
"w"), indent=2, sort_keys=
True
450 write[
".yaml"] =
lambda filename, all: yaml.safe_dump(
453 write[
".yml"] = write[
".yaml"]
457 from os.path
import splitext
459 ext = splitext(filename)[1]
461 write[ext](filename, all)
464 "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: