1 from __future__
import print_function
11 print(
'Not injecting to wmagent in --show mode. Need to run the worklfows.')
13 if opt.wmcontrol==
'init':
16 if opt.wmcontrol==
'test':
19 if opt.wmcontrol==
'submit' and opt.nProcs==0:
20 print(
'Not injecting to wmagent in -j 0 mode. Need to run the worklfows.')
22 if opt.wmcontrol==
'force':
23 print(
"This is an expert setting, you'd better know what you're doing")
27 from modules.wma
import upload_to_couch
28 (filePath,labelInCouch,user,group,where) = arguments
29 cacheId=upload_to_couch(filePath,
45 for k
in options.split(
','):
46 if k.startswith(
'dqm:'):
47 self.
dqmgui=k.split(
':',1)[-1]
48 elif k.startswith(
'wma:'):
51 self.
testMode=((mode!=
'submit')
and (mode!=
'force'))
63 self.
wmagent=os.getenv(
'WMAGENT_REQMGR')
69 self.
wmagent =
'cmsweb-testbed.cern.ch' 70 self.
DbsUrl =
"https://"+self.
wmagent+
"/dbs/int/global/DBSReader" 73 self.
dqmgui=
"https://cmsweb.cern.ch/dqm/relval" 78 self.
user = os.getenv(
'USER')
86 if not os.getenv(
'WMCORE_ROOT'):
87 print(
'\n\twmclient is not setup properly. Will not be able to upload or submit requests.\n')
92 print(
'\n\tFound wmclient\n')
95 "RequestType" :
"TaskChain",
96 "SubRequestType" :
"RelVal",
97 "RequestPriority": 500000,
98 "Requestor": self.
user,
100 "CMSSWVersion": os.getenv(
'CMSSW_VERSION'),
101 "Campaign": os.getenv(
'CMSSW_VERSION'),
102 "ScramArch": os.getenv(
'SCRAM_ARCH'),
103 "ProcessingVersion": self.
version,
105 "ConfigCacheUrl": self.
couch,
113 "SizePerEvent" : 1234,
115 "PrepID": os.getenv(
'CMSSW_VERSION')
119 "EnableHarvesting" :
"True",
120 "DQMUploadUrl" : self.
dqmgui,
121 "DQMConfigCacheID" :
None,
127 "ConfigCacheID" :
None,
129 "SplittingAlgo" :
"EventBased",
130 "EventsPerJob" :
None,
131 "RequestNumEvents" :
None,
132 "Seeding" :
"AutomaticSeeding",
133 "PrimaryDataset" :
None,
135 "Multicore" : opt.nThreads,
139 "TaskName" :
"DigiHLT",
140 "ConfigCacheID" :
None,
142 "InputDataset" :
None,
143 "SplittingAlgo" :
"LumiBased",
146 "Multicore" : opt.nThreads,
152 "InputFromOutputModule" :
None,
153 "ConfigCacheID" :
None,
155 "SplittingAlgo" :
"LumiBased",
158 "Multicore" : opt.nThreads,
165 def prepare(self,mReader, directories, mode='init'):
172 wmsplit[
'RECODreHLT']=2
176 wmsplit[
'DIGIUP15_PU50']=1
177 wmsplit[
'RECOUP15_PU50']=1
178 wmsplit[
'DIGIUP15_PU25']=1
179 wmsplit[
'RECOUP15_PU25']=1
180 wmsplit[
'DIGIUP15_PU25HS']=1
181 wmsplit[
'RECOUP15_PU25HS']=1
182 wmsplit[
'DIGIHIMIX']=5
183 wmsplit[
'RECOHIMIX']=5
184 wmsplit[
'RECODSplit']=1
185 wmsplit[
'SingleMuPt10_UP15_ID']=1
186 wmsplit[
'DIGIUP15_ID']=1
187 wmsplit[
'RECOUP15_ID']=1
188 wmsplit[
'TTbar_13_ID']=1
189 wmsplit[
'SingleMuPt10FS_ID']=1
190 wmsplit[
'TTbarFS_ID']=1
191 wmsplit[
'RECODR2_50nsreHLT']=5
192 wmsplit[
'RECODR2_25nsreHLT']=5
193 wmsplit[
'RECODR2_2016reHLT']=5
194 wmsplit[
'RECODR2_50nsreHLT_HIPM']=5
195 wmsplit[
'RECODR2_25nsreHLT_HIPM']=5
196 wmsplit[
'RECODR2_2016reHLT_HIPM']=1
197 wmsplit[
'RECODR2_2016reHLT_skimSingleMu']=1
198 wmsplit[
'RECODR2_2016reHLT_skimDoubleEG']=1
199 wmsplit[
'RECODR2_2016reHLT_skimMuonEG']=1
200 wmsplit[
'RECODR2_2016reHLT_skimJetHT']=1
201 wmsplit[
'RECODR2_2016reHLT_skimMET']=1
202 wmsplit[
'RECODR2_2016reHLT_skimSinglePh']=1
203 wmsplit[
'RECODR2_2016reHLT_skimMuOnia']=1
204 wmsplit[
'RECODR2_2016reHLT_skimSingleMu_HIPM']=1
205 wmsplit[
'RECODR2_2016reHLT_skimDoubleEG_HIPM']=1
206 wmsplit[
'RECODR2_2016reHLT_skimMuonEG_HIPM']=1
207 wmsplit[
'RECODR2_2016reHLT_skimJetHT_HIPM']=1
208 wmsplit[
'RECODR2_2016reHLT_skimMET_HIPM']=1
209 wmsplit[
'RECODR2_2016reHLT_skimSinglePh_HIPM']=1
210 wmsplit[
'RECODR2_2016reHLT_skimMuOnia_HIPM']=1
211 wmsplit[
'RECODR2_2017reHLT_Prompt']=1
212 wmsplit[
'RECODR2_2017reHLT_skimSingleMu_Prompt_Lumi']=1
213 wmsplit[
'RECODR2_2017reHLT_skimDoubleEG_Prompt']=1
214 wmsplit[
'RECODR2_2017reHLT_skimMET_Prompt']=1
215 wmsplit[
'RECODR2_2017reHLT_skimMuOnia_Prompt']=1
216 wmsplit[
'RECODR2_2017reHLT_Prompt_L1TEgDQM']=1
217 wmsplit[
'RECODR2_2018reHLT_Prompt']=1
218 wmsplit[
'RECODR2_2018reHLT_skimSingleMu_Prompt_Lumi']=1
219 wmsplit[
'RECODR2_2018reHLT_skimDoubleEG_Prompt']=1
220 wmsplit[
'RECODR2_2018reHLT_skimJetHT_Prompt']=1
221 wmsplit[
'RECODR2_2018reHLT_skimMET_Prompt']=1
222 wmsplit[
'RECODR2_2018reHLT_skimMuOnia_Prompt']=1
223 wmsplit[
'RECODR2_2018reHLT_skimEGamma_Prompt_L1TEgDQM']=1
224 wmsplit[
'RECODR2_2018reHLT_skimMuonEG_Prompt']=1
225 wmsplit[
'RECODR2_2018reHLT_skimCharmonium_Prompt']=1
226 wmsplit[
'RECODR2_2018reHLT_skimJetHT_Prompt_HEfail']=1
227 wmsplit[
'RECODR2_2018reHLT_skimJetHT_Prompt_BadHcalMitig']=1
228 wmsplit[
'HLTDR2_50ns']=1
229 wmsplit[
'HLTDR2_25ns']=1
230 wmsplit[
'HLTDR2_2016']=1
231 wmsplit[
'HLTDR2_2017']=1
232 wmsplit[
'HLTDR2_2018']=1
233 wmsplit[
'HLTDR2_2018_BadHcalMitig']=1
234 wmsplit[
'Hadronizer']=1
235 wmsplit[
'DIGIUP15']=1
236 wmsplit[
'RECOUP15']=1
237 wmsplit[
'RECOAODUP15']=5
238 wmsplit[
'DBLMINIAODMCUP15NODQM']=5
239 wmsplit[
'DigiFull']=5
240 wmsplit[
'RecoFull']=5
241 wmsplit[
'DigiFullPU']=1
242 wmsplit[
'RecoFullPU']=1
243 wmsplit[
'RECOHID11']=1
244 wmsplit[
'DigiFullTriggerPU_2023D17PU'] = 1
245 wmsplit[
'RecoFullGlobalPU_2023D17PU']=1
246 wmsplit[
'DIGIUP17']=1
247 wmsplit[
'RECOUP17']=1
248 wmsplit[
'DIGIUP17_PU25']=1
249 wmsplit[
'RECOUP17_PU25']=1
250 wmsplit[
'DIGICOS_UP16']=1
251 wmsplit[
'RECOCOS_UP16']=1
252 wmsplit[
'DIGICOS_UP17']=1
253 wmsplit[
'RECOCOS_UP17']=1
254 wmsplit[
'DIGICOS_UP18']=1
255 wmsplit[
'RECOCOS_UP18']=1
256 wmsplit[
'HYBRIDRepackHI2015VR']=1
257 wmsplit[
'HYBRIDZSHI2015']=1
258 wmsplit[
'RECOHID15']=1
263 print(
"Not set up for step splitting")
267 for (n,dir)
in directories.items():
269 print(
"inspecting",dir)
271 for (x,s)
in mReader.workFlowSteps.items():
281 if len( [step
for step
in s[3]
if "HARVESTGEN" in step] )>0:
282 chainDict[
'TimePerEvent']=0.01
283 thisLabel=thisLabel+
"_gen" 285 if len( [step
for step
in s[3]
if "DBLMINIAODMCUP15NODQM" in step] )>0:
286 thisLabel=thisLabel+
"_dblMiniAOD" 292 if 'INPUT' in step
or (
not isinstance(s[2][index],str)):
293 nextHasDSInput=s[2][index]
301 chainDict[
'nowmTasklist'][-1][
'nowmIO']=json.loads(open(
'%s/%s.io'%(dir,step)).read())
303 print(
"Failed to find",
'%s/%s.io'%(dir,step),
".The workflows were probably not run on cfg not created")
306 chainDict[
'nowmTasklist'][-1][
'PrimaryDataset']=
'RelVal'+s[1].
split(
'+')[0]
307 if not '--relval' in s[2][index]:
308 print(
'Impossible to create task from scratch without splitting information with --relval')
311 arg=s[2][index].
split()
312 ns=
map(int,arg[arg.index(
'--relval')+1].
split(
','))
313 chainDict[
'nowmTasklist'][-1][
'RequestNumEvents'] = ns[0]
314 chainDict[
'nowmTasklist'][-1][
'EventsPerJob'] = ns[1]
315 if 'FASTSIM' in s[2][index]
or '--fast' in s[2][index]:
316 thisLabel+=
'_FastSim' 317 if 'lhe' in s[2][index]
in s[2][index]:
318 chainDict[
'nowmTasklist'][-1][
'LheInputFiles'] =
True 323 chainDict[
'nowmTasklist'][-1][
'nowmIO']=json.loads(open(
'%s/%s.io'%(dir,step)).read())
325 print(
"Failed to find",
'%s/%s.io'%(dir,step),
".The workflows were probably not run on cfg not created")
327 chainDict[
'nowmTasklist'][-1][
'InputDataset']=nextHasDSInput.dataSet
328 if (
'DQMHLTonRAWAOD' in step) :
329 chainDict[
'nowmTasklist'][-1][
'IncludeParents']=
True 330 splitForThisWf=nextHasDSInput.split
331 chainDict[
'nowmTasklist'][-1][
'LumisPerJob']=splitForThisWf
333 chainDict[
'nowmTasklist'][-1][
'LumisPerJob']=wmsplit[step]
335 if len(nextHasDSInput.run):
336 chainDict[
'nowmTasklist'][-1][
'RunWhitelist']=nextHasDSInput.run
337 if len(nextHasDSInput.ls):
338 chainDict[
'nowmTasklist'][-1][
'LumiList']=nextHasDSInput.ls
340 if '--data' in s[2][index]
and nextHasDSInput.label:
341 thisLabel+=
'_RelVal_%s'%nextHasDSInput.label
342 if 'filter' in chainDict[
'nowmTasklist'][-1][
'nowmIO']:
343 print(
"This has an input DS and a filter sequence: very likely to be the PyQuen sample")
344 processStrPrefix=
'PU_' 345 setPrimaryDs =
'RelVal'+s[1].
split(
'+')[0]
347 chainDict[
'nowmTasklist'][-1][
'PrimaryDataset']=setPrimaryDs
353 chainDict[
'nowmTasklist'][-1][
'nowmIO']=json.loads(open(
'%s/%s.io'%(dir,step)).read())
355 print(
"Failed to find",
'%s/%s.io'%(dir,step),
".The workflows were probably not run on cfg not created")
358 chainDict[
'nowmTasklist'][-1][
'LumisPerJob']=splitForThisWf
360 chainDict[
'nowmTasklist'][-1][
'LumisPerJob']=wmsplit[step]
363 if 'Hadronizer' in step:
364 chainDict[
'nowmTasklist'][-1][
'LumisPerJob']=wmsplit[
'Hadronizer']
367 chainDict[
'nowmTasklist'][-1][
'TaskName']=step
369 chainDict[
'nowmTasklist'][-1][
'PrimaryDataset']=setPrimaryDs
370 chainDict[
'nowmTasklist'][-1][
'ConfigCacheID']=
'%s/%s.py'%(dir,step)
371 chainDict[
'nowmTasklist'][-1][
'GlobalTag']=chainDict[
'nowmTasklist'][-1][
'nowmIO'][
'GT']
372 chainDict[
'GlobalTag']=chainDict[
'nowmTasklist'][-1][
'nowmIO'][
'GT']
373 if 'NANOEDM' in step :
374 nanoedmGT = chainDict[
'nowmTasklist'][-1][
'nowmIO'][
'GT']
375 if 'NANOMERGE' in step :
376 chainDict[
'GlobalTag'] = nanoedmGT
377 if 'pileup' in chainDict[
'nowmTasklist'][-1][
'nowmIO']:
378 chainDict[
'nowmTasklist'][-1][
'MCPileup']=chainDict[
'nowmTasklist'][-1][
'nowmIO'][
'pileup']
379 if '--pileup ' in s[2][index]:
380 processStrPrefix=
'PU_' 382 processStrPrefix=
'PU25ns_' 384 processStrPrefix=
'PU50ns_' 385 if 'premix_stage2' in s[2][index]
and '--pileup_input' in s[2][index]:
387 processStrPrefix=
'PUpmx25ns_' 388 elif s[2][index].
split()[ s[2][index].
split().
index(
'--pileup_input')+1 ].
find(
'50ns') > 0 :
389 processStrPrefix=
'PUpmx50ns_' 393 chainDict[
'AcquisitionEra'][step]=chainDict[
'CMSSWVersion']
394 chainDict[
'ProcessingString'][step]=processStrPrefix+chainDict[
'nowmTasklist'][-1][
'GlobalTag'].
replace(
'::All',
'').
replace(
'-',
'_')+thisLabel
395 if 'NANOMERGE' in step :
396 chainDict[
'ProcessingString'][step]=processStrPrefix+nanoedmGT.replace(
'::All',
'').
replace(
'-',
'_')+thisLabel
399 chainDict[
'nowmTasklist'][-1][
'AcquisitionEra']=chainDict[
'CMSSWVersion']
400 chainDict[
'nowmTasklist'][-1][
'ProcessingString']=processStrPrefix+chainDict[
'nowmTasklist'][-1][
'GlobalTag'].
replace(
'::All',
'').
replace(
'-',
'_')+thisLabel
401 if 'NANOMERGE' in step :
402 chainDict[
'nowmTasklist'][-1][
'ProcessingString']=processStrPrefix+nanoedmGT.replace(
'::All',
'').
replace(
'-',
'_')+thisLabel
405 chainDict[
'nowmTasklist'][-1][
'Campaign'] = chainDict[
'nowmTasklist'][-1][
'AcquisitionEra']+self.
batchName 408 if (
'DBLMINIAODMCUP15NODQM' in step):
409 chainDict[
'nowmTasklist'][-1][
'ProcessingString']=chainDict[
'nowmTasklist'][-1][
'ProcessingString']+
'_miniAOD' 411 if( chainDict[
'nowmTasklist'][-1][
'Multicore'] ):
418 chainDict[
'nowmTasklist'][-1][
'Memory'] = self.
memoryOffset +
int( chainDict[
'nowmTasklist'][-1][
'Multicore'] -1 ) * self.
memPerCore 422 chainDict[
'RequestString']=
'RV'+chainDict[
'CMSSWVersion']+s[1].
split(
'+')[0]
423 if processStrPrefix
or thisLabel:
424 chainDict[
'RequestString']+=
'_'+processStrPrefix+thisLabel
427 chainDict[
'PrepID'] = chainDict[
'CMSSWVersion']+
'__'+self.
batchTime+
'-'+s[1].
split(
'+')[0]
429 chainDict[
'PrepID'] = chainDict[
'CMSSWVersion']+self.
batchName+
'-'+s[1].
split(
'+')[0]
431 chainDict[
'SubRequestType'] =
"HIRelVal" 438 for i_second
in reversed(range(len(chainDict[
'nowmTasklist']))):
439 t_second=chainDict[
'nowmTasklist'][i_second]
441 if 'primary' in t_second[
'nowmIO']:
443 primary=t_second[
'nowmIO'][
'primary'][0].
replace(
'file:',
'')
444 for i_input
in reversed(range(0,i_second)):
445 t_input=chainDict[
'nowmTasklist'][i_input]
446 for (om,o)
in t_input[
'nowmIO'].
items():
449 t_second[
'InputTask'] = t_input[
'TaskName']
450 t_second[
'InputFromOutputModule'] = om
452 if t_second[
'TaskName'].startswith(
'HARVEST'):
454 chainDict[
'DQMConfigCacheID']=t_second[
'ConfigCacheID']
474 chainDict[
'AcquisitionEra'] = chainDict[
'AcquisitionEra'].
values()[0]
475 chainDict[
'ProcessingString'] = chainDict[
'ProcessingString'].
values()[0]
477 chainDict[
'AcquisitionEra'] = chainDict[
'nowmTasklist'][0][
'AcquisitionEra']
478 chainDict[
'ProcessingString'] = chainDict[
'nowmTasklist'][0][
'ProcessingString']
482 chainDict[
'Campaign'] = chainDict[
'AcquisitionEra']+self.
batchName 488 if isinstance(i, int)
and i < len(chainDict[
'nowmTasklist']):
489 chainDict[
'nowmTasklist'][i][
'KeepOutput']=
True 490 for (i,t)
in enumerate(chainDict[
'nowmTasklist']):
491 if t[
'TaskName'].startswith(
'HARVEST'):
495 elif t[
'TaskName']
in self.
keep:
497 if t[
'TaskName'].startswith(
'HYBRIDRepackHI2015VR'):
498 t[
'KeepOutput']=
False 501 chainDict[
'Task%d'%(itask)]=t
508 chainDict[
'TaskChain']=itask
510 chainDict.pop(
'nowmTasklist')
517 labelInCouch=self.
label+
'_'+label
518 cacheName=filePath.split(
'/')[-1]
521 print(
'\tFake upload of',filePath,
'to couch with label',labelInCouch)
525 from modules.wma
import upload_to_couch,DATABASE_NAME
527 print(
'\n\tUnable to find wmcontrol modules. Please include it in your python path\n')
532 print(
"Not re-uploading",filePath,
"to",where,
"for",label)
535 print(
"Loading",filePath,
"to",where,
"for",label)
537 pool = multiprocessing.Pool(1)
538 cacheIds = pool.map( upload_to_couch_oneArg, [(filePath,labelInCouch,self.
user,self.
group,where)] )
539 cacheId = cacheIds[0]
544 for (n,d)
in self.chainDicts.items():
546 if it.startswith(
"Task")
and it!=
'TaskChain':
548 couchID=self.
uploadConf(d[it][
'ConfigCacheID'],
549 str(n)+d[it][
'TaskName'],
552 print(d[it][
'ConfigCacheID'],
" uploaded to couchDB for",
str(n),
"with ID",couchID)
553 d[it][
'ConfigCacheID']=couchID
554 if it ==
'DQMConfigCacheID':
555 couchID=self.
uploadConf(d[
'DQMConfigCacheID'],
559 print(d[
'DQMConfigCacheID'],
"uploaded to couchDB for",
str(n),
"with ID",couchID)
560 d[
'DQMConfigCacheID']=couchID
565 from modules.wma
import makeRequest,approveRequest
566 from wmcontrol
import random_sleep
567 print(
'\n\tFound wmcontrol\n')
569 print(
'\n\tUnable to find wmcontrol modules. Please include it in your python path\n')
575 for (n,d)
in self.chainDicts.items():
577 print(
"Only viewing request",n)
578 print(pprint.pprint(d))
581 print(
"For eyes before submitting",n)
582 print(pprint.pprint(d))
583 print(
"Submitting",n,
"...........")
584 workFlow=makeRequest(self.
wmagent,d,encodeDict=
True)
585 print(
"...........",n,
"submitted")
def prepare(self, mReader, directories, mode='init')
def performInjectionOptionTest(opt)
def uploadConf(self, filePath, label, where)
the info are not in the task specific dict but in the general dict t_input.update(copy.deepcopy(self.defaultHarvest)) t_input['DQMConfigCacheID']=t_second['ConfigCacheID']
def replace(string, replacements)
S & print(S &os, JobReport::InputFile const &f)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def __init__(self, opt, mode='init', options='')
def upload_to_couch_oneArg(arguments)