9 print 'Not injecting to wmagent in --show mode. Need to run the worklfows.'
11 if opt.wmcontrol==
'init':
14 if opt.wmcontrol==
'test':
17 if opt.wmcontrol==
'submit' and opt.nThreads==0:
18 print 'Not injecting to wmagent in -j 0 mode. Need to run the worklfows.'
20 if opt.wmcontrol==
'force':
21 print "This is an expert setting, you'd better know what you're doing"
25 from modules.wma
import upload_to_couch
26 (filePath,labelInCouch,user,group,where) = arguments
27 cacheId=upload_to_couch(filePath,
43 for k
in options.split(
','):
44 if k.startswith(
'dqm:'):
45 self.
dqmgui=k.split(
':',1)[-1]
46 elif k.startswith(
'wma:'):
49 self.
testMode=((mode!=
'submit')
and (mode!=
'force'))
55 self.
wmagent=os.getenv(
'WMAGENT_REQMGR')
60 self.
dqmgui=
"https://cmsweb.cern.ch/dqm/relval"
65 self.
user = os.getenv(
'USER')
73 if not os.getenv(
'WMCORE_ROOT'):
74 print '\n\twmclient is not setup properly. Will not be able to upload or submit requests.\n'
79 print '\n\tFound wmclient\n'
82 "RequestType" :
"TaskChain",
84 "ProcessingString": {},
85 "Requestor": self.
user,
87 "CMSSWVersion": os.getenv(
'CMSSW_VERSION'),
88 "Campaign": os.getenv(
'CMSSW_VERSION'),
89 "ScramArch": os.getenv(
'SCRAM_ARCH'),
90 "ProcessingVersion": self.
version,
92 "CouchURL": self.
couch,
93 "ConfigCacheURL": self.
couch,
94 "DbsUrl":
"http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet",
97 "SiteWhitelist" : [
"T2_CH_CERN",
"T1_US_FNAL"],
100 "unmergedLFNBase" :
"/store/unmerged",
101 "mergedLFNBase" :
"/store/relval",
102 "dashboardActivity" :
"relval",
104 "SizePerEvent" : 1234,
109 "EnableDQMHarvest" : 1,
110 "DQMUploadUrl" : self.
dqmgui,
111 "DQMConfigCacheID" :
None
116 "ConfigCacheID" :
None,
118 "SplittingAlgorithm" :
"EventBased",
119 "SplittingArguments" : {
"events_per_job" :
None},
120 "RequestNumEvents" :
None,
121 "Seeding" :
"AutomaticSeeding",
122 "PrimaryDataset" :
None,
127 "TaskName" :
"DigiHLT",
128 "ConfigCacheID" :
None,
130 "InputDataset" :
None,
131 "SplittingAlgorithm" :
"LumiBased",
132 "SplittingArguments" : {
"lumis_per_job" : 10},
139 "InputFromOutputModule" :
None,
140 "ConfigCacheID" :
None,
142 "SplittingAlgorithm" :
"LumiBased",
143 "SplittingArguments" : {
"lumis_per_job" : 10},
151 def prepare(self,mReader, directories, mode='init'):
158 wmsplit[
'RECODreHLT']=2
162 wmsplit[
'DIGIHISt3']=5
163 wmsplit[
'RECOHISt4']=5
164 wmsplit[
'SingleMuPt10_ID']=1
167 wmsplit[
'TTbar_ID']=1
168 wmsplit[
'SingleMuPt10FS_ID']=1
169 wmsplit[
'TTbarFS_ID']=1
174 print "Not set up for step splitting"
178 for (n,dir)
in directories.items():
180 print "inspecting",dir
182 for (x,s)
in mReader.workFlowSteps.items():
195 if 'INPUT' in step
or (
not isinstance(s[2][index],str)):
196 nextHasDSInput=s[2][index]
204 chainDict[
'nowmTasklist'][-1][
'nowmIO']=json.loads(open(
'%s/%s.io'%(dir,step)).
read())
206 print "Failed to find",
'%s/%s.io'%(dir,step),
".The workflows were probably not run on cfg not created"
209 chainDict[
'nowmTasklist'][-1][
'PrimaryDataset']=
'RelVal'+s[1].
split(
'+')[0]
210 if not '--relval' in s[2][index]:
211 print 'Impossible to create task from scratch without splitting information with --relval'
214 arg=s[2][index].
split()
215 ns=
map(int,arg[arg.index(
'--relval')+1].
split(
','))
216 chainDict[
'nowmTasklist'][-1][
'RequestNumEvents'] = ns[0]
217 chainDict[
'nowmTasklist'][-1][
'SplittingArguments'][
'events_per_job'] = ns[1]
218 if 'FASTSIM' in s[2][index]
or '--fast' in s[2][index]:
219 thisLabel+=
'_FastSim'
224 chainDict[
'nowmTasklist'][-1][
'nowmIO']=json.loads(open(
'%s/%s.io'%(dir,step)).
read())
226 print "Failed to find",
'%s/%s.io'%(dir,step),
".The workflows were probably not run on cfg not created"
228 chainDict[
'nowmTasklist'][-1][
'InputDataset']=nextHasDSInput.dataSet
229 splitForThisWf=nextHasDSInput.split
230 chainDict[
'nowmTasklist'][-1][
'SplittingArguments'][
'lumis_per_job']=splitForThisWf
232 chainDict[
'nowmTasklist'][-1][
'SplittingArguments'][
'lumis_per_job']=wmsplit[step]
234 if len(nextHasDSInput.run):
235 chainDict[
'nowmTasklist'][-1][
'RunWhitelist']=nextHasDSInput.run
237 if '--data' in s[2][index]
and nextHasDSInput.label:
238 thisLabel+=
'_RelVal_%s'%nextHasDSInput.label
239 if 'filter' in chainDict[
'nowmTasklist'][-1][
'nowmIO']:
240 print "This has an input DS and a filter sequence: very likely to be the PyQuen sample"
241 processStrPrefix=
'PU_'
242 setPrimaryDs =
'RelVal'+s[1].
split(
'+')[0]
244 chainDict[
'nowmTasklist'][-1][
'PrimaryDataset']=setPrimaryDs
250 chainDict[
'nowmTasklist'][-1][
'nowmIO']=json.loads(open(
'%s/%s.io'%(dir,step)).
read())
252 print "Failed to find",
'%s/%s.io'%(dir,step),
".The workflows were probably not run on cfg not created"
255 chainDict[
'nowmTasklist'][-1][
'SplittingArguments'][
'lumis_per_job']=splitForThisWf
257 chainDict[
'nowmTasklist'][-1][
'SplittingArguments'][
'lumis_per_job']=wmsplit[step]
260 chainDict[
'nowmTasklist'][-1][
'TaskName']=step
262 chainDict[
'nowmTasklist'][-1][
'PrimaryDataset']=setPrimaryDs
263 chainDict[
'nowmTasklist'][-1][
'ConfigCacheID']=
'%s/%s.py'%(dir,step)
264 chainDict[
'nowmTasklist'][-1][
'GlobalTag']=chainDict[
'nowmTasklist'][-1][
'nowmIO'][
'GT']
265 chainDict[
'GlobalTag']=chainDict[
'nowmTasklist'][-1][
'nowmIO'][
'GT']
266 if 'pileup' in chainDict[
'nowmTasklist'][-1][
'nowmIO']:
267 chainDict[
'nowmTasklist'][-1][
'MCPileup']=chainDict[
'nowmTasklist'][-1][
'nowmIO'][
'pileup']
268 if '--pileup' in s[2][index]:
269 processStrPrefix=
'PU_'
273 chainDict[
'AcquisitionEra'][step]=chainDict[
'CMSSWVersion']
274 chainDict[
'ProcessingString'][step]=processStrPrefix+chainDict[
'nowmTasklist'][-1][
'GlobalTag'].
replace(
'::All',
'')+thisLabel
277 chainDict[
'nowmTasklist'][-1][
'AcquisitionEra']=chainDict[
'CMSSWVersion']
278 chainDict[
'nowmTasklist'][-1][
'ProcessingString']=processStrPrefix+chainDict[
'nowmTasklist'][-1][
'GlobalTag'].
replace(
'::All',
'')+thisLabel
282 chainDict[
'RequestString']=
'RV'+chainDict[
'CMSSWVersion']+s[1].
split(
'+')[0]
283 if processStrPrefix
or thisLabel:
284 chainDict[
'RequestString']+=
'_'+processStrPrefix+thisLabel
293 for i_second
in reversed(range(len(chainDict[
'nowmTasklist']))):
294 t_second=chainDict[
'nowmTasklist'][i_second]
296 if 'primary' in t_second[
'nowmIO']:
298 primary=t_second[
'nowmIO'][
'primary'][0].
replace(
'file:',
'')
299 for i_input
in reversed(range(0,i_second)):
300 t_input=chainDict[
'nowmTasklist'][i_input]
301 for (om,o)
in t_input[
'nowmIO'].items():
304 t_second[
'InputTask'] = t_input[
'TaskName']
305 t_second[
'InputFromOutputModule'] = om
307 if t_second[
'TaskName'].startswith(
'HARVEST'):
309 chainDict[
'DQMConfigCacheID']=t_second[
'ConfigCacheID']
319 chainDict[
'AcquisitionEra'] = chainDict[
'AcquisitionEra'].
values()[0]
325 if type(i)==int
and i < len(chainDict[
'nowmTasklist']):
326 chainDict[
'nowmTasklist'][i][
'KeepOutput']=
True
327 for (i,t)
in enumerate(chainDict[
'nowmTasklist']):
328 if t[
'TaskName'].startswith(
'HARVEST'):
332 elif t[
'TaskName']
in self.
keep:
336 chainDict[
'Task%d'%(itask)]=t
343 chainDict[
'TaskChain']=itask
345 chainDict.pop(
'nowmTasklist')
352 labelInCouch=self.
label+
'_'+label
353 cacheName=filePath.split(
'/')[-1]
356 print '\tFake upload of',filePath,
'to couch with label',labelInCouch
360 from modules.wma
import upload_to_couch,DATABASE_NAME
362 print '\n\tUnable to find wmcontrol modules. Please include it in your python path\n'
367 print "Not re-uploading",filePath,
"to",where,
"for",label
370 print "Loading",filePath,
"to",where,
"for",label
372 pool = multiprocessing.Pool(1)
373 cacheIds = pool.map( upload_to_couch_oneArg, [(filePath,labelInCouch,self.
user,self.
group,where)] )
374 cacheId = cacheIds[0]
379 for (n,d)
in self.chainDicts.items():
381 if it.startswith(
"Task")
and it!=
'TaskChain':
383 couchID=self.
uploadConf(d[it][
'ConfigCacheID'],
384 str(n)+d[it][
'TaskName'],
387 print d[it][
'ConfigCacheID'],
" uploaded to couchDB for",str(n),
"with ID",couchID
388 d[it][
'ConfigCacheID']=couchID
389 if it ==
'DQMConfigCacheID':
390 couchID=self.
uploadConf(d[
'DQMConfigCacheID'],
394 print d[
'DQMConfigCacheID'],
"uploaded to couchDB for",str(n),
"with ID",couchID
395 d[
'DQMConfigCacheID']=couchID
400 from modules.wma
import makeRequest,approveRequest
401 from wmcontrol
import random_sleep
402 print '\n\tFound wmcontrol\n'
404 print '\n\tUnable to find wmcontrol modules. Please include it in your python path\n'
410 for (n,d)
in self.chainDicts.items():
412 print "Only viewing request",n
413 print pprint.pprint(d)
416 print "For eyes before submitting",n
417 print pprint.pprint(d)
418 print "Submitting",n,
"..........."
419 workFlow=makeRequest(self.
wmagent,d,encodeDict=
True)
420 approveRequest(self.
wmagent,workFlow)
421 print "...........",n,
"submitted"
def performInjectionOptionTest
def upload_to_couch_oneArg