|
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 325 of file Main.py.
◆ __init__()
def Gaudi.Main.gaudimain.__init__ |
( |
|
self | ) |
|
Definition at line 326 of file Main.py.
327 from Configurables
import ApplicationMgr
330 if os.environ.get(
"GAUDIAPPNAME"):
331 appMgr.AppName = str(os.environ[
"GAUDIAPPNAME"])
332 if os.environ.get(
"GAUDIAPPVERSION"):
333 appMgr.AppVersion = str(os.environ[
"GAUDIAPPVERSION"])
334 self.log = logging.getLogger(__name__)
335 self.printsequence =
False
336 self.application =
"Gaudi::Application"
◆ _writepickle()
def Gaudi.Main.gaudimain._writepickle |
( |
|
self, |
|
|
|
filename |
|
) |
| |
|
private |
Definition at line 402 of file Main.py.
402 def _writepickle(self, filename):
406 output = open(filename,
"wb")
408 from GaudiKernel.Proxy.Configurable
import getNeededConfigurables
412 to_dump[n] = Configuration.allConfigurables[n]
413 pickle.dump(to_dump, output, -1)
◆ generateOptsOutput()
def Gaudi.Main.gaudimain.generateOptsOutput |
( |
|
self, |
|
|
|
all = False |
|
) |
| |
Definition at line 395 of file Main.py.
395 def generateOptsOutput(self, all=False):
◆ generatePyOutput()
def Gaudi.Main.gaudimain.generatePyOutput |
( |
|
self, |
|
|
|
all = False |
|
) |
| |
Definition at line 376 of file Main.py.
376 def generatePyOutput(self, all=False):
377 from collections
import defaultdict
378 from pprint
import pformat
380 optDict = defaultdict(dict)
383 c, p = key.rsplit(
".", 1)
384 optDict[c][p] =
parseOpt(allOpts[key])
385 formatted = pformat(dict(optDict))
393 return re.sub(
r'"\n +"',
"", formatted, flags=re.MULTILINE)
◆ hookDebugger()
def Gaudi.Main.gaudimain.hookDebugger |
( |
|
self, |
|
|
|
debugger = "gdb" |
|
) |
| |
Definition at line 474 of file Main.py.
474 def hookDebugger(self, debugger="gdb"):
477 self.log.info(
"attaching debugger to PID " + str(os.getpid()))
479 os.P_NOWAIT, debugger, [debugger,
"-q",
"python", str(os.getpid())]
488 os.waitpid(pid, os.WNOHANG)
◆ printconfig()
def Gaudi.Main.gaudimain.printconfig |
( |
|
self, |
|
|
|
old_format = False , |
|
|
|
all = False |
|
) |
| |
Definition at line 416 of file Main.py.
416 def printconfig(self, old_format=False, all=False):
417 msg =
"Dumping all configurables and properties"
419 msg +=
" (different from default)"
422 print(self.generateOptsOutput(all))
424 print(self.generatePyOutput(all))
◆ run()
def Gaudi.Main.gaudimain.run |
( |
|
self, |
|
|
|
attach_debugger, |
|
|
|
ncpus = None |
|
) |
| |
Definition at line 465 of file Main.py.
465 def run(self, attach_debugger, ncpus=None):
468 result = self.runSerial(attach_debugger)
471 result = self.runParallel(ncpus)
◆ runParallel()
def Gaudi.Main.gaudimain.runParallel |
( |
|
self, |
|
|
|
ncpus |
|
) |
| |
Definition at line 534 of file Main.py.
534 def runParallel(self, ncpus):
535 self.setupParallelLogging()
539 c = Configurable.allConfigurables
540 self.log.info(
"-" * 80)
541 self.log.info(
"%s: Parallel Mode : %i ", __name__, ncpus)
543 (
"platform",
" ".join(os.uname())),
544 (
"config", os.environ.get(
"BINARY_TAG")
or os.environ.get(
"CMTCONFIG")),
545 (
"app. name", os.environ.get(
"GAUDIAPPNAME")),
546 (
"app. version", os.environ.get(
"GAUDIAPPVERSION")),
548 self.log.info(
"%s: %30s : %s ", __name__, name, value
or "Undefined")
550 events = str(c[
"ApplicationMgr"].EvtMax)
552 events =
"Undetermined"
553 self.log.info(
"%s: Events Specified : %s ", __name__, events)
554 self.log.info(
"-" * 80)
556 Parall = gpp.Coord(ncpus, c, self.log)
559 self.log.info(
"MAIN.PY : received %s from Coordinator" % (sc))
562 sysTime =
time() - sysStart
563 self.log.name =
"Gaudi/Main.py Logger"
564 self.log.info(
"-" * 80)
566 "%s: parallel system finished, time taken: %5.4fs", __name__, sysTime
568 self.log.info(
"-" * 80)
◆ runSerial()
def Gaudi.Main.gaudimain.runSerial |
( |
|
self, |
|
|
|
attach_debugger |
|
) |
| |
Definition at line 492 of file Main.py.
492 def runSerial(self, attach_debugger):
494 from GaudiKernel.Proxy.Configurable
import expandvars
500 from GaudiKernel.Proxy.Configurable
import Configurable
502 self.log.debug(
"runSerial: apply options")
504 conf_dict[
"ApplicationMgr.JobOptionsType"] =
'"NONE"'
506 if self.printsequence:
507 conf_dict[
"ApplicationMgr.PrintAlgsSequence"] =
"true"
509 if hasattr(Configurable,
"_configurationLocked"):
510 Configurable._configurationLocked =
True
515 self.log.debug(
"-" * 80)
516 self.log.debug(
"%s: running in serial mode", __name__)
517 self.log.debug(
"-" * 80)
525 sysTime =
time() - sysStart
526 self.log.debug(
"-" * 80)
528 "%s: serial system finished, time taken: %5.4fs", __name__, sysTime
530 self.log.debug(
"-" * 80)
◆ setupParallelLogging()
def Gaudi.Main.gaudimain.setupParallelLogging |
( |
|
self | ) |
|
Definition at line 338 of file Main.py.
338 def setupParallelLogging(self):
343 import multiprocessing
346 from time
import ctime
349 datetime = datetime.replace(
" ",
"_")
350 outfile = open(
"gaudirun-%s.log" % (datetime),
"w")
352 streamhandler = logging.StreamHandler(stream=outfile)
353 console = logging.StreamHandler()
355 formatter = logging.Formatter(
356 "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
359 streamhandler.setFormatter(formatter)
360 console.setFormatter(formatter)
364 self.log = multiprocessing.log_to_stderr()
365 self.log.setLevel(logging.INFO)
366 self.log.name =
"Gaudi/Main.py Logger"
367 self.log.handlers = []
369 self.log.addHandler(streamhandler)
370 self.log.addHandler(console)
371 self.log.removeHandler(console)
373 self.log.setLevel = logging.INFO
◆ writeconfig()
def Gaudi.Main.gaudimain.writeconfig |
( |
|
self, |
|
|
|
filename, |
|
|
|
all = False |
|
) |
| |
Definition at line 427 of file Main.py.
427 def writeconfig(self, filename, all=False):
431 ".pkl":
lambda filename, all: self._writepickle(filename),
432 ".py":
lambda filename, all: open(filename,
"w").write(
433 self.generatePyOutput(all) +
"\n"
435 ".opts":
lambda filename, all: open(filename,
"w").write(
436 self.generateOptsOutput(all) +
"\n"
438 ".json":
lambda filename, all: json.dump(
439 getAllOpts(all), open(filename,
"w"), indent=2, sort_keys=
True
445 write[
".yaml"] =
lambda filename, all: yaml.safe_dump(
448 write[
".yml"] = write[
".yaml"]
452 from os.path
import splitext
454 ext = splitext(filename)[1]
456 write[ext](filename, all)
459 "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: