List of all members.
Detailed Description
Definition at line 8 of file Main.py.
Constructor & Destructor Documentation
| def Gaudi::Main::gaudimain::__init__ |
( |
|
self ) |
|
Definition at line 12 of file Main.py.
00013 :
00014 from Configurables import ApplicationMgr
00015 appMgr = ApplicationMgr()
00016 if "GAUDIAPPNAME" in os.environ:
00017 appMgr.AppName = str(os.environ["GAUDIAPPNAME"])
00018 if "GAUDIAPPVERSION" in os.environ:
00019 appMgr.AppVersion = str(os.environ["GAUDIAPPVERSION"])
00020 self.log = logging.getLogger(__name__)
00021 self.printsequence = False
Member Function Documentation
| def Gaudi::Main::gaudimain::_printsequence |
( |
|
self ) |
[private] |
Definition at line 110 of file Main.py.
00111 :
00112 if not self.printsequence:
00113
00114 return
00115
00116 def printAlgo( algName, appMgr, prefix = ' ') :
00117 print prefix + algName
00118 alg = appMgr.algorithm( algName.split( "/" )[ -1 ] )
00119 prop = alg.properties()
00120 if prop.has_key( "Members" ) :
00121 subs = prop[ "Members" ].value()
00122 for i in subs : printAlgo( i.strip( '"' ), appMgr, prefix + " " )
00123 elif prop.has_key( "DetectorList" ) :
00124 subs = prop[ "DetectorList" ].value()
00125 for i in subs : printAlgo( algName.split( "/" )[ -1 ] + i.strip( '"' ) + "Seq", appMgr, prefix + " ")
00126
00127 mp = self.g.properties()
00128 print "\n ****************************** Algorithm Sequence **************************** \n"
00129 for i in mp["TopAlg"].value(): printAlgo( i, self.g )
00130 print "\n ****************************************************************************** \n"
| def Gaudi::Main::gaudimain::_writepickle |
( |
|
self, |
|
|
|
filename |
|
) |
| [private] |
Definition at line 74 of file Main.py.
00075 :
00076
00077 import pickle
00078 output = open(filename, 'wb')
00079
00080 from GaudiKernel.Proxy.Configurable import getNeededConfigurables
00081 to_dump = {}
00082 for n in getNeededConfigurables():
00083 to_dump[n] = Configuration.allConfigurables[n]
00084 pickle.dump(to_dump, output, -1)
00085 output.close()
| def Gaudi::Main::gaudimain::generateOptsOutput |
( |
|
self, |
|
|
|
all = False |
|
) |
| |
Definition at line 61 of file Main.py.
00062 :
00063 from pprint import pformat
00064 conf_dict = Configuration.configurationDict(all)
00065 out = []
00066 names = conf_dict.keys()
00067 names.sort()
00068 for n in names:
00069 props = conf_dict[n].keys()
00070 props.sort()
00071 for p in props:
00072 out.append('%s.%s = %s;' % (n,p, repr(conf_dict[n][p])))
00073 return "\n".join(out)
| def Gaudi::Main::gaudimain::generatePyOutput |
( |
|
self, |
|
|
|
all = False |
|
) |
| |
Definition at line 56 of file Main.py.
00057 :
00058 from pprint import pformat
00059 conf_dict = Configuration.configurationDict(all)
00060 return pformat(conf_dict)
| def Gaudi::Main::gaudimain::printconfig |
( |
|
self, |
|
|
|
old_format = False, |
|
|
|
all = False |
|
) |
| |
Definition at line 86 of file Main.py.
00087 :
00088 msg = 'Dumping all configurables and properties'
00089 if not all:
00090 msg += ' (different from default)'
00091 log.info(msg)
00092 conf_dict = Configuration.configurationDict(all)
00093 if old_format:
00094 print self.generateOptsOutput(all)
00095 else:
00096 print self.generatePyOutput(all)
| def Gaudi::Main::gaudimain::run |
( |
|
self, |
|
|
|
ncpus = None |
|
) |
| |
Instantiate and run the application.
Depending on the number of CPUs (ncpus) specified, it start
Definition at line 133 of file Main.py.
00134 :
00135 if not ncpus:
00136
00137 result = self.runSerial()
00138 else:
00139
00140 result = self.runParallel(ncpus)
00141 return result
00142
| def Gaudi::Main::gaudimain::runParallel |
( |
|
self, |
|
|
|
ncpus |
|
) |
| |
Definition at line 168 of file Main.py.
00169 :
00170 if self.mainLoop:
00171 self.log.fatal("Cannot use custom main loop in multi-process mode, check your options")
00172 return 1
00173 self.setupParallelLogging( )
00174 from Gaudi.Configuration import Configurable
00175 import GaudiMP.GMPBase as gpp
00176 c = Configurable.allConfigurables
00177 self.log.info('-'*80)
00178 self.log.info('%s: Parallel Mode : %i '%(__name__, ncpus))
00179 from commands import getstatusoutput as gso
00180 metadataCommands = [ 'uname -a',
00181 'echo $CMTCONFIG',
00182 'echo $GAUDIAPPNAME',
00183 'echo $GAUDIAPPVERSION']
00184 for comm in metadataCommands :
00185 s, o = gso( comm )
00186 if s :
00187 o = "Undetermined"
00188 string = '%s: %30s : %s '%(__name__, comm, o)
00189 self.log.info( string )
00190 try :
00191 events = str(c['ApplicationMgr'].EvtMax)
00192 except :
00193 events = "Undetermined"
00194 self.log.info('%s: Events Specified : %s '%(__name__,events))
00195 self.log.info('-'*80)
00196
00197 Parall = gpp.Coord( ncpus, c, self.log )
00198 sysStart = time()
00199 sc = Parall.Go()
00200 self.log.info('MAIN.PY : received %s from Coordinator'%(sc))
00201 if sc.isFailure() :
00202 return 1
00203 sysTime = time()-sysStart
00204 self.log.name = 'Gaudi/Main.py Logger'
00205 self.log.info('-'*80)
00206 self.log.info('%s: parallel system finished, time taken: %5.4fs', __name__, sysTime)
00207 self.log.info('-'*80)
00208 return 0
| def Gaudi::Main::gaudimain::runSerial |
( |
|
self ) |
|
Definition at line 143 of file Main.py.
00144 :
00145
00146 import GaudiPython
00147 self.log.debug('-'*80)
00148 self.log.debug('%s: running in serial mode', __name__)
00149 self.log.debug('-'*80)
00150 sysStart = time()
00151 self.g = GaudiPython.AppMgr()
00152 self._printsequence()
00153 runner = self.mainLoop or (lambda app, nevt: app.run(nevt))
00154 statuscode = runner(self.g, self.g.EvtMax)
00155 if hasattr(statuscode, "isSuccess"):
00156 success = statuscode.isSuccess()
00157 else:
00158 success = statuscode
00159 success = self.g.exit().isSuccess() and success
00160 if not success and self.g.ReturnCode == 0:
00161
00162 self.g.ReturnCode = 1
00163 sysTime = time()-sysStart
00164 self.log.debug('-'*80)
00165 self.log.debug('%s: serial system finished, time taken: %5.4fs', __name__, sysTime)
00166 self.log.debug('-'*80)
00167 return self.g.ReturnCode
| def Gaudi::Main::gaudimain::setupParallelLogging |
( |
|
self ) |
|
Definition at line 22 of file Main.py.
00023 :
00024
00025
00026
00027
00028 import multiprocessing
00029
00030 from time import ctime
00031 datetime = ctime()
00032 datetime = datetime.replace(' ', '_')
00033 outfile = open( 'gaudirun-%s.log'%(datetime), 'w' )
00034
00035 streamhandler = logging.StreamHandler(strm=outfile)
00036 console = logging.StreamHandler()
00037
00038 formatter = logging.Formatter( "%(asctime)s - %(name)s - %(levelname)s - %(message)s" )
00039
00040 streamhandler.setFormatter(formatter)
00041 console.setFormatter(formatter)
00042
00043
00044
00045 self.log = multiprocessing.log_to_stderr()
00046 self.log.setLevel( logging.INFO )
00047 self.log.name = 'Gaudi/Main.py Logger'
00048 self.log.handlers = []
00049
00050 self.log.addHandler(streamhandler)
00051 self.log.addHandler(console)
00052 self.log.removeHandler(console)
00053
00054 self.log.setLevel = logging.INFO
00055
| def Gaudi::Main::gaudimain::writeconfig |
( |
|
self, |
|
|
|
filename, |
|
|
|
all = False |
|
) |
| |
Definition at line 97 of file Main.py.
00098 :
00099 write = { ".pkl" : lambda filename, all: self._writepickle(filename),
00100 ".py" : lambda filename, all: open(filename,"w").write(self.generatePyOutput(all) + "\n"),
00101 ".opts": lambda filename, all: open(filename,"w").write(self.generateOptsOutput(all) + "\n"),
00102 }
00103 from os.path import splitext
00104 ext = splitext(filename)[1]
00105 if ext in write:
00106 write[ext](filename, all)
00107 else:
00108 log.error("Unknown file type '%s'. Must be any of %r.", ext, write.keys())
00109 sys.exit(1)
Member Data Documentation
| Gaudi::Main::gaudimain::g |
| Gaudi::Main::gaudimain::log |
Gaudi::Main::gaudimain::mainLoop = None [static] |
| Gaudi::Main::gaudimain::printsequence |
The documentation for this class was generated from the following file:
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v23r2p1/Gaudi/python/Gaudi/Main.py