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",
83 "Requestor": self.
user,
85 "CMSSWVersion": os.getenv(
'CMSSW_VERSION'),
86 "Campaign": os.getenv(
'CMSSW_VERSION'),
87 "ScramArch": os.getenv(
'SCRAM_ARCH'),
88 "ProcessingVersion": self.
version,
90 "CouchURL": self.
couch,
91 "ConfigCacheURL": self.
couch,
92 "DbsUrl":
"http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet",
98 "unmergedLFNBase" :
"/store/unmerged",
99 "mergedLFNBase" :
"/store/relval",
100 "dashboardActivity" :
"relval",
102 "SizePerEvent" : 1234,
107 "EnableHarvesting" :
"True",
108 "DQMUploadUrl" : self.
dqmgui,
109 "DQMConfigCacheID" :
None
114 "ConfigCacheID" :
None,
116 "SplittingAlgo" :
"EventBased",
117 "EventsPerJob" :
None,
118 "RequestNumEvents" :
None,
119 "Seeding" :
"AutomaticSeeding",
120 "PrimaryDataset" :
None,
125 "TaskName" :
"DigiHLT",
126 "ConfigCacheID" :
None,
128 "InputDataset" :
None,
129 "SplittingAlgo" :
"LumiBased",
137 "InputFromOutputModule" :
None,
138 "ConfigCacheID" :
None,
140 "SplittingAlgo" :
"LumiBased",
149 def prepare(self,mReader, directories, mode='init'):
156 wmsplit[
'RECODreHLT']=2
160 wmsplit[
'DIGIHISt3']=5
161 wmsplit[
'RECOHISt4']=5
162 wmsplit[
'SingleMuPt10_ID']=1
165 wmsplit[
'TTbar_ID']=1
166 wmsplit[
'SingleMuPt10FS_ID']=1
167 wmsplit[
'TTbarFS_ID']=1
172 print "Not set up for step splitting"
176 for (n,dir)
in directories.items():
178 print "inspecting",dir
180 for (x,s)
in mReader.workFlowSteps.items():
193 if 'INPUT' in step
or (
not isinstance(s[2][index],str)):
194 nextHasDSInput=s[2][index]
202 chainDict[
'nowmTasklist'][-1][
'nowmIO']=json.loads(open(
'%s/%s.io'%(dir,step)).
read())
204 print "Failed to find",
'%s/%s.io'%(dir,step),
".The workflows were probably not run on cfg not created"
207 chainDict[
'nowmTasklist'][-1][
'PrimaryDataset']=
'RelVal'+s[1].
split(
'+')[0]
208 if not '--relval' in s[2][index]:
209 print 'Impossible to create task from scratch without splitting information with --relval'
212 arg=s[2][index].
split()
213 ns=
map(int,arg[arg.index(
'--relval')+1].
split(
','))
214 chainDict[
'nowmTasklist'][-1][
'RequestNumEvents'] = ns[0]
215 chainDict[
'nowmTasklist'][-1][
'EventsPerJob'] = ns[1]
216 if 'FASTSIM' in s[2][index]
or '--fast' in s[2][index]:
217 thisLabel+=
'_FastSim'
222 chainDict[
'nowmTasklist'][-1][
'nowmIO']=json.loads(open(
'%s/%s.io'%(dir,step)).
read())
224 print "Failed to find",
'%s/%s.io'%(dir,step),
".The workflows were probably not run on cfg not created"
226 chainDict[
'nowmTasklist'][-1][
'InputDataset']=nextHasDSInput.dataSet
227 splitForThisWf=nextHasDSInput.split
228 chainDict[
'nowmTasklist'][-1][
'LumisPerJob']=splitForThisWf
230 chainDict[
'nowmTasklist'][-1][
'LumisPerJob']=wmsplit[step]
232 if len(nextHasDSInput.run):
233 chainDict[
'nowmTasklist'][-1][
'RunWhitelist']=nextHasDSInput.run
235 if '--data' in s[2][index]
and nextHasDSInput.label:
236 thisLabel+=
'_RelVal_%s'%nextHasDSInput.label
237 if 'filter' in chainDict[
'nowmTasklist'][-1][
'nowmIO']:
238 print "This has an input DS and a filter sequence: very likely to be the PyQuen sample"
239 processStrPrefix=
'PU_'
240 setPrimaryDs =
'RelVal'+s[1].
split(
'+')[0]
242 chainDict[
'nowmTasklist'][-1][
'PrimaryDataset']=setPrimaryDs
248 chainDict[
'nowmTasklist'][-1][
'nowmIO']=json.loads(open(
'%s/%s.io'%(dir,step)).
read())
250 print "Failed to find",
'%s/%s.io'%(dir,step),
".The workflows were probably not run on cfg not created"
253 chainDict[
'nowmTasklist'][-1][
'LumisPerJob']=splitForThisWf
255 chainDict[
'nowmTasklist'][-1][
'LumisPerJob']=wmsplit[step]
258 chainDict[
'nowmTasklist'][-1][
'TaskName']=step
260 chainDict[
'nowmTasklist'][-1][
'PrimaryDataset']=setPrimaryDs
261 chainDict[
'nowmTasklist'][-1][
'ConfigCacheID']=
'%s/%s.py'%(dir,step)
262 chainDict[
'nowmTasklist'][-1][
'GlobalTag']=chainDict[
'nowmTasklist'][-1][
'nowmIO'][
'GT']
263 chainDict[
'GlobalTag']=chainDict[
'nowmTasklist'][-1][
'nowmIO'][
'GT']
264 if 'pileup' in chainDict[
'nowmTasklist'][-1][
'nowmIO']:
265 chainDict[
'nowmTasklist'][-1][
'MCPileup']=chainDict[
'nowmTasklist'][-1][
'nowmIO'][
'pileup']
266 if '--pileup' in s[2][index]:
267 processStrPrefix=
'PU_'
271 chainDict[
'AcquisitionEra'][step]=chainDict[
'CMSSWVersion']
272 chainDict[
'ProcessingString'][step]=processStrPrefix+chainDict[
'nowmTasklist'][-1][
'GlobalTag'].
replace(
'::All',
'')+thisLabel
275 chainDict[
'nowmTasklist'][-1][
'AcquisitionEra']=chainDict[
'CMSSWVersion']
276 chainDict[
'nowmTasklist'][-1][
'ProcessingString']=processStrPrefix+chainDict[
'nowmTasklist'][-1][
'GlobalTag'].
replace(
'::All',
'')+thisLabel
280 chainDict[
'RequestString']=
'RV'+chainDict[
'CMSSWVersion']+s[1].
split(
'+')[0]
281 if processStrPrefix
or thisLabel:
282 chainDict[
'RequestString']+=
'_'+processStrPrefix+thisLabel
291 for i_second
in reversed(range(len(chainDict[
'nowmTasklist']))):
292 t_second=chainDict[
'nowmTasklist'][i_second]
294 if 'primary' in t_second[
'nowmIO']:
296 primary=t_second[
'nowmIO'][
'primary'][0].
replace(
'file:',
'')
297 for i_input
in reversed(range(0,i_second)):
298 t_input=chainDict[
'nowmTasklist'][i_input]
299 for (om,o)
in t_input[
'nowmIO'].items():
302 t_second[
'InputTask'] = t_input[
'TaskName']
303 t_second[
'InputFromOutputModule'] = om
305 if t_second[
'TaskName'].startswith(
'HARVEST'):
307 chainDict[
'DQMConfigCacheID']=t_second[
'ConfigCacheID']
317 chainDict[
'AcquisitionEra'] = chainDict[
'AcquisitionEra'].
values()[0]
323 if type(i)==int
and i < len(chainDict[
'nowmTasklist']):
324 chainDict[
'nowmTasklist'][i][
'KeepOutput']=
True
325 for (i,t)
in enumerate(chainDict[
'nowmTasklist']):
326 if t[
'TaskName'].startswith(
'HARVEST'):
330 elif t[
'TaskName']
in self.
keep:
334 chainDict[
'Task%d'%(itask)]=t
341 chainDict[
'TaskChain']=itask
343 chainDict.pop(
'nowmTasklist')
350 labelInCouch=self.
label+
'_'+label
351 cacheName=filePath.split(
'/')[-1]
354 print '\tFake upload of',filePath,
'to couch with label',labelInCouch
358 from modules.wma
import upload_to_couch,DATABASE_NAME
360 print '\n\tUnable to find wmcontrol modules. Please include it in your python path\n'
365 print "Not re-uploading",filePath,
"to",where,
"for",label
368 print "Loading",filePath,
"to",where,
"for",label
370 pool = multiprocessing.Pool(1)
371 cacheIds = pool.map( upload_to_couch_oneArg, [(filePath,labelInCouch,self.
user,self.
group,where)] )
372 cacheId = cacheIds[0]
377 for (n,d)
in self.chainDicts.items():
379 if it.startswith(
"Task")
and it!=
'TaskChain':
381 couchID=self.
uploadConf(d[it][
'ConfigCacheID'],
382 str(n)+d[it][
'TaskName'],
385 print d[it][
'ConfigCacheID'],
" uploaded to couchDB for",str(n),
"with ID",couchID
386 d[it][
'ConfigCacheID']=couchID
387 if it ==
'DQMConfigCacheID':
388 couchID=self.
uploadConf(d[
'DQMConfigCacheID'],
392 print d[
'DQMConfigCacheID'],
"uploaded to couchDB for",str(n),
"with ID",couchID
393 d[
'DQMConfigCacheID']=couchID
398 from modules.wma
import makeRequest,approveRequest
399 from wmcontrol
import random_sleep
400 print '\n\tFound wmcontrol\n'
402 print '\n\tUnable to find wmcontrol modules. Please include it in your python path\n'
408 for (n,d)
in self.chainDicts.items():
410 print "Only viewing request",n
411 print pprint.pprint(d)
414 print "For eyes before submitting",n
415 print pprint.pprint(d)
416 print "Submitting",n,
"..........."
417 workFlow=makeRequest(self.
wmagent,d,encodeDict=
True)
418 approveRequest(self.
wmagent,workFlow)
419 print "...........",n,
"submitted"
def performInjectionOptionTest
def upload_to_couch_oneArg