ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/writeCfg.py
(Generate patch)

Comparing COMP/CRAB/python/writeCfg.py (file contents):
Revision 1.25 by ewv, Fri Aug 28 18:56:43 2009 UTC vs.
Revision 1.33 by spiga, Wed Mar 23 16:48:53 2011 UTC

# Line 17 | Line 17 | import xml.dom.minidom
17   from random import SystemRandom
18  
19   from ProdCommon.CMSConfigTools.ConfigAPI.CfgInterface import CfgInterface
20 from FWCore.ParameterSet.Config                       import include
20   import FWCore.ParameterSet.Types as CfgTypes
21  
22   MyRandom  = SystemRandom()
# Line 102 | Line 101 | def main(argv) :
101      firstEvent = -1
102      compHEPFirstEvent = 0
103      firstRun   = 0
104 +    # FUTURE: Remove firstRun
105 +    firstLumi  = 0
106  
107      dom = xml.dom.minidom.parse(os.environ['RUNTIME_AREA']+'/arguments.xml')
108  
# Line 115 | Line 116 | def main(argv) :
116                  firstEvent = int(elem.getAttribute("FirstEvent"))
117              if elem.getAttribute("FirstRun"):
118                  firstRun = int(elem.getAttribute("FirstRun"))
119 +            if elem.getAttribute("FirstLumi"):
120 +                firstLumi = int(elem.getAttribute("FirstLumi"))
121  
122              generator      = str(elem.getAttribute('Generator'))
123 +            inputBlocks    = str(elem.getAttribute('InputBlocks'))
124              inputFiles     = str(elem.getAttribute('InputFiles'))
125              parentFiles    = str(elem.getAttribute('ParentFiles'))
126              lumis          = str(elem.getAttribute('Lumis'))
127  
128 +    report(inputBlocks,inputFiles,parentFiles,lumis)
129 +
130    # Read Input python config file
131  
132      handle = open(fileName, 'r')
# Line 143 | Line 149 | def main(argv) :
149      if maxEvents:
150          cfg.maxEvents.setMaxEventsInput(maxEvents)
151  
152 <    if skipEvents:
152 >    if skipEvents and inModule.sourceType not in ['EmptySource']:
153          inModule.setSkipEvents(skipEvents)
154  
155      # Set "skip events" for various generators
# Line 174 | Line 180 | def main(argv) :
180      # Pythia parameters
181      if (firstRun):
182          inModule.setFirstRun(firstRun)
183 +    if (firstLumi):
184 +        inModule.setFirstLumi(firstLumi)
185  
186      # Check if there are random #'s to deal with
187      if cfg.data.services.has_key('RandomNumberGeneratorService'):
188          print "RandomNumberGeneratorService found, will attempt to change seeds"
189          from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper
190          ranGenerator = cfg.data.services['RandomNumberGeneratorService']
191 +
192 +        ranModules   = getattr(ranGenerator, "moduleSeeds", None)
193 +        oldSource    = getattr(ranGenerator, "sourceSeed",  None)
194 +        if ranModules != None or oldSource != None:
195 +            msg = "Your random number seeds are set in an old,\n"
196 +            msg += "deprecated style. Please change to new style:\n"
197 +            msg += "https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideEDMRandomNumberGeneratorService"
198 +            raise ConfigException(msg)
199 +
200          randSvc = RandomNumberServiceHelper(ranGenerator)
201  
202          incrementSeedList = []
# Line 201 | Line 218 | def main(argv) :
218          randSvc.populate(*preserveSeedList)
219  
220      # Write out new config file
221 +    pklFileName = outFileName + '.pkl'
222      outFile = open(outFileName,"w")
223      outFile.write("import FWCore.ParameterSet.Config as cms\n")
224      outFile.write("import pickle\n")
225 <    outFile.write("pickledCfg=\"\"\"%s\"\"\"\n" % pickle.dumps(cmsProcess))
208 <    outFile.write("process = pickle.loads(pickledCfg)\n")
225 >    outFile.write("process = pickle.load(open('%s', 'rb'))\n" % pklFileName)
226      outFile.close()
227 +
228 +    pklFile = open(pklFileName,"wb")
229 +    myPickle = pickle.Pickler(pklFile)
230 +    myPickle.dump(cmsProcess)
231 +    pklFile.close()
232 +
233      if (debug):
234          print "writeCfg output (May not be exact):"
235          print "import FWCore.ParameterSet.Config as cms"
236          print cmsProcess.dumpPython()
237  
238  
239 + def report( inputBlocks='', inputFiles='', parentFiles='', lumis='' ):
240 +    """
241 +    Writes the 4 parameters to a file, one parameter per line.
242 +    """
243 +    outFile = open('%s/inputsReport.txt'%os.environ['RUNTIME_AREA'],"a")
244 +
245 +  #  InputFileList=inputFiles.split(',')
246 +  #  parentFilesList= parentFiles.split(',')
247 +  #  lumisList= lumis.split(',')
248 +
249 +    ## replacing , with ; otherwise report.py will split it as a new parameter
250 +    txt = ''
251 +    txt += 'inputBlocks='+inputBlocks.replace(',',';')+'\n'
252 +    txt += 'inputFiles='+inputFiles.replace(',',';')+'\n'
253 +    txt += 'parentFiles='+parentFiles.replace(',',';')+'\n'
254 +    txt += 'lumisRange='+lumis.replace(',',';')+'\n'
255 +    outFile.write(str(txt))
256 +    outFile.close()
257 +    return
258 +
259 +
260   if __name__ == '__main__' :
261      exit_status = main(sys.argv[1:])
262      sys.exit(exit_status)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines