Gaudi::Main::gaudimain Class Reference
List of all members.
Detailed Description
Definition at line 8 of file Main.py.
Member Function Documentation
| def Gaudi::Main::gaudimain::__init__ |
( |
|
self |
) |
|
Definition at line 9 of file Main.py.
00010 :
00011 from Configurables import ApplicationMgr
00012 appMgr = ApplicationMgr()
00013 if "GAUDIAPPNAME" in os.environ:
00014 appMgr.AppName = str(os.environ["GAUDIAPPNAME"])
00015 if "GAUDIAPPVERSION" in os.environ:
00016 appMgr.AppVersion = str(os.environ["GAUDIAPPVERSION"])
00017 self.log = logging.getLogger(__name__)
| def Gaudi::Main::gaudimain::_writepickle |
( |
|
self, |
|
|
|
filename | |
|
) |
| | [private] |
Definition at line 70 of file Main.py.
00071 :
00072
00073 import pickle
00074 output = open(filename, 'wb')
00075
00076 from GaudiKernel.Proxy.Configurable import getNeededConfigurables
00077 to_dump = {}
00078 for n in getNeededConfigurables():
00079 to_dump[n] = Configuration.allConfigurables[n]
00080 pickle.dump(to_dump, output, -1)
00081 output.close()
| def Gaudi::Main::gaudimain::generateOptsOutput |
( |
|
self, |
|
|
|
all = False | |
|
) |
| | |
Definition at line 57 of file Main.py.
00058 :
00059 from pprint import pformat
00060 conf_dict = Configuration.configurationDict(all)
00061 out = []
00062 names = conf_dict.keys()
00063 names.sort()
00064 for n in names:
00065 props = conf_dict[n].keys()
00066 props.sort()
00067 for p in props:
00068 out.append('%s.%s = %s;' % (n,p, repr(conf_dict[n][p])))
00069 return "\n".join(out)
| def Gaudi::Main::gaudimain::generatePyOutput |
( |
|
self, |
|
|
|
all = False | |
|
) |
| | |
Definition at line 52 of file Main.py.
00053 :
00054 from pprint import pformat
00055 conf_dict = Configuration.configurationDict(all)
00056 return pformat(conf_dict)
| def Gaudi::Main::gaudimain::printconfig |
( |
|
self, |
|
|
|
old_format = False, |
|
|
|
all = False | |
|
) |
| | |
Definition at line 82 of file Main.py.
00083 :
00084 msg = 'Dumping all configurables and properties'
00085 if not all:
00086 msg += ' (different from default)'
00087 log.info(msg)
00088 conf_dict = Configuration.configurationDict(all)
00089 if old_format:
00090 print self.generateOptsOutput(all)
00091 else:
00092 print self.generatePyOutput(all)
| def Gaudi::Main::gaudimain::printsequence |
( |
|
self |
) |
|
Definition at line 106 of file Main.py.
00107 :
00108 def printAlgo( algName, appMgr, prefix = ' ') :
00109 print prefix + algName
00110 alg = appMgr.algorithm( algName.split( "/" )[ -1 ] )
00111 prop = alg.properties()
00112 if prop.has_key( "Members" ) :
00113 subs = prop[ "Members" ].value()
00114 for i in subs : printAlgo( i.strip( '"' ), appMgr, prefix + " " )
00115 elif prop.has_key( "DetectorList" ) :
00116 subs = prop[ "DetectorList" ].value()
00117 for i in subs : printAlgo( algName.split( "/" )[ -1 ] + i.strip( '"' ) + "Seq", appMgr, prefix + " ")
00118 import GaudiPython
00119 self.g = GaudiPython.AppMgr()
00120 mp = self.g.properties()
00121 print "\n ****************************** Algorithm Sequence **************************** \n"
00122 for i in mp["TopAlg"].value(): printAlgo( i, self.g )
00123 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 126 of file Main.py.
00127 :
00128 if not ncpus:
00129
00130 result = self.runSerial()
00131 else:
00132
00133 result = self.runParallel(ncpus)
00134 return result
00135
| def Gaudi::Main::gaudimain::runParallel |
( |
|
self, |
|
|
|
ncpus | |
|
) |
| | |
Definition at line 155 of file Main.py.
00156 :
00157 self.setupParallelLogging( )
00158 from Gaudi.Configuration import Configurable
00159 import GaudiMP.GMPBase as gpp
00160 c = Configurable.allConfigurables
00161 self.log.info('-'*80)
00162 self.log.info('%s: Parallel Mode : %i '%(__name__, ncpus))
00163 from commands import getstatusoutput as gso
00164 metadataCommands = [ 'uname -a',
00165 'echo $CMTCONFIG',
00166 'echo $GAUDIAPPNAME',
00167 'echo $GAUDIAPPVERSION']
00168 for comm in metadataCommands :
00169 s, o = gso( comm )
00170 if s :
00171 o = "Undetermined"
00172 string = '%s: %30s : %s '%(__name__, comm, o)
00173 self.log.info( string )
00174 try :
00175 events = str(c['ApplicationMgr'].EvtMax)
00176 except :
00177 events = "Undetermined"
00178 self.log.info('%s: Events Specified : %s '%(__name__,events))
00179 self.log.info('-'*80)
00180
00181 Parall = gpp.Coord( ncpus, c, self.log )
00182 sysStart = time()
00183 sc = Parall.Go()
00184 self.log.info('MAIN.PY : received %s from Coordinator'%(sc))
00185 if sc.isFailure() :
00186 return 1
00187 sysTime = time()-sysStart
00188 self.log.name = 'Gaudi/Main.py Logger'
00189 self.log.info('-'*80)
00190 self.log.info('%s: parallel system finished, time taken: %5.4fs', __name__, sysTime)
00191 self.log.info('-'*80)
00192 return 0
| def Gaudi::Main::gaudimain::runSerial |
( |
|
self |
) |
|
Definition at line 136 of file Main.py.
00137 :
00138
00139 import GaudiPython
00140 self.log.debug('-'*80)
00141 self.log.debug('%s: running in serial mode', __name__)
00142 self.log.debug('-'*80)
00143 sysStart = time()
00144 self.g = GaudiPython.AppMgr()
00145 success = self.g.run(self.g.EvtMax).isSuccess()
00146 success = self.g.exit().isSuccess() and success
00147 if not success and self.g.ReturnCode == 0:
00148
00149 self.g.ReturnCode = 1
00150 sysTime = time()-sysStart
00151 self.log.debug('-'*80)
00152 self.log.debug('%s: serial system finished, time taken: %5.4fs', __name__, sysTime)
00153 self.log.debug('-'*80)
00154 return self.g.ReturnCode
| def Gaudi::Main::gaudimain::setupParallelLogging |
( |
|
self |
) |
|
Definition at line 18 of file Main.py.
00019 :
00020
00021
00022
00023
00024 import multiprocessing
00025
00026 from time import ctime
00027 datetime = ctime()
00028 datetime = datetime.replace(' ', '_')
00029 outfile = open( 'gaudirun-%s.log'%(datetime), 'w' )
00030
00031 streamhandler = logging.StreamHandler(strm=outfile)
00032 console = logging.StreamHandler()
00033
00034 formatter = logging.Formatter( "%(asctime)s - %(name)s - %(levelname)s - %(message)s" )
00035
00036 streamhandler.setFormatter(formatter)
00037 console.setFormatter(formatter)
00038
00039
00040
00041 self.log = multiprocessing.log_to_stderr()
00042 self.log.setLevel( logging.INFO )
00043 self.log.name = 'Gaudi/Main.py Logger'
00044 self.log.handlers = []
00045
00046 self.log.addHandler(streamhandler)
00047 self.log.addHandler(console)
00048 self.log.removeHandler(console)
00049
00050 self.log.setLevel = logging.INFO
00051
| def Gaudi::Main::gaudimain::writeconfig |
( |
|
self, |
|
|
|
filename, |
|
|
|
all = False | |
|
) |
| | |
Definition at line 93 of file Main.py.
00094 :
00095 write = { ".pkl" : lambda filename, all: self._writepickle(filename),
00096 ".py" : lambda filename, all: open(filename,"w").write(self.generatePyOutput(all) + "\n"),
00097 ".opts": lambda filename, all: open(filename,"w").write(self.generateOptsOutput(all) + "\n"),
00098 }
00099 from os.path import splitext
00100 ext = splitext(filename)[1]
00101 if ext in write:
00102 write[ext](filename, all)
00103 else:
00104 log.error("Unknown file type '%s'. Must be any of %r.", ext, write.keys())
00105 sys.exit(1)
Member Data Documentation
| Gaudi::Main::gaudimain::g |
| Gaudi::Main::gaudimain::log |
The documentation for this class was generated from the following file:
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r0/Gaudi/python/Gaudi/Main.py