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.13 by ewv, Mon Aug 18 15:30:43 2008 UTC vs.
Revision 1.19 by ewv, Tue May 5 15:29:38 2009 UTC

# Line 7 | Line 7 | Re-write config file and optionally conv
7   __revision__ = "$Id$"
8   __version__ = "$Revision$"
9  
10 < import sys, getopt
10 > import getopt
11   import imp
12   import os
13 + import pickle
14 + import sys
15 + import xml.dom.minidom
16 +
17   from random import SystemRandom
18  
19   from ProdCommon.CMSConfigTools.ConfigAPI.CfgInterface import CfgInterface
# Line 85 | Line 89 | def main(argv) :
89          print main.__doc__
90          sys.exit()
91  
92 <  # Optional Parameters
92 >  # Read in Environment, XML and get optional Parameters
93  
90    maxEvents  = int(os.environ.get('MaxEvents', '0'))
91    skipEvents = int(os.environ.get('SkipEvents','0'))
92    firstRun   = int(os.environ.get('FirstRun',  '0'))
94      nJob       = int(os.environ.get('NJob',      '0'))
94
95    inputFiles     = os.environ.get('InputFiles','')
96    parentFiles    = os.environ.get('ParentFiles','')
95      preserveSeeds  = os.environ.get('PreserveSeeds','')
96      incrementSeeds = os.environ.get('IncrementSeeds','')
97  
98 +  # Defaults
99 +
100 +    maxEvents  = 0
101 +    skipEvents = 0
102 +    firstEvent = -1
103 +    compHEPFirstEvent = 0
104 +    firstRun   = 0
105 +
106 +    dom = xml.dom.minidom.parse(os.environ['RUNTIME_AREA']+'/arguments.xml')
107 +
108 +    for elem in dom.getElementsByTagName("Job"):
109 +        if nJob == int(elem.getAttribute("JobID")):
110 +            if elem.getAttribute("MaxEvents"):
111 +                maxEvents = int(elem.getAttribute("MaxEvents"))
112 +            if elem.getAttribute("SkipEvents"):
113 +                skipEvents = int(elem.getAttribute("SkipEvents"))
114 +            if elem.getAttribute("FirstEvent"):
115 +                firstEvent = int(elem.getAttribute("FirstEvent"))
116 +            if elem.getAttribute("CompHEPFirstEvent"):
117 +                compHEPFirstEvent = int(elem.getAttribute("CompHEPFirstEvent"))
118 +            if elem.getAttribute("FirstRun"):
119 +                firstRun = int(elem.getAttribute("FirstRun"))
120 +
121 +            inputFiles     = str(elem.getAttribute('InputFiles'))
122 +            parentFiles    = str(elem.getAttribute('ParentFiles'))
123 +
124    # Read Input cfg or python cfg file, FUTURE: Get rid cfg mode
125  
126      if fileName.endswith('py'):
# Line 130 | Line 154 | def main(argv) :
154  
155      if skipEvents:
156          inModule.setSkipEvents(skipEvents)
157 <
157 >    if firstEvent != -1:
158 >        cmsProcess.source.firstEvent = CfgTypes.untracked(CfgTypes.uint32(firstEvent))
159 >    if compHEPFirstEvent:
160 >        cmsProcess.source.CompHEPFirstEvent = CfgTypes.int32(compHEPFirstEvent)
161      if inputFiles:
135        inputFiles = inputFiles.replace('\\','')
136        inputFiles = inputFiles.replace('"','')
162          inputFileNames = inputFiles.split(',')
163          inModule.setFileNames(*inputFileNames)
164  
165      # handle parent files if needed
166      if parentFiles:
142        parentFiles = parentFiles.replace('\\','')
143        parentFiles = parentFiles.replace('"','')
167          parentFileNames = parentFiles.split(',')
168          inModule.setSecondaryFileNames(*parentFileNames)
169  
# Line 212 | Line 235 | def main(argv) :
235      outFile = open(outFileName,"w")
236      if outFileName.endswith('py'):
237          outFile.write("import FWCore.ParameterSet.Config as cms\n")
238 <        outFile.write(cmsProcess.dumpPython())
238 >        outFile.write("import pickle\n")
239 >        outFile.write("pickledCfg=\"\"\"%s\"\"\"\n" % pickle.dumps(cmsProcess))
240 >        outFile.write("process = pickle.loads(pickledCfg)\n")
241          if (debug):
242 <            print "writeCfg output:"
242 >            print "writeCfg output (May not be exact):"
243              print "import FWCore.ParameterSet.Config as cms"
244              print cmsProcess.dumpPython()
245      else:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines