|
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 326 of file Main.py.
◆ __init__()
def Gaudi.Main.gaudimain.__init__ |
( |
|
self | ) |
|
Definition at line 327 of file Main.py.
328 from Configurables
import ApplicationMgr
331 if os.environ.get(
"GAUDIAPPNAME"):
332 appMgr.AppName = str(os.environ[
"GAUDIAPPNAME"])
333 if os.environ.get(
"GAUDIAPPVERSION"):
334 appMgr.AppVersion = str(os.environ[
"GAUDIAPPVERSION"])
335 self.log = logging.getLogger(__name__)
336 self.printsequence =
False
337 self.application =
"Gaudi::Application"
◆ _writepickle()
def Gaudi.Main.gaudimain._writepickle |
( |
|
self, |
|
|
|
filename |
|
) |
| |
|
private |
Definition at line 403 of file Main.py.
403 def _writepickle(self, filename):
407 output = open(filename,
"wb")
409 from GaudiKernel.Proxy.Configurable
import getNeededConfigurables
413 to_dump[n] = Configuration.allConfigurables[n]
414 pickle.dump(to_dump, output, -1)
◆ generateOptsOutput()
def Gaudi.Main.gaudimain.generateOptsOutput |
( |
|
self, |
|
|
|
all = False |
|
) |
| |
Definition at line 396 of file Main.py.
396 def generateOptsOutput(self, all=False):
◆ generatePyOutput()
def Gaudi.Main.gaudimain.generatePyOutput |
( |
|
self, |
|
|
|
all = False |
|
) |
| |
Definition at line 377 of file Main.py.
377 def generatePyOutput(self, all=False):
378 from collections
import defaultdict
379 from pprint
import pformat
381 optDict = defaultdict(dict)
384 c, p = key.rsplit(
".", 1)
385 optDict[c][p] =
parseOpt(allOpts[key])
386 formatted = pformat(dict(optDict))
394 return re.sub(
r'"\n +"',
"", formatted, flags=re.MULTILINE)
◆ hookDebugger()
def Gaudi.Main.gaudimain.hookDebugger |
( |
|
self, |
|
|
|
debugger = "gdb" |
|
) |
| |
Definition at line 475 of file Main.py.
475 def hookDebugger(self, debugger="gdb"):
478 self.log.info(
"attaching debugger to PID " + str(os.getpid()))
480 os.P_NOWAIT, debugger, [debugger,
"-q",
"python", str(os.getpid())]
489 os.waitpid(pid, os.WNOHANG)
◆ printconfig()
def Gaudi.Main.gaudimain.printconfig |
( |
|
self, |
|
|
|
old_format = False , |
|
|
|
all = False |
|
) |
| |
Definition at line 417 of file Main.py.
417 def printconfig(self, old_format=False, all=False):
418 msg =
"Dumping all configurables and properties"
420 msg +=
" (different from default)"
423 print(self.generateOptsOutput(all))
425 print(self.generatePyOutput(all))
◆ run()
def Gaudi.Main.gaudimain.run |
( |
|
self, |
|
|
|
attach_debugger, |
|
|
|
ncpus = None |
|
) |
| |
Definition at line 466 of file Main.py.
466 def run(self, attach_debugger, ncpus=None):
469 result = self.runSerial(attach_debugger)
472 result = self.runParallel(ncpus)
◆ runParallel()
def Gaudi.Main.gaudimain.runParallel |
( |
|
self, |
|
|
|
ncpus |
|
) |
| |
Definition at line 535 of file Main.py.
535 def runParallel(self, ncpus):
536 self.setupParallelLogging()
540 c = Configurable.allConfigurables
541 self.log.info(
"-" * 80)
542 self.log.info(
"%s: Parallel Mode : %i ", __name__, ncpus)
544 (
"platform",
" ".join(os.uname())),
545 (
"config", os.environ.get(
"BINARY_TAG")
or os.environ.get(
"CMTCONFIG")),
546 (
"app. name", os.environ.get(
"GAUDIAPPNAME")),
547 (
"app. version", os.environ.get(
"GAUDIAPPVERSION")),
549 self.log.info(
"%s: %30s : %s ", __name__, name, value
or "Undefined")
551 events = str(c[
"ApplicationMgr"].EvtMax)
553 events =
"Undetermined"
554 self.log.info(
"%s: Events Specified : %s ", __name__, events)
555 self.log.info(
"-" * 80)
557 Parall = gpp.Coord(ncpus, c, self.log)
560 self.log.info(
"MAIN.PY : received %s from Coordinator" % (sc))
563 sysTime =
time() - sysStart
564 self.log.name =
"Gaudi/Main.py Logger"
565 self.log.info(
"-" * 80)
567 "%s: parallel system finished, time taken: %5.4fs", __name__, sysTime
569 self.log.info(
"-" * 80)
◆ runSerial()
def Gaudi.Main.gaudimain.runSerial |
( |
|
self, |
|
|
|
attach_debugger |
|
) |
| |
Definition at line 493 of file Main.py.
493 def runSerial(self, attach_debugger):
495 from GaudiKernel.Proxy.Configurable
import expandvars
501 from GaudiKernel.Proxy.Configurable
import Configurable
503 self.log.debug(
"runSerial: apply options")
505 conf_dict[
"ApplicationMgr.JobOptionsType"] =
'"NONE"'
507 if self.printsequence:
508 conf_dict[
"ApplicationMgr.PrintAlgsSequence"] =
"true"
510 if hasattr(Configurable,
"_configurationLocked"):
511 Configurable._configurationLocked =
True
516 self.log.debug(
"-" * 80)
517 self.log.debug(
"%s: running in serial mode", __name__)
518 self.log.debug(
"-" * 80)
526 sysTime =
time() - sysStart
527 self.log.debug(
"-" * 80)
529 "%s: serial system finished, time taken: %5.4fs", __name__, sysTime
531 self.log.debug(
"-" * 80)
◆ setupParallelLogging()
def Gaudi.Main.gaudimain.setupParallelLogging |
( |
|
self | ) |
|
Definition at line 339 of file Main.py.
339 def setupParallelLogging(self):
344 import multiprocessing
347 from time
import ctime
350 datetime = datetime.replace(
" ",
"_")
351 outfile = open(
"gaudirun-%s.log" % (datetime),
"w")
353 streamhandler = logging.StreamHandler(stream=outfile)
354 console = logging.StreamHandler()
356 formatter = logging.Formatter(
357 "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
360 streamhandler.setFormatter(formatter)
361 console.setFormatter(formatter)
365 self.log = multiprocessing.log_to_stderr()
366 self.log.setLevel(logging.INFO)
367 self.log.name =
"Gaudi/Main.py Logger"
368 self.log.handlers = []
370 self.log.addHandler(streamhandler)
371 self.log.addHandler(console)
372 self.log.removeHandler(console)
374 self.log.setLevel = logging.INFO
◆ writeconfig()
def Gaudi.Main.gaudimain.writeconfig |
( |
|
self, |
|
|
|
filename, |
|
|
|
all = False |
|
) |
| |
Definition at line 428 of file Main.py.
428 def writeconfig(self, filename, all=False):
432 ".pkl":
lambda filename, all: self._writepickle(filename),
433 ".py":
lambda filename, all: open(filename,
"w").write(
434 self.generatePyOutput(all) +
"\n"
436 ".opts":
lambda filename, all: open(filename,
"w").write(
437 self.generateOptsOutput(all) +
"\n"
439 ".json":
lambda filename, all: json.dump(
440 getAllOpts(all), open(filename,
"w"), indent=2, sort_keys=
True
446 write[
".yaml"] =
lambda filename, all: yaml.safe_dump(
449 write[
".yml"] = write[
".yaml"]
453 from os.path
import splitext
455 ext = splitext(filename)[1]
457 write[ext](filename, all)
460 "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: