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.7 by ewv, Tue May 6 01:09:58 2008 UTC vs.
Revision 1.9 by ewv, Wed May 7 16:30:35 2008 UTC

# Line 144 | Line 144 | def main(argv) :
144    if preserveSeeds:
145      preserveSeedList  = preserveSeeds.split(',')
146  
147 <  # FUTURE: This function tests the CMSSW version. Can be simplified as we drop support for old versions
148 <  if CMSSW_major < 2 or (CMSSW_major == 2 and CMSSW_minor == 0): # Treatment for seeds, CMSSW < 2_1_x
149 <    if cfg.data.services.has_key('RandomNumberGeneratorService'):
150 <      ranGenerator = cfg.data.services['RandomNumberGeneratorService']
151 <      ranModules   = ranGenerator.moduleSeeds
152 <
147 >  # FUTURE: This function tests the CMSSW version and presence of old-style seed specification. Reduce when we drop support for old versions
148 >  if cfg.data.services.has_key('RandomNumberGeneratorService'): # There are random #'s to deal with
149 >    print "RandomNumberGeneratorService found, will attempt to change seeds"
150 >    ranGenerator = cfg.data.services['RandomNumberGeneratorService']
151 >    ranModules   = getattr(ranGenerator,"moduleSeeds",None)
152 >    if ranModules != None:              # Old format present, no matter the CMSSW version
153 >      print "Old-style random number seeds found, will be changed."
154        sourceSeed = int(ranGenerator.sourceSeed.value())
155 <      if 'sourceSeed' in preserveSeedList:
155 >      if ('sourceSeed' in preserveSeedList) or ('theSource' in preserveSeedList):
156          pass
157 <      elif 'sourceSeed' in incrementSeedList:
157 >      elif ('sourceSeed' in incrementSeedList) or ('theSource' in incrementSeedList):
158          ranGenerator.sourceSeed = CfgTypes.untracked(CfgTypes.uint32(sourceSeed+nJob))
159        else:
160          ranGenerator.sourceSeed = CfgTypes.untracked(CfgTypes.uint32(_inst.randint(1,_MAXINT)))
# Line 171 | Line 172 | def main(argv) :
172            if curSeed:
173              curValue = int(curSeed.value())
174              setattr(ranGenerator.moduleSeeds,seed,CfgTypes.untracked(CfgTypes.uint32(_inst.randint(1,_MAXINT))))
175 <  else: # Treatment for  seeds, CMSSW 2_1_x and later
176 <    if cfg.data.services.has_key('RandomNumberGeneratorService'):
175 >    elif CMSSW_major > 2 or (CMSSW_major == 2 and CMSSW_minor >= 1): # Treatment for  seeds, CMSSW 2_1_x and later
176 >      print "New-style random number seeds found, will be changed."
177        from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper
177
178      ranGenerator = cfg.data.services['RandomNumberGeneratorService']
178        randSvc = RandomNumberServiceHelper(ranGenerator)
180      # sourceSeed is different from the rest, John says will become "theSource"
181      if 'sourceSeed' in preserveSeedList:
182        pass
183      elif 'sourceSeed' in incrementSeedList:
184        sourceSeed = int(ranGenerator.sourceSeed.value())
185        ranGenerator.sourceSeed = CfgTypes.untracked(CfgTypes.uint32(sourceSeed+nJob))
186      else:
187        ranGenerator.sourceSeed = CfgTypes.untracked(CfgTypes.uint32(_inst.randint(1,_MAXINT)))
179  
180        # Increment requested seed sets
181        for seedName in incrementSeedList:
# Line 195 | Line 186 | def main(argv) :
186  
187        # Randomize remaining seeds
188        randSvc.populate(*preserveSeedList)
189 +    else:
190 +      print "Neither old nor new seed format found!"
191  
192 <  # End version specific code
192 >    # End version specific code
193  
194    # Write out new config file in one format or the other, FUTURE: Get rid of cfg mode
195    outFile = open(outFileName,"w")

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines