| # Gaudi Framework, version v21r9 |

Home |  | Generated: 3 May 2010

# Gaudi::Main::gaudimain Class Reference

List of all members.

## Public Member Functions
def | __init__
def | generatePyOutput
def | generateOptsOutput
def | printconfig
def | writeconfig
def | printsequence
def | run
| Instantiate and run the application.
def | runSerial
def | runParallel
## Public Attributes
| g
## Private Member Functions
def | _writepickle

## 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.

    00009                        :
    00010         from Configurables import ApplicationMgr
    00011         appMgr = ApplicationMgr()
    00012         if "GAUDIAPPNAME" in os.environ:
    00013             appMgr.AppName = str(os.environ["GAUDIAPPNAME"])
    00014         if "GAUDIAPPVERSION" in os.environ:
    00015             appMgr.AppVersion = str(os.environ["GAUDIAPPVERSION"])
    00016
        def generatePyOutput(self, all = False):

def Gaudi::Main::gaudimain::generatePyOutput | ( |  | self,
|  |  | all = `False` |
| ) |  |  |

Definition at line 17 of file Main.py.

    00017                                            :
    00018         from pprint import pformat
    00019         conf_dict = Configuration.configurationDict(all)
    00020         return pformat(conf_dict)
    00021
        def generateOptsOutput(self, all = False):

def Gaudi::Main::gaudimain::generateOptsOutput | ( |  | self,
|  |  | all = `False` |
| ) |  |  |

Definition at line 22 of file Main.py.

    00022                                              :
    00023         from pprint import pformat
    00024         conf_dict = Configuration.configurationDict(all)
    00025         out = []
    00026         names = conf_dict.keys()
    00027         names.sort()
    00028         for n in names:
    00029             props = conf_dict[n].keys()
    00030             props.sort()
    00031             for p in props:
    00032                 out.append('%s.%s = %s;' % (n,p, repr(conf_dict[n][p])))
    00033         return "\n".join(out)
    00034
        def _writepickle(self, filename) :

def Gaudi::Main::gaudimain::_writepickle | ( |  | self,
|  |  | filename |
| ) |  |  | `[private]`

Definition at line 35 of file Main.py.

    00035                                      :
    00036         #--- Lets take the first file input file as the name of the pickle file
    00037         import pickle
    00038         output = open(filename, 'wb')
    00039         # Dump only the the configurables that make sense to dump (not User ones)
    00040         from GaudiKernel.Proxy.Configurable import getNeededConfigurables
    00041         to_dump = {}
    00042         for n in getNeededConfigurables():
    00043             to_dump[n] = Configuration.allConfigurables[n]
    00044         pickle.dump(to_dump, output, -1)
    00045         output.close()
    00046
        def printconfig(self, old_format = False, all = False) :

def Gaudi::Main::gaudimain::printconfig | ( |  | self,
|  |  | old_format = `False`,
|  |  | all = `False` |
| ) |  |  |

Definition at line 47 of file Main.py.

    00047                                                            :
    00048         msg = 'Dumping all configurables and properties'
    00049         if not all:
    00050             msg += ' (different from default)'
    00051         log.info(msg)
    00052         conf_dict = Configuration.configurationDict(all)
    00053         if old_format:
    00054             print self.generateOptsOutput(all)
    00055         else:
    00056             print self.generatePyOutput(all)
    00057
        def writeconfig(self, filename, all = False):

def Gaudi::Main::gaudimain::writeconfig | ( |  | self,
|  |  | filename,
|  |  | all = `False` |
| ) |  |  |

Definition at line 58 of file Main.py.

    00058                                                 :
    00059         write = { ".pkl" : lambda filename, all: self._writepickle(filename),
    00060                   ".py"  : lambda filename, all: open(filename,"w").write(self.generatePyOutput(all) + "\n"),
    00061                   ".opts": lambda filename, all: open(filename,"w").write(self.generateOptsOutput(all) + "\n"),
    00062                 }
    00063         from os.path import splitext
    00064         ext = splitext(filename)[1]
    00065         if ext in write:
    00066             write[ext](filename, all)
    00067         else:
    00068             log.error("Unknown file type '%s'. Must be any of %r.", ext, write.keys())
    00069             sys.exit(1)
    00070
        def printsequence(self):

def Gaudi::Main::gaudimain::printsequence | ( |  | self | ) |

Definition at line 71 of file Main.py.

    00071                            :
    00072         def printAlgo( algName, appMgr, prefix = ' ') :
    00073             print prefix + algName
    00074             alg = appMgr.algorithm( algName.split( "/" )[ -1 ] )
    00075             prop = alg.properties()
    00076             if prop.has_key( "Members" ) :
    00077                 subs = prop[ "Members" ].value()
    00078                 for i in subs : printAlgo( i.strip( '"' ), appMgr, prefix + "     " )
    00079             elif prop.has_key( "DetectorList" ) :
    00080                 subs = prop[ "DetectorList" ].value()
    00081                 for i in subs : printAlgo( algName.split( "/" )[ -1 ] + i.strip( '"' ) + "Seq", appMgr, prefix + "     ")
    00082         import GaudiPython
    00083         self.g = GaudiPython.AppMgr()
    00084         mp = self.g.properties()
    00085         print "\n ****************************** Algorithm Sequence **************************** \n"
    00086         for i in mp["TopAlg"].value(): printAlgo( i, self.g )
    00087         print "\n ****************************************************************************** \n"
    00088
        ## Instantiate and run the application.

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 91 of file Main.py.

    00091                                :
    00092         if not ncpus:
    00093             # Standard sequential mode
    00094             result = self.runSerial()
    00095         else:
    00096             # Doing the checking here because it is not done in runParallel
    00097             ncpus = int(ncpus)
    00098             assert(ncpus > 0)
    00099             # Parallel mode
    00100             result = self.runParallel(ncpus)
    00101         return result
    00102
    00103
        def runSerial(self) :

def Gaudi::Main::gaudimain::runSerial | ( |  | self | ) |

Definition at line 104 of file Main.py.

    00104                         :
    00105         #--- Instantiate the ApplicationMgr------------------------------
    00106         import GaudiPython
    00107         log.debug('-'*80)
    00108         log.debug('%s: running in serial mode', __name__)
    00109         log.debug('-'*80)
    00110         sysStart = time()
    00111         self.g = GaudiPython.AppMgr()
    00112         success = self.g.run(self.g.EvtMax).isSuccess()
    00113         success = self.g.exit().isSuccess() and success
    00114         if not success and self.g.ReturnCode == 0:
    00115             # ensure that the return code is correctly set
    00116             self.g.ReturnCode = 1
    00117         sysTime = time()-sysStart
    00118         log.debug('-'*80)
    00119         log.debug('%s: serial system finished, time taken: %5.4fs', __name__, sysTime)
    00120         log.debug('-'*80)
    00121         return self.g.ReturnCode
    00122
        def runParallel(self, ncpus) :

def Gaudi::Main::gaudimain::runParallel | ( |  | self,
|  |  | ncpus |
| ) |  |  |

Definition at line 123 of file Main.py.

    00123                                  :
    00124         from Gaudi.Configuration import Configurable
    00125         import GaudiPython.Parallel as gpp
    00126         c = Configurable.allConfigurables
    00127         log.info('-'*80)
    00128         log.info('%s: running in parallel mode', __name__)
    00129         log.info('-'*80)
    00130         sysStart = time()
    00131         sc = gpp.setupSystem(ncpus, c)
    00132         if not sc:
    00133             return 1
    00134         sysTime = time()-sysStart
    00135         log.info('-'*80)
    00136         log.info('%s: parallel system finished, time taken: %5.4fs', __name__, sysTime)
    00137         log.info('-'*80)
    00138         return 0
            return 0

## Member Data Documentation

Gaudi::Main::gaudimain::g

Definition at line 83 of file Main.py.

The documentation for this class was generated from the following file:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r9/Gaudi/python/Gaudi/Main.py