|
| 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 318 of file Main.py.
◆ __init__()
| def Gaudi.Main.gaudimain.__init__ |
( |
|
self | ) |
|
Definition at line 319 of file Main.py.
320 from Configurables
import ApplicationMgr
323 if os.environ.get(
"GAUDIAPPNAME"):
324 appMgr.AppName = str(os.environ[
"GAUDIAPPNAME"])
325 if os.environ.get(
"GAUDIAPPVERSION"):
326 appMgr.AppVersion = str(os.environ[
"GAUDIAPPVERSION"])
327 self.log = logging.getLogger(__name__)
328 self.printsequence =
False
329 self.application =
"Gaudi::Application"
◆ _writepickle()
| def Gaudi.Main.gaudimain._writepickle |
( |
|
self, |
|
|
|
filename |
|
) |
| |
|
private |
Definition at line 391 of file Main.py.
391 def _writepickle(self, filename):
395 output = open(filename,
"wb")
397 from GaudiKernel.Proxy.Configurable
import getNeededConfigurables
401 to_dump[n] = Configuration.allConfigurables[n]
402 pickle.dump(to_dump, output, -1)
◆ generateOptsOutput()
| def Gaudi.Main.gaudimain.generateOptsOutput |
( |
|
self, |
|
|
|
all = False |
|
) |
| |
Definition at line 384 of file Main.py.
384 def generateOptsOutput(self, all=False):
◆ generatePyOutput()
| def Gaudi.Main.gaudimain.generatePyOutput |
( |
|
self, |
|
|
|
all = False |
|
) |
| |
Definition at line 369 of file Main.py.
369 def generatePyOutput(self, all=False):
371 from collections
import defaultdict
372 from pprint
import pformat
374 optDict = defaultdict(dict)
377 c, p = key.rsplit(
".", 1)
378 optDict[c][p] =
parseOpt(allOpts[key])
379 formatted = pformat(dict(optDict))
382 return re.sub(
r'"\n +"',
"", formatted, flags=re.MULTILINE)
◆ hookDebugger()
| def Gaudi.Main.gaudimain.hookDebugger |
( |
|
self, |
|
|
|
debugger = "gdb" |
|
) |
| |
Definition at line 463 of file Main.py.
463 def hookDebugger(self, debugger="gdb"):
466 self.log.info(
"attaching debugger to PID " + str(os.getpid()))
468 os.P_NOWAIT, debugger, [debugger,
"-q",
"python", str(os.getpid())]
477 os.waitpid(pid, os.WNOHANG)
◆ printconfig()
| def Gaudi.Main.gaudimain.printconfig |
( |
|
self, |
|
|
|
old_format = False, |
|
|
|
all = False |
|
) |
| |
Definition at line 405 of file Main.py.
405 def printconfig(self, old_format=False, all=False):
406 msg =
"Dumping all configurables and properties"
408 msg +=
" (different from default)"
411 print(self.generateOptsOutput(all))
413 print(self.generatePyOutput(all))
◆ run()
| def Gaudi.Main.gaudimain.run |
( |
|
self, |
|
|
|
attach_debugger, |
|
|
|
ncpus = None |
|
) |
| |
Definition at line 454 of file Main.py.
454 def run(self, attach_debugger, ncpus=None):
457 result = self.runSerial(attach_debugger)
460 result = self.runParallel(ncpus)
◆ runParallel()
| def Gaudi.Main.gaudimain.runParallel |
( |
|
self, |
|
|
|
ncpus |
|
) |
| |
Definition at line 523 of file Main.py.
523 def runParallel(self, ncpus):
524 self.setupParallelLogging()
528 c = Configurable.allConfigurables
529 self.log.info(
"-" * 80)
530 self.log.info(
"%s: Parallel Mode : %i ", __name__, ncpus)
532 (
"platform",
" ".join(os.uname())),
533 (
"config", os.environ.get(
"BINARY_TAG")
or os.environ.get(
"CMTCONFIG")),
534 (
"app. name", os.environ.get(
"GAUDIAPPNAME")),
535 (
"app. version", os.environ.get(
"GAUDIAPPVERSION")),
537 self.log.info(
"%s: %30s : %s ", __name__, name, value
or "Undefined")
539 events = str(c[
"ApplicationMgr"].EvtMax)
541 events =
"Undetermined"
542 self.log.info(
"%s: Events Specified : %s ", __name__, events)
543 self.log.info(
"-" * 80)
545 Parall = gpp.Coord(ncpus, c, self.log)
548 self.log.info(
"MAIN.PY : received %s from Coordinator" % (sc))
551 sysTime =
time() - sysStart
552 self.log.name =
"Gaudi/Main.py Logger"
553 self.log.info(
"-" * 80)
555 "%s: parallel system finished, time taken: %5.4fs", __name__, sysTime
557 self.log.info(
"-" * 80)
◆ runSerial()
| def Gaudi.Main.gaudimain.runSerial |
( |
|
self, |
|
|
|
attach_debugger |
|
) |
| |
Definition at line 481 of file Main.py.
481 def runSerial(self, attach_debugger):
483 from GaudiKernel.Proxy.Configurable
import expandvars
489 from GaudiKernel.Proxy.Configurable
import Configurable
491 self.log.debug(
"runSerial: apply options")
493 conf_dict[
"ApplicationMgr.JobOptionsType"] =
'"NONE"'
495 if self.printsequence:
496 conf_dict[
"ApplicationMgr.PrintAlgsSequence"] =
"true"
498 if hasattr(Configurable,
"_configurationLocked"):
499 Configurable._configurationLocked =
True
504 self.log.debug(
"-" * 80)
505 self.log.debug(
"%s: running in serial mode", __name__)
506 self.log.debug(
"-" * 80)
514 sysTime =
time() - sysStart
515 self.log.debug(
"-" * 80)
517 "%s: serial system finished, time taken: %5.4fs", __name__, sysTime
519 self.log.debug(
"-" * 80)
◆ setupParallelLogging()
| def Gaudi.Main.gaudimain.setupParallelLogging |
( |
|
self | ) |
|
Definition at line 331 of file Main.py.
331 def setupParallelLogging(self):
336 import multiprocessing
339 from time
import ctime
342 datetime = datetime.replace(
" ",
"_")
343 outfile = open(
"gaudirun-%s.log" % (datetime),
"w")
345 streamhandler = logging.StreamHandler(stream=outfile)
346 console = logging.StreamHandler()
348 formatter = logging.Formatter(
349 "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
352 streamhandler.setFormatter(formatter)
353 console.setFormatter(formatter)
357 self.log = multiprocessing.log_to_stderr()
358 self.log.setLevel(logging.INFO)
359 self.log.name =
"Gaudi/Main.py Logger"
360 self.log.handlers = []
362 self.log.addHandler(streamhandler)
363 self.log.addHandler(console)
364 self.log.removeHandler(console)
366 self.log.setLevel = logging.INFO
◆ writeconfig()
| def Gaudi.Main.gaudimain.writeconfig |
( |
|
self, |
|
|
|
filename, |
|
|
|
all = False |
|
) |
| |
Definition at line 416 of file Main.py.
416 def writeconfig(self, filename, all=False):
420 ".pkl":
lambda filename, all: self._writepickle(filename),
421 ".py":
lambda filename, all: open(filename,
"w").write(
422 self.generatePyOutput(all) +
"\n"
424 ".opts":
lambda filename, all: open(filename,
"w").write(
425 self.generateOptsOutput(all) +
"\n"
427 ".json":
lambda filename, all: json.dump(
428 getAllOpts(all), open(filename,
"w"), indent=2, sort_keys=
True
434 write[
".yaml"] =
lambda filename, all: yaml.safe_dump(
437 write[
".yml"] = write[
".yaml"]
441 from os.path
import splitext
443 ext = splitext(filename)[1]
445 write[ext](filename, all)
448 "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: