本文整理汇总了Python中PSetTweaks.PSetTweak.PSetTweak.addParameter方法的典型用法代码示例。如果您正苦于以下问题:Python PSetTweak.addParameter方法的具体用法?Python PSetTweak.addParameter怎么用?Python PSetTweak.addParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PSetTweaks.PSetTweak.PSetTweak
的用法示例。
在下文中一共展示了PSetTweak.addParameter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handleSeeding
# 需要导入模块: from PSetTweaks.PSetTweak import PSetTweak [as 别名]
# 或者: from PSetTweaks.PSetTweak.PSetTweak import addParameter [as 别名]
def handleSeeding(self):
"""
_handleSeeding_
Handle Random Seed settings for the job
"""
baggage = self.job.getBaggage()
seeding = getattr(baggage, "seeding", None)
if seeding == None:
return
if seeding == "AutomaticSeeding":
from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper
helper = RandomNumberServiceHelper(self.process.RandomNumberGeneratorService)
helper.populate()
return
if seeding == "ReproducibleSeeding":
randService = self.process.RandomNumberGeneratorService
tweak = PSetTweak()
for x in randService:
parameter = "process.RandomNumberGeneratorService.%s.initialSeed" % x._internal_name
tweak.addParameter(parameter, x.initialSeed)
applyTweak(self.process, tweak, self.fixupDict)
return
# still here means bad seeding algo name
raise RuntimeError, "Bad Seeding Algorithm: %s" % seeding
示例2: __call__
# 需要导入模块: from PSetTweaks.PSetTweak import PSetTweak [as 别名]
# 或者: from PSetTweaks.PSetTweak.PSetTweak import addParameter [as 别名]
def __call__(self, process):
tweak = PSetTweak()
# handle process parameters
processParams = []
[ processParams.extend( expandParameter(process, param).keys())
for param in self.processLevel]
[ tweak.addParameter(param, getParameter(process, param))
for param in processParams if hasParameter(process, param) ]
# output modules
tweak.addParameter('process.outputModules_', [])
for outMod in process.outputModules_():
tweak.getParameter('process.outputModules_').append(outMod)
outModRef = getattr(process, outMod)
for param in self.outModLevel:
fullParam = "process.%s.%s" % (outMod, param)
if hasParameter(outModRef, param, True):
tweak.addParameter(
fullParam,
getParameter(outModRef,
param,
True))
return tweak
示例3: testC
# 需要导入模块: from PSetTweaks.PSetTweak import PSetTweak [as 别名]
# 或者: from PSetTweaks.PSetTweak.PSetTweak import addParameter [as 别名]
def testC(self):
"""test building a tweak from the seeds"""
job = Job("TestJob")
seeder = AutomaticSeeding()
job.addBaggageParameter("process.RandomNumberGeneratorService.seed1.initialSeed", 123445)
job.addBaggageParameter("process.RandomNumberGeneratorService.seed2.initialSeed", 123445)
job.addBaggageParameter("process.RandomNumberGeneratorService.seed3.initialSeed", 7464738)
job.addBaggageParameter("process.RandomNumberGeneratorService.seed44.initialSeed", 98273762)
seeder(job)
tweak = PSetTweak()
for x in job.baggage.process.RandomNumberGeneratorService:
parameter = "process.RandomNumberGeneratorService.%s.initialSeed" % x._internal_name
tweak.addParameter(parameter, x.initialSeed)
print(tweak)
示例4: makeTaskTweak
# 需要导入模块: from PSetTweaks.PSetTweak import PSetTweak [as 别名]
# 或者: from PSetTweaks.PSetTweak.PSetTweak import addParameter [as 别名]
def makeTaskTweak(stepSection):
"""
_makeTaskTweak_
Create a tweak for options in the task that apply to all jobs.
"""
result = PSetTweak()
# GlobalTag
if hasattr(stepSection, "application"):
if hasattr(stepSection.application, "configuration"):
if hasattr(stepSection.application.configuration, "arguments"):
globalTag = getattr(stepSection.application.configuration.arguments,
"globalTag", None)
if globalTag != None:
result.addParameter("process.GlobalTag.globaltag", globalTag)
return result
示例5: makeTaskTweak
# 需要导入模块: from PSetTweaks.PSetTweak import PSetTweak [as 别名]
# 或者: from PSetTweaks.PSetTweak.PSetTweak import addParameter [as 别名]
def makeTaskTweak(stepSection):
"""
_makeTaskTweak_
Create a tweak for options in the task that apply to all jobs.
"""
result = PSetTweak()
# GlobalTag
if hasattr(stepSection, "application"):
if hasattr(stepSection.application, "configuration"):
if hasattr(stepSection.application.configuration, "pickledarguments"):
args = pickle.loads(stepSection.application.configuration.pickledarguments)
if args.has_key('globalTag'):
result.addParameter("process.GlobalTag.globaltag", args['globalTag'])
if args.has_key('globalTagTransaction'):
result.addParameter("process.GlobalTag.DBParameters.transactionId", args['globalTagTransaction'])
return result
示例6: handleSeeding
# 需要导入模块: from PSetTweaks.PSetTweak import PSetTweak [as 别名]
# 或者: from PSetTweaks.PSetTweak.PSetTweak import addParameter [as 别名]
def handleSeeding(self):
"""
_handleSeeding_
Handle Random Seed settings for the job
"""
baggage = self.job.getBaggage()
seeding = getattr(baggage, "seeding", None)
if seeding == "ReproducibleSeeding":
randService = self.process.RandomNumberGeneratorService
tweak = PSetTweak()
for x in randService:
parameter = "process.RandomNumberGeneratorService.%s.initialSeed" % x._internal_name
tweak.addParameter(parameter, x.initialSeed)
applyTweak(self.process, tweak, self.fixupDict)
else:
if hasattr(self.process, "RandomNumberGeneratorService"):
from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper
helper = RandomNumberServiceHelper(self.process.RandomNumberGeneratorService)
helper.populate()
return
示例7: makeOutputTweak
# 需要导入模块: from PSetTweaks.PSetTweak import PSetTweak [as 别名]
# 或者: from PSetTweaks.PSetTweak.PSetTweak import addParameter [as 别名]
def makeOutputTweak(outMod, job):
"""
_makeOutputTweak_
Make a PSetTweak for the output module and job instance provided
"""
result = PSetTweak()
# output filenames
modName = str(getattr(outMod, "_internal_name"))
fileName = "%s.root" % modName
result.addParameter("process.%s.fileName" % modName, fileName)
lfnBase = str(getattr(outMod, "lfnBase", None))
if lfnBase != None:
lfn = "%s/%s/%s.root" % (lfnBase, lfnGroup(job), modName)
result.addParameter("process.%s.logicalFileName" % modName, lfn)
# TODO: Nice standard way to meddle with the other parameters in the
# output module based on the settings in the section
return result
示例8: makeJobTweak
# 需要导入模块: from PSetTweaks.PSetTweak import PSetTweak [as 别名]
# 或者: from PSetTweaks.PSetTweak.PSetTweak import addParameter [as 别名]
def makeJobTweak(job):
"""
_makeJobTweak_
Convert information from a WMBS Job object into a PSetTweak
that can be used to modify a CMSSW process.
"""
result = PSetTweak()
baggage = job.getBaggage()
# Check in the baggage if we are processing .lhe files
lheInput = getattr(baggage, "lheInputFiles", False)
# Input files and secondary input files.
primaryFiles = []
secondaryFiles = []
for inputFile in job["input_files"]:
if inputFile["lfn"].startswith("MCFakeFile"):
# If there is a preset lumi in the mask, use it as the first
# luminosity setting
if job['mask'].get('FirstLumi', None) != None:
result.addParameter("process.source.firstLuminosityBlock",
job['mask']['FirstLumi'])
else:
#We don't have lumi information in the mask, raise an exception
raise WMTweakMaskError(job['mask'],
"No first lumi information provided")
continue
primaryFiles.append(inputFile["lfn"])
for secondaryFile in inputFile["parents"]:
secondaryFiles.append(secondaryFile["lfn"])
if len(primaryFiles) > 0:
result.addParameter("process.source.fileNames", primaryFiles)
if len(secondaryFiles) > 0:
result.addParameter("process.source.secondaryFileNames", secondaryFiles)
elif not lheInput:
#First event parameter should be set from whatever the mask says,
#That should have the added protection of not going over 2^32 - 1
#If there is nothing in the mask, then we fallback to the counter method
if job['mask'].get('FirstEvent',None) != None:
result.addParameter("process.source.firstEvent",
job['mask']['FirstEvent'])
else:
#No first event information in the mask, raise and error
raise WMTweakMaskError(job['mask'],
"No first event information provided in the mask")
mask = job['mask']
# event limits
maxEvents = mask.getMaxEvents()
if maxEvents == None: maxEvents = -1
result.addParameter("process.maxEvents.input", maxEvents)
# We don't want to set skip events for MonteCarlo jobs which have
# no input files.
firstEvent = mask['FirstEvent']
if firstEvent != None and firstEvent >= 0 and (len(primaryFiles) > 0 or lheInput):
if lheInput:
result.addParameter("process.source.skipEvents", firstEvent - 1)
else:
result.addParameter("process.source.skipEvents", firstEvent)
firstRun = mask['FirstRun']
if firstRun != None:
result.addParameter("process.source.firstRun", firstRun)
elif not len(primaryFiles):
#Then we have a MC job, we need to set firstRun to 1
logging.debug("MCFakeFile initiated without job FirstRun - using one.")
result.addParameter("process.source.firstRun", 1)
runs = mask.getRunAndLumis()
lumisToProcess = []
for run in runs.keys():
lumiPairs = runs[run]
for lumiPair in lumiPairs:
if len(lumiPair) != 2:
# Do nothing
continue
lumisToProcess.append("%s:%s-%s:%s" % (run, lumiPair[0], run, lumiPair[1]))
if len(lumisToProcess) > 0:
result.addParameter("process.source.lumisToProcess", lumisToProcess)
# install any settings from the per job baggage
procSection = getattr(baggage, "process", None)
if procSection == None:
return result
baggageParams = decomposeConfigSection(procSection)
for k,v in baggageParams.items():
result.addParameter(k,v)
return result