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() |
146 |
|
if maxEvents: |
147 |
|
cfg.maxEvents.setMaxEventsInput(maxEvents) |
148 |
|
|
149 |
< |
if skipEvents: |
149 |
> |
if skipEvents and inModule.sourceType not in ['EmptySource']: |
150 |
|
inModule.setSkipEvents(skipEvents) |
151 |
|
|
152 |
|
# Set "skip events" for various generators |
185 |
|
print "RandomNumberGeneratorService found, will attempt to change seeds" |
186 |
|
from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper |
187 |
|
ranGenerator = cfg.data.services['RandomNumberGeneratorService'] |
188 |
+ |
|
189 |
+ |
ranModules = getattr(ranGenerator, "moduleSeeds", None) |
190 |
+ |
oldSource = getattr(ranGenerator, "sourceSeed", None) |
191 |
+ |
if ranModules != None or oldSource != None: |
192 |
+ |
msg = "Your random number seeds are set in an old,\n" |
193 |
+ |
msg += "deprecated style. Please change to new style:\n" |
194 |
+ |
msg += "https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideEDMRandomNumberGeneratorService" |
195 |
+ |
raise ConfigException(msg) |
196 |
+ |
|
197 |
|
randSvc = RandomNumberServiceHelper(ranGenerator) |
198 |
|
|
199 |
|
incrementSeedList = [] |
215 |
|
randSvc.populate(*preserveSeedList) |
216 |
|
|
217 |
|
# Write out new config file |
218 |
+ |
pklFileName = outFileName + '.pkl' |
219 |
|
outFile = open(outFileName,"w") |
220 |
|
outFile.write("import FWCore.ParameterSet.Config as cms\n") |
221 |
|
outFile.write("import pickle\n") |
222 |
< |
outFile.write("pickledCfg=\"\"\"%s\"\"\"\n" % pickle.dumps(cmsProcess)) |
214 |
< |
outFile.write("process = pickle.loads(pickledCfg)\n") |
222 |
> |
outFile.write("process = pickle.load(open('%s', 'rb'))\n" % pklFileName) |
223 |
|
outFile.close() |
224 |
+ |
|
225 |
+ |
pklFile = open(pklFileName,"wb") |
226 |
+ |
myPickle = pickle.Pickler(pklFile) |
227 |
+ |
myPickle.dump(cmsProcess) |
228 |
+ |
pklFile.close() |
229 |
+ |
|
230 |
|
if (debug): |
231 |
|
print "writeCfg output (May not be exact):" |
232 |
|
print "import FWCore.ParameterSet.Config as cms" |