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