6 |
|
import PsetManipulator |
7 |
|
|
8 |
|
import DBSInfo_EDM |
9 |
– |
#from DataDiscovery_EDM import DataDiscovery_EDM |
9 |
|
import DataDiscovery_EDM |
11 |
– |
#from DataLocation_EDM import DataLocation_EDM |
10 |
|
import DataLocation_EDM |
11 |
|
import Scram |
12 |
|
|
21 |
|
# Marco. |
22 |
|
self._params = {} |
23 |
|
self.cfg_params = cfg_params |
26 |
– |
|
24 |
|
log = common.logger |
25 |
|
|
26 |
|
self.scram = Scram.Scram(cfg_params) |
32 |
|
|
33 |
|
|
34 |
|
self.version = self.scram.getSWVersion() |
35 |
+ |
self.setParam_('application', self.version) |
36 |
|
common.analisys_common_info['sw_version'] = self.version |
37 |
|
### FEDE |
38 |
|
common.analisys_common_info['copy_input_data'] = 0 |
40 |
|
|
41 |
|
### collect Data cards |
42 |
|
try: |
43 |
< |
# self.owner = cfg_params['CMSSW.owner'] |
44 |
< |
# log.debug(6, "CMSSW::CMSSW(): owner = "+self.owner) |
45 |
< |
# self.dataset = cfg_params['CMSSW.dataset'] |
46 |
< |
self.datasetPath = cfg_params['CMSSW.datasetpath'] |
47 |
< |
log.debug(6, "CMSSW::CMSSW(): datasetPath = "+self.datasetPath) |
43 |
> |
tmp = cfg_params['CMSSW.datasetpath'] |
44 |
> |
log.debug(6, "CMSSW::CMSSW(): datasetPath = "+tmp) |
45 |
> |
if string.lower(tmp)=='none': |
46 |
> |
self.datasetPath = None |
47 |
> |
else: |
48 |
> |
self.datasetPath = tmp |
49 |
|
except KeyError: |
51 |
– |
# msg = "Error: owner and/or dataset not defined " |
50 |
|
msg = "Error: datasetpath not defined " |
51 |
|
raise CrabException(msg) |
52 |
+ |
|
53 |
+ |
# ML monitoring |
54 |
+ |
# split dataset path style: /PreProdR3Minbias/SIM/GEN-SIM |
55 |
+ |
if not self.datasetPath: |
56 |
+ |
self.setParam_('dataset', 'None') |
57 |
+ |
self.setParam_('owner', 'None') |
58 |
+ |
else: |
59 |
+ |
datasetpath_split = self.datasetPath.split("/") |
60 |
+ |
self.setParam_('dataset', datasetpath_split[1]) |
61 |
+ |
self.setParam_('owner', datasetpath_split[-1]) |
62 |
+ |
|
63 |
+ |
self.setTaskid_() |
64 |
+ |
self.setParam_('taskId', self.cfg_params['taskId']) |
65 |
+ |
|
66 |
|
self.dataTiers = [] |
55 |
– |
# try: |
56 |
– |
# tmpDataTiers = string.split(cfg_params['CMSSW.data_tier'],',') |
57 |
– |
# for tmp in tmpDataTiers: |
58 |
– |
# tmp=string.strip(tmp) |
59 |
– |
# self.dataTiers.append(tmp) |
60 |
– |
# pass |
61 |
– |
# pass |
62 |
– |
# except KeyError: |
63 |
– |
# pass |
64 |
– |
# log.debug(6, "Cmssw::Cmssw(): dataTiers = "+str(self.dataTiers)) |
67 |
|
|
68 |
|
## now the application |
69 |
|
try: |
70 |
|
self.executable = cfg_params['CMSSW.executable'] |
71 |
+ |
self.setParam_('exe', self.executable) |
72 |
|
log.debug(6, "CMSSW::CMSSW(): executable = "+self.executable) |
73 |
|
msg = "Default executable cmsRun overridden. Switch to " + self.executable |
74 |
|
log.debug(3,msg) |
75 |
|
except KeyError: |
76 |
|
self.executable = 'cmsRun' |
77 |
+ |
self.setParam_('exe', self.executable) |
78 |
|
msg = "User executable not defined. Use cmsRun" |
79 |
|
log.debug(3,msg) |
80 |
|
pass |
109 |
|
|
110 |
|
# script_exe file as additional file in inputSandbox |
111 |
|
try: |
112 |
< |
self.scriptExe = cfg_params['USER.script_exe'] |
113 |
< |
self.additional_inbox_files.append(self.scriptExe) |
112 |
> |
self.scriptExe = cfg_params['USER.script_exe'] |
113 |
> |
self.additional_inbox_files.append(self.scriptExe) |
114 |
> |
if self.scriptExe != '': |
115 |
> |
if not os.path.isfile(self.scriptExe): |
116 |
> |
msg ="WARNING. file "+self.scriptExe+" not found" |
117 |
> |
raise CrabException(msg) |
118 |
|
except KeyError: |
119 |
|
pass |
112 |
– |
if self.scriptExe != '': |
113 |
– |
if os.path.isfile(self.scriptExe): |
114 |
– |
pass |
115 |
– |
else: |
116 |
– |
log.message("WARNING. file "+self.scriptExe+" not found") |
117 |
– |
sys.exit() |
120 |
|
|
121 |
|
## additional input files |
122 |
|
try: |
131 |
|
except KeyError: |
132 |
|
pass |
133 |
|
|
134 |
+ |
# files per job |
135 |
|
try: |
136 |
|
self.filesPerJob = int(cfg_params['CMSSW.files_per_jobs']) #Daniele |
137 |
+ |
self.selectFilesPerJob = 1 |
138 |
|
except KeyError: |
139 |
< |
self.filesPerJob = 1 |
139 |
> |
self.filesPerJob = 0 |
140 |
> |
self.selectFilesPerJob = 0 |
141 |
|
|
142 |
< |
## Max event will be total_number_of_events ??? Daniele |
142 |
> |
## Events per job |
143 |
|
try: |
144 |
< |
self.maxEv = cfg_params['CMSSW.event_per_job'] |
144 |
> |
self.eventsPerJob =int( cfg_params['CMSSW.events_per_job']) |
145 |
> |
self.selectEventsPerJob = 1 |
146 |
|
except KeyError: |
147 |
< |
self.maxEv = "-1" |
148 |
< |
## |
147 |
> |
self.eventsPerJob = -1 |
148 |
> |
self.selectEventsPerJob = 0 |
149 |
> |
|
150 |
> |
# To be implemented |
151 |
> |
# ## number of jobs |
152 |
> |
# try: |
153 |
> |
# self.numberOfJobs =int( cfg_params['CMSSW.number_of_job']) |
154 |
> |
# self.selectNumberOfJobs = 1 |
155 |
> |
# except KeyError: |
156 |
> |
# self.selectNumberOfJobs = 0 |
157 |
> |
|
158 |
> |
if (self.selectFilesPerJob == self.selectEventsPerJob): |
159 |
> |
msg = 'Must define either files_per_jobs or events_per_job' |
160 |
> |
raise CrabException(msg) |
161 |
> |
|
162 |
> |
if (self.selectEventsPerJob and not self.datasetPath == None): |
163 |
> |
msg = 'Splitting according to events_per_job available only with None as datasetpath' |
164 |
> |
raise CrabException(msg) |
165 |
> |
|
166 |
|
try: |
167 |
|
self.total_number_of_events = int(cfg_params['CMSSW.total_number_of_events']) |
168 |
|
except KeyError: |
207 |
|
self.maxEvents=0 # max events available ( --> check the requested nb. of evts in Creator.py) |
208 |
|
self.DBSPaths={} # all dbs paths requested ( --> input to the site local discovery script) |
209 |
|
## Perform the data location and discovery (based on DBS/DLS) |
210 |
< |
self.DataDiscoveryAndLocation(cfg_params) |
210 |
> |
## SL: Don't if NONE is specified as input (pythia use case) |
211 |
> |
common.analisys_common_info['sites']=None |
212 |
> |
if self.datasetPath: |
213 |
> |
self.DataDiscoveryAndLocation(cfg_params) |
214 |
|
#DBSDLS-end |
215 |
|
|
216 |
|
self.tgzNameWithPath = self.getTarBall(self.executable) |
217 |
|
|
218 |
< |
self.jobSplitting() #Daniele job Splitting |
219 |
< |
self.PsetEdit.maxEvent(self.maxEv) #Daniele |
220 |
< |
self.PsetEdit.inputModule("INPUT") #Daniele |
218 |
> |
# modify Pset |
219 |
> |
if (self.datasetPath): # standard job |
220 |
> |
self.PsetEdit.maxEvent(self.eventsPerJob) #Daniele |
221 |
> |
self.PsetEdit.inputModule("INPUT") #Daniele |
222 |
> |
|
223 |
> |
else: # pythia like job |
224 |
> |
self.PsetEdit.maxEvent(self.eventsPerJob) #Daniele |
225 |
> |
self.PsetEdit.pythiaSeed("INPUT") #Daniele |
226 |
> |
try: |
227 |
> |
self.sourceSeed = int(cfg_params['CMSSW.pythia_seed']) |
228 |
> |
except KeyError: |
229 |
> |
self.sourceSeed = 123456 |
230 |
> |
common.logger.message("No seed given, will use "+str(self.sourceSeed)) |
231 |
> |
|
232 |
|
self.PsetEdit.psetWriter(self.configFilename()) |
233 |
+ |
|
234 |
+ |
## Select Splitting |
235 |
+ |
if self.selectFilesPerJob: self.jobSplittingPerFiles() |
236 |
+ |
elif self.selectEventsPerJob: self.jobSplittingPerEvents() |
237 |
+ |
else: |
238 |
+ |
msg = 'Don\'t know how to split...' |
239 |
+ |
raise CrabException(msg) |
240 |
+ |
|
241 |
|
|
242 |
|
def DataDiscoveryAndLocation(self, cfg_params): |
243 |
|
|
244 |
|
common.logger.debug(10,"CMSSW::DataDiscoveryAndLocation()") |
245 |
|
|
201 |
– |
#datasetPath = "/"+self.owner+"/"+self.dataTiers[0]+"/"+self.dataset |
202 |
– |
|
246 |
|
datasetPath=self.datasetPath |
247 |
|
|
248 |
|
## TODO |
251 |
|
|
252 |
|
## Contact the DBS |
253 |
|
try: |
254 |
< |
self.pubdata=DataDiscovery_EDM.DataDiscovery_EDM(datasetPath, dataTiers, dataTiers) |
254 |
> |
self.pubdata=DataDiscovery_EDM.DataDiscovery_EDM(datasetPath, dataTiers, cfg_params) |
255 |
|
self.pubdata.fetchDBSInfo() |
256 |
|
|
257 |
|
except DataDiscovery_EDM.NotExistingDatasetError, ex : |
311 |
|
common.logger.message("List of Sites hosting the data : "+str(sites)) |
312 |
|
common.logger.debug(6, "List of Sites: "+str(sites)) |
313 |
|
common.analisys_common_info['sites']=sites ## used in SchedulerEdg.py in createSchScript |
314 |
+ |
self.setParam_('TargetCE', ','.join(sites)) |
315 |
|
return |
316 |
|
|
317 |
< |
def jobSplitting(self): |
317 |
> |
def jobSplittingPerFiles(self): |
318 |
|
""" |
319 |
< |
first implemntation for job splitting |
320 |
< |
""" |
321 |
< |
# print 'eventi totali '+str(self.maxEvents) |
278 |
< |
# print 'eventi totali richiesti dallo user '+str(self.total_number_of_events) |
279 |
< |
#print 'files per job '+str(self.filesPerJob) |
319 |
> |
Perform job splitting based on number of files to be accessed per job |
320 |
> |
""" |
321 |
> |
common.logger.debug(5,'Splitting per input files') |
322 |
|
common.logger.message('Required '+str(self.filesPerJob)+' files per job ') |
323 |
|
common.logger.message('Required '+str(self.total_number_of_events)+' events in total ') |
324 |
+ |
common.logger.message('Available '+str(self.maxEvents)+' events in total ') |
325 |
|
|
326 |
|
## TODO: SL need to have (from DBS) a detailed list of how many events per each file |
327 |
|
n_tot_files = (len(self.files[0])) |
328 |
+ |
#print "n_tot_files = ", n_tot_files |
329 |
|
## SL: this is wrong if the files have different number of events |
330 |
+ |
#print "self.maxEvents = ", self.maxEvents |
331 |
|
evPerFile = int(self.maxEvents)/n_tot_files |
332 |
< |
|
332 |
> |
#print "evPerFile = int(self.maxEvents)/n_tot_files = ", evPerFile |
333 |
> |
|
334 |
|
common.logger.debug(5,'Events per File '+str(evPerFile)) |
335 |
|
|
336 |
|
## if asked to process all events, do it |
337 |
|
if self.total_number_of_events == -1: |
338 |
|
self.total_number_of_events=self.maxEvents |
339 |
|
self.total_number_of_jobs = int(n_tot_files)*1/int(self.filesPerJob) |
340 |
+ |
check = int(n_tot_files) - (int(self.total_number_of_jobs)*self.filesPerJob) |
341 |
+ |
if check > 0: |
342 |
+ |
self.total_number_of_jobs = self.total_number_of_jobs + 1 |
343 |
+ |
common.logger.message('Warning: last job will be created with '+str(check)+' files') |
344 |
|
common.logger.message(str(self.total_number_of_jobs)+' jobs will be created for all available events '+str(self.total_number_of_events)+' events') |
345 |
|
|
346 |
|
else: |
347 |
+ |
if self.total_number_of_events>self.maxEvents: |
348 |
+ |
common.logger.message("Asked "+str(self.total_number_of_events)+" but only "+str(self.maxEvents)+" available.") |
349 |
+ |
self.total_number_of_events=self.maxEvents |
350 |
+ |
|
351 |
+ |
#print "self.total_number_of_events = ", self.total_number_of_events |
352 |
+ |
#print "evPerFile = ", evPerFile |
353 |
|
self.total_number_of_files = int(self.total_number_of_events/evPerFile) |
354 |
+ |
#print "self.total_number_of_files = int(self.total_number_of_events/evPerFile) = " , self.total_number_of_files |
355 |
+ |
|
356 |
+ |
## SL: round the number of files to be processed to the ceiling |
357 |
+ |
rem = self.total_number_of_events - self.total_number_of_files*evPerFile |
358 |
+ |
if rem>0: |
359 |
+ |
self.total_number_of_files = self.total_number_of_files + 1 |
360 |
+ |
|
361 |
|
## SL: if ask for less event than what is computed to be available on a |
362 |
|
## file, process the first file anyhow. |
363 |
|
if self.total_number_of_files == 0: |
364 |
|
self.total_number_of_files = self.total_number_of_files + 1 |
302 |
– |
|
365 |
|
common.logger.debug(5,'N files '+str(self.total_number_of_files)) |
366 |
|
|
367 |
|
check = 0 |
368 |
|
|
369 |
|
## Compute the number of jobs |
370 |
|
#self.total_number_of_jobs = int(n_tot_files)*1/int(self.filesPerJob) |
371 |
+ |
#print "self.total_number_of_files = ", self.total_number_of_files |
372 |
+ |
#print "self.filesPerJob = ", self.filesPerJob |
373 |
|
self.total_number_of_jobs = int(self.total_number_of_files/self.filesPerJob) |
374 |
+ |
#print "self.total_number_of_jobs = ", self.total_number_of_jobs |
375 |
|
common.logger.debug(5,'N jobs '+str(self.total_number_of_jobs)) |
376 |
|
|
377 |
|
## is there any remainder? |
383 |
|
self.total_number_of_jobs = self.total_number_of_jobs + 1 |
384 |
|
common.logger.message('Warning: last job will be created with '+str(check)+' files') |
385 |
|
|
386 |
< |
common.logger.message(str(self.total_number_of_jobs)+' jobs will be created for a total of '+str((self.total_number_of_jobs-1)*self.filesPerJob*evPerFile + check*evPerFile)+' events') |
386 |
> |
common.logger.message(str(self.total_number_of_jobs)+' jobs will be created for a total of '+str((self.total_number_of_jobs-check)*self.filesPerJob*evPerFile + check*evPerFile)+' events') |
387 |
|
pass |
388 |
|
|
389 |
|
list_of_lists = [] |
390 |
|
for i in xrange(0, int(n_tot_files), self.filesPerJob): |
391 |
< |
list_of_lists.append(self.files[0][i: i+self.filesPerJob]) |
391 |
> |
parString = "\\{" |
392 |
> |
|
393 |
> |
params = self.files[0][i: i+self.filesPerJob] |
394 |
> |
for i in range(len(params) - 1): |
395 |
> |
parString += '\\\"' + params[i] + '\\\"\,' |
396 |
> |
|
397 |
> |
parString += '\\\"' + params[len(params) - 1] + '\\\"\\}' |
398 |
> |
#print parString |
399 |
> |
list_of_lists.append([parString]) |
400 |
> |
#print list_of_lists |
401 |
> |
pass |
402 |
> |
|
403 |
> |
self.list_of_args = list_of_lists |
404 |
> |
# print self.list_of_args |
405 |
> |
return |
406 |
> |
|
407 |
> |
def jobSplittingPerEvents(self): |
408 |
> |
""" |
409 |
> |
Perform job splitting based on number of event per job |
410 |
> |
""" |
411 |
> |
common.logger.debug(5,'Splitting per events') |
412 |
> |
common.logger.message('Required '+str(self.eventsPerJob)+' events per job ') |
413 |
> |
common.logger.message('Required '+str(self.total_number_of_events)+' events in total ') |
414 |
> |
|
415 |
> |
if (self.total_number_of_events < 0): |
416 |
> |
msg='Cannot split jobs per Events with "-1" as total number of events' |
417 |
> |
raise CrabException(msg) |
418 |
> |
|
419 |
> |
self.total_number_of_jobs = int(self.total_number_of_events/self.eventsPerJob) |
420 |
> |
|
421 |
> |
common.logger.debug(5,'N jobs '+str(self.total_number_of_jobs)) |
422 |
> |
|
423 |
> |
# is there any remainder? |
424 |
> |
check = int(self.total_number_of_events) - (int(self.total_number_of_jobs)*self.eventsPerJob) |
425 |
> |
|
426 |
> |
common.logger.debug(5,'Check '+str(check)) |
427 |
> |
|
428 |
> |
if check > 0: |
429 |
> |
common.logger.message('Warning: asked '+self.total_number_of_events+' but will do only '+(int(self.total_number_of_jobs)*self.eventsPerJob)) |
430 |
> |
|
431 |
> |
common.logger.message(str(self.total_number_of_jobs)+' jobs will be created for a total of '+str(self.total_number_of_jobs*self.eventsPerJob)+' events') |
432 |
> |
|
433 |
> |
# argument is seed number.$i |
434 |
> |
self.list_of_args = [] |
435 |
> |
for i in range(self.total_number_of_jobs): |
436 |
> |
self.list_of_args.append([int(str(self.sourceSeed)+str(i))]) |
437 |
> |
#print self.list_of_args |
438 |
|
|
328 |
– |
self.list_of_files = list_of_lists |
329 |
– |
|
439 |
|
return |
440 |
|
|
441 |
|
def split(self, jobParams): |
443 |
|
common.jobDB.load() |
444 |
|
#### Fabio |
445 |
|
njobs = self.total_number_of_jobs |
446 |
< |
filelist = self.list_of_files |
446 |
> |
arglist = self.list_of_args |
447 |
|
# create the empty structure |
448 |
|
for i in range(njobs): |
449 |
|
jobParams.append("") |
450 |
|
|
451 |
|
for job in range(njobs): |
452 |
< |
jobParams[job] = filelist[job] |
452 |
> |
jobParams[job] = arglist[job] |
453 |
> |
# print str(arglist[job]) |
454 |
> |
# print jobParams[job] |
455 |
|
common.jobDB.setArguments(job, jobParams[job]) |
456 |
|
|
457 |
|
common.jobDB.save() |
458 |
|
return |
459 |
|
|
460 |
|
def getJobTypeArguments(self, nj, sched): |
461 |
< |
params = common.jobDB.arguments(nj) |
462 |
< |
#print params |
463 |
< |
parString = "\\{" |
464 |
< |
|
354 |
< |
for i in range(len(params) - 1): |
355 |
< |
parString += '\\\"' + params[i] + '\\\"\,' |
356 |
< |
|
357 |
< |
parString += '\\\"' + params[len(params) - 1] + '\\\"\\}' |
358 |
< |
return parString |
461 |
> |
result = '' |
462 |
> |
for i in common.jobDB.arguments(nj): |
463 |
> |
result=result+str(i)+" " |
464 |
> |
return result |
465 |
|
|
466 |
|
def numberOfJobs(self): |
467 |
|
# Fabio |
362 |
– |
|
468 |
|
return self.total_number_of_jobs |
364 |
– |
|
365 |
– |
|
469 |
|
|
470 |
|
def checkBlackList(self, allSites): |
471 |
|
if len(self.reCEBlackList)==0: return allSites |
601 |
|
txt += ' echo "Creating working directory: $WORKING_DIR"\n' |
602 |
|
txt += ' /bin/mkdir -p $WORKING_DIR\n' |
603 |
|
txt += ' if [ ! -d $WORKING_DIR ] ;then\n' |
604 |
< |
txt += ' echo "OSG WORKING DIR ==> $WORKING_DIR could not be created on on WN `hostname`"\n' |
605 |
< |
|
606 |
< |
txt += ' echo "JOB_EXIT_STATUS = 1"\n' |
604 |
> |
txt += ' echo "SET_CMS_ENV 10016 ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n' |
605 |
> |
txt += ' echo "JOB_EXIT_STATUS = 10016"\n' |
606 |
> |
txt += ' echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n' |
607 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
608 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
609 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
610 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
611 |
|
txt += ' exit 1\n' |
612 |
|
txt += ' fi\n' |
613 |
|
txt += '\n' |
623 |
|
txt += scram+' project CMSSW '+self.version+'\n' |
624 |
|
txt += 'status=$?\n' |
625 |
|
txt += 'if [ $status != 0 ] ; then\n' |
626 |
< |
txt += ' echo "SET_EXE_ENV 1 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n' |
626 |
> |
txt += ' echo "SET_EXE_ENV 10034 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n' |
627 |
|
txt += ' echo "JOB_EXIT_STATUS = 10034"\n' |
628 |
< |
txt += ' echo "SanityCheckCode = 10034" | tee -a $RUNTIME_AREA/$repo\n' |
628 |
> |
txt += ' echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n' |
629 |
|
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
630 |
+ |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
631 |
+ |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
632 |
+ |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
633 |
|
## OLI_Daniele |
634 |
|
txt += ' if [ $middleware == OSG ]; then \n' |
635 |
|
txt += ' echo "Remove working directory: $WORKING_DIR"\n' |
636 |
|
txt += ' cd $RUNTIME_AREA\n' |
637 |
|
txt += ' /bin/rm -rf $WORKING_DIR\n' |
638 |
|
txt += ' if [ -d $WORKING_DIR ] ;then\n' |
639 |
< |
txt += ' echo "OSG WORKING DIR ==> $WORKING_DIR could not be deleted on on WN `hostname`"\n' |
639 |
> |
txt += ' echo "SET_CMS_ENV 10018 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after CMSSW CMSSW_0_6_1 not found on `hostname`"\n' |
640 |
> |
txt += ' echo "JOB_EXIT_STATUS = 10018"\n' |
641 |
> |
txt += ' echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n' |
642 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
643 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
644 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
645 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
646 |
|
txt += ' fi\n' |
647 |
|
txt += ' fi \n' |
648 |
|
txt += ' exit 1 \n' |
654 |
|
|
655 |
|
# Handle the arguments: |
656 |
|
txt += "\n" |
657 |
< |
txt += "## ARGUMNETS: $1 Job Number\n" |
542 |
< |
# txt += "## ARGUMNETS: $2 First Event for this job\n" |
543 |
< |
# txt += "## ARGUMNETS: $3 Max Event for this job\n" |
657 |
> |
txt += "## number of arguments (first argument always jobnumber)\n" |
658 |
|
txt += "\n" |
659 |
|
txt += "narg=$#\n" |
660 |
|
txt += "if [ $narg -lt 2 ]\n" |
661 |
|
txt += "then\n" |
662 |
|
txt += " echo 'SET_EXE_ENV 1 ==> ERROR Too few arguments' +$narg+ \n" |
663 |
|
txt += ' echo "JOB_EXIT_STATUS = 50113"\n' |
664 |
< |
txt += ' echo "SanityCheckCode = 50113" | tee -a $RUNTIME_AREA/$repo\n' |
664 |
> |
txt += ' echo "JobExitCode=50113" | tee -a $RUNTIME_AREA/$repo\n' |
665 |
|
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
666 |
+ |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
667 |
+ |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
668 |
+ |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
669 |
|
## OLI_Daniele |
670 |
|
txt += ' if [ $middleware == OSG ]; then \n' |
671 |
|
txt += ' echo "Remove working directory: $WORKING_DIR"\n' |
672 |
|
txt += ' cd $RUNTIME_AREA\n' |
673 |
|
txt += ' /bin/rm -rf $WORKING_DIR\n' |
674 |
|
txt += ' if [ -d $WORKING_DIR ] ;then\n' |
675 |
< |
txt += ' echo "OSG WORKING DIR ==> $WORKING_DIR could not be deleted on on WN `hostname`"\n' |
675 |
> |
txt += ' echo "SET_EXE_ENV 50114 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Too few arguments for CRAB job wrapper"\n' |
676 |
> |
txt += ' echo "JOB_EXIT_STATUS = 50114"\n' |
677 |
> |
txt += ' echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n' |
678 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
679 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
680 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
681 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
682 |
|
txt += ' fi\n' |
683 |
|
txt += ' fi \n' |
684 |
|
txt += " exit 1\n" |
685 |
|
txt += "fi\n" |
686 |
|
txt += "\n" |
564 |
– |
txt += "NJob=$1\n" |
565 |
– |
txt += "InputFiles=$2\n" |
566 |
– |
txt += "echo \"<$InputFiles>\"\n" |
567 |
– |
# txt += "Args = ` cat $2 | sed -e \'s/\\\\//g\' -e \'s/\"/\\x27/g\' `" |
568 |
– |
|
569 |
– |
### OLI_DANIELE |
570 |
– |
txt += 'if [ $middleware == LCG ]; then \n' |
571 |
– |
txt += ' echo "MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`" | tee -a $RUNTIME_AREA/$repo\n' |
572 |
– |
txt += ' echo "SyncGridJobId=`echo $EDG_WL_JOBID`" | tee -a $RUNTIME_AREA/$repo\n' |
573 |
– |
txt += ' echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo\n' |
574 |
– |
txt += 'elif [ $middleware == OSG ]; then\n' |
575 |
– |
|
576 |
– |
# OLI: added monitoring for dashbord, use hash of crab.cfg |
577 |
– |
if common.scheduler.boss_scheduler_name == 'condor_g': |
578 |
– |
# create hash of cfg file |
579 |
– |
hash = makeCksum(common.work_space.cfgFileName()) |
580 |
– |
txt += ' echo "MonitorJobID=`echo ${NJob}_'+hash+'_$GLOBUS_GRAM_JOB_CONTACT`" | tee -a $RUNTIME_AREA/$repo\n' |
581 |
– |
txt += ' echo "SyncGridJobId=`echo $GLOBUS_GRAM_JOB_CONTACT`" | tee -a $RUNTIME_AREA/$repo\n' |
582 |
– |
txt += ' echo "SyncCE=`echo $hostname`" | tee -a $RUNTIME_AREA/$repo\n' |
583 |
– |
else : |
584 |
– |
txt += ' echo "MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`" | tee -a $RUNTIME_AREA/$repo\n' |
585 |
– |
txt += ' echo "SyncGridJobId=`echo $EDG_WL_JOBID`" | tee -a $RUNTIME_AREA/$repo\n' |
586 |
– |
txt += ' echo "SyncCE=`$EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo\n' |
587 |
– |
|
588 |
– |
txt += 'fi\n' |
589 |
– |
txt += 'dumpStatus $RUNTIME_AREA/$repo\n' |
687 |
|
|
688 |
|
# Prepare job-specific part |
689 |
|
job = common.job_list[nj] |
690 |
|
pset = os.path.basename(job.configFilename()) |
691 |
|
txt += '\n' |
692 |
< |
#txt += 'echo sed "s#{\'INPUT\'}#$InputFiles#" $RUNTIME_AREA/'+pset+' \n' |
693 |
< |
txt += 'sed "s#{\'INPUT\'}#$InputFiles#" $RUNTIME_AREA/'+pset+' > pset.cfg\n' |
694 |
< |
#txt += 'sed "s#{\'INPUT\'}#${InputFiles}#" $RUNTIME_AREA/'+pset+' > pset1.cfg\n' |
692 |
> |
if (self.datasetPath): # standard job |
693 |
> |
txt += 'InputFiles=$2\n' |
694 |
> |
txt += 'echo "Inputfiles:<$InputFiles>"\n' |
695 |
> |
txt += 'sed "s#{\'INPUT\'}#$InputFiles#" $RUNTIME_AREA/'+pset+' > pset.cfg\n' |
696 |
> |
else: # pythia like job |
697 |
> |
txt += 'Seed=$2\n' |
698 |
> |
txt += 'echo "Seed: <$Seed>"\n' |
699 |
> |
txt += 'sed "s#INPUT#$Seed#" $RUNTIME_AREA/'+pset+' > pset.cfg\n' |
700 |
|
|
701 |
|
if len(self.additional_inbox_files) > 0: |
702 |
|
for file in self.additional_inbox_files: |
733 |
|
txt += 'if [ $untar_status -ne 0 ]; then \n' |
734 |
|
txt += ' echo "SET_EXE 1 ==> ERROR Untarring .tgz file failed"\n' |
735 |
|
txt += ' echo "JOB_EXIT_STATUS = $untar_status" \n' |
736 |
< |
txt += ' echo "SanityCheckCode = $untar_status" | tee -a $repo\n' |
736 |
> |
txt += ' echo "JobExitCode=$untar_status" | tee -a $RUNTIME_AREA/$repo\n' |
737 |
|
txt += ' if [ $middleware == OSG ]; then \n' |
738 |
|
txt += ' echo "Remove working directory: $WORKING_DIR"\n' |
739 |
|
txt += ' cd $RUNTIME_AREA\n' |
740 |
|
txt += ' /bin/rm -rf $WORKING_DIR\n' |
741 |
|
txt += ' if [ -d $WORKING_DIR ] ;then\n' |
742 |
< |
txt += ' echo "OSG WORKING DIR ==> $WORKING_DIR could not be deleted on on WN `hostname`"\n' |
742 |
> |
txt += ' echo "SET_EXE 50999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Untarring .tgz file failed"\n' |
743 |
> |
txt += ' echo "JOB_EXIT_STATUS = 50999"\n' |
744 |
> |
txt += ' echo "JobExitCode=50999" | tee -a $RUNTIME_AREA/$repo\n' |
745 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
746 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
747 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
748 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
749 |
|
txt += ' fi\n' |
750 |
|
txt += ' fi \n' |
751 |
|
txt += ' \n' |
752 |
< |
txt += ' exit $untar_status \n' |
752 |
> |
txt += ' exit 1 \n' |
753 |
|
txt += 'else \n' |
754 |
|
txt += ' echo "Successful untar" \n' |
755 |
|
txt += 'fi \n' |
814 |
|
""" |
815 |
|
|
816 |
|
txt = '\n' |
817 |
+ |
txt += '# directory content\n' |
818 |
+ |
txt += 'ls \n' |
819 |
|
file_list = '' |
710 |
– |
check = len(self.output_file) |
711 |
– |
i = 0 |
820 |
|
for fileWithSuffix in self.output_file: |
713 |
– |
i= i + 1 |
821 |
|
output_file_num = self.numberFile_(fileWithSuffix, '$NJob') |
822 |
< |
file_list=file_list+output_file_num+'' |
716 |
< |
txt += '\n' |
717 |
< |
txt += 'ls \n' |
822 |
> |
file_list=file_list+output_file_num+' ' |
823 |
|
txt += '\n' |
824 |
+ |
txt += '# check output file\n' |
825 |
|
txt += 'ls '+fileWithSuffix+'\n' |
826 |
< |
txt += 'exe_result=$?\n' |
827 |
< |
txt += 'if [ $exe_result -ne 0 ] ; then\n' |
828 |
< |
txt += ' echo "ERROR: No output file to manage"\n' |
826 |
> |
txt += 'ls_result=$?\n' |
827 |
> |
#txt += 'exe_result=$?\n' |
828 |
> |
txt += 'if [ $ls_result -ne 0 ] ; then\n' |
829 |
> |
txt += ' echo "ERROR: Problem with output file"\n' |
830 |
> |
#txt += ' echo "JOB_EXIT_STATUS = $exe_result"\n' |
831 |
> |
#txt += ' echo "JobExitCode=60302" | tee -a $RUNTIME_AREA/$repo\n' |
832 |
> |
#txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
833 |
|
### OLI_DANIELE |
834 |
< |
txt += ' if [ $middleware == OSG ]; then \n' |
835 |
< |
txt += ' echo "prepare dummy output file"\n' |
836 |
< |
txt += ' cp '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n' |
837 |
< |
txt += ' fi \n' |
834 |
> |
if common.scheduler.boss_scheduler_name == 'condor_g': |
835 |
> |
txt += ' if [ $middleware == OSG ]; then \n' |
836 |
> |
txt += ' echo "prepare dummy output file"\n' |
837 |
> |
txt += ' echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n' |
838 |
> |
txt += ' fi \n' |
839 |
|
txt += 'else\n' |
840 |
|
txt += ' cp '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n' |
841 |
|
txt += 'fi\n' |
731 |
– |
if i == check: |
732 |
– |
txt += 'cd $RUNTIME_AREA\n' |
733 |
– |
pass |
734 |
– |
pass |
842 |
|
|
843 |
+ |
txt += 'cd $RUNTIME_AREA\n' |
844 |
|
file_list=file_list[:-1] |
845 |
|
txt += 'file_list="'+file_list+'"\n' |
846 |
+ |
txt += 'cd $RUNTIME_AREA\n' |
847 |
|
### OLI_DANIELE |
848 |
|
txt += 'if [ $middleware == OSG ]; then\n' |
849 |
|
txt += ' cd $RUNTIME_AREA\n' |
850 |
|
txt += ' echo "Remove working directory: $WORKING_DIR"\n' |
851 |
|
txt += ' /bin/rm -rf $WORKING_DIR\n' |
852 |
|
txt += ' if [ -d $WORKING_DIR ] ;then\n' |
853 |
< |
txt += ' echo "OSG WORKING DIR ==> $WORKING_DIR could not be deleted on on WN `hostname`"\n' |
853 |
> |
txt += ' echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n' |
854 |
> |
txt += ' echo "JOB_EXIT_STATUS = 60999"\n' |
855 |
> |
txt += ' echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n' |
856 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
857 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
858 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
859 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
860 |
|
txt += ' fi\n' |
861 |
|
txt += 'fi\n' |
862 |
|
txt += '\n' |
887 |
|
return job requirements to add to jdl files |
888 |
|
""" |
889 |
|
req = '' |
890 |
+ |
if common.analisys_common_info['sw_version']: |
891 |
+ |
req='Member("VO-cms-' + \ |
892 |
+ |
common.analisys_common_info['sw_version'] + \ |
893 |
+ |
'", other.GlueHostApplicationSoftwareRunTimeEnvironment)' |
894 |
|
if common.analisys_common_info['sites']: |
776 |
– |
if common.analisys_common_info['sw_version']: |
777 |
– |
req='Member("VO-cms-' + \ |
778 |
– |
common.analisys_common_info['sw_version'] + \ |
779 |
– |
'", other.GlueHostApplicationSoftwareRunTimeEnvironment)' |
895 |
|
if len(common.analisys_common_info['sites'])>0: |
896 |
|
req = req + ' && (' |
897 |
|
for i in range(len(common.analisys_common_info['sites'])): |
926 |
|
txt += ' echo "JOB_EXIT_STATUS = 10020"\n' |
927 |
|
txt += ' echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n' |
928 |
|
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
929 |
< |
txt += ' exit\n' |
929 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
930 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
931 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
932 |
> |
txt += ' exit 1\n' |
933 |
|
txt += '\n' |
934 |
|
txt += ' echo "Remove working directory: $WORKING_DIR"\n' |
935 |
|
txt += ' cd $RUNTIME_AREA\n' |
936 |
|
txt += ' /bin/rm -rf $WORKING_DIR\n' |
937 |
|
txt += ' if [ -d $WORKING_DIR ] ;then\n' |
938 |
< |
txt += ' echo "OSG WORKING DIR ==> $WORKING_DIR could not be deleted on on WN `hostname`"\n' |
938 |
> |
txt += ' echo "SET_CMS_ENV 10017 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after $GRID3_APP_DIR/cmssoft/cmsset_default.sh and $OSG_APP/cmssoft/cmsset_default.sh file not found"\n' |
939 |
> |
txt += ' echo "JOB_EXIT_STATUS = 10017"\n' |
940 |
> |
txt += ' echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n' |
941 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
942 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
943 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
944 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
945 |
|
txt += ' fi\n' |
946 |
|
txt += '\n' |
947 |
< |
txt += ' exit\n' |
947 |
> |
txt += ' exit 1\n' |
948 |
|
txt += ' fi\n' |
949 |
|
txt += '\n' |
950 |
|
txt += ' echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n' |
960 |
|
""" |
961 |
|
txt = ' \n' |
962 |
|
txt += ' echo " ### SETUP CMS LCG ENVIRONMENT ### "\n' |
839 |
– |
txt += ' echo "JOB_EXIT_STATUS = 0"\n' |
963 |
|
txt += ' if [ ! $VO_CMS_SW_DIR ] ;then\n' |
964 |
|
txt += ' echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n' |
965 |
|
txt += ' echo "JOB_EXIT_STATUS = 10031" \n' |
966 |
|
txt += ' echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n' |
967 |
|
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
968 |
< |
txt += ' exit\n' |
968 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
969 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
970 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
971 |
> |
txt += ' exit 1\n' |
972 |
|
txt += ' else\n' |
973 |
|
txt += ' echo "Sourcing environment... "\n' |
974 |
|
txt += ' if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n' |
976 |
|
txt += ' echo "JOB_EXIT_STATUS = 10020"\n' |
977 |
|
txt += ' echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n' |
978 |
|
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
979 |
< |
txt += ' exit\n' |
979 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
980 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
981 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
982 |
> |
txt += ' exit 1\n' |
983 |
|
txt += ' fi\n' |
984 |
|
txt += ' echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n' |
985 |
|
txt += ' source $VO_CMS_SW_DIR/cmsset_default.sh\n' |
989 |
|
txt += ' echo "JOB_EXIT_STATUS = 10032"\n' |
990 |
|
txt += ' echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n' |
991 |
|
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
992 |
< |
txt += ' exit\n' |
992 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
993 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
994 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
995 |
> |
txt += ' exit 1\n' |
996 |
|
txt += ' fi\n' |
997 |
|
txt += ' fi\n' |
998 |
|
txt += ' \n' |
1004 |
|
txt += ' export SCRAM_ARCH=slc3_ia32_gcc323\n' |
1005 |
|
txt += ' echo "SCRAM_ARCH= $SCRAM_ARCH"\n' |
1006 |
|
txt += ' else\n' |
1007 |
< |
txt += ' echo "SET_CMS_ENV 1 ==> ERROR OS unknown, LCG environment not initialized"\n' |
1007 |
> |
txt += ' echo "SET_CMS_ENV 10033 ==> ERROR OS unknown, LCG environment not initialized"\n' |
1008 |
|
txt += ' echo "JOB_EXIT_STATUS = 10033"\n' |
1009 |
|
txt += ' echo "JobExitCode=10033" | tee -a $RUNTIME_AREA/$repo\n' |
1010 |
|
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
1011 |
< |
txt += ' exit\n' |
1011 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
1012 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
1013 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
1014 |
> |
txt += ' exit 1\n' |
1015 |
|
txt += ' fi\n' |
1016 |
|
txt += ' echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n' |
1017 |
|
txt += ' echo "### END SETUP CMS LCG ENVIRONMENT ###"\n' |
1018 |
|
return txt |
1019 |
+ |
|
1020 |
+ |
def setParam_(self, param, value): |
1021 |
+ |
self._params[param] = value |
1022 |
+ |
|
1023 |
+ |
def getParams(self): |
1024 |
+ |
return self._params |
1025 |
+ |
|
1026 |
+ |
def setTaskid_(self): |
1027 |
+ |
self._taskId = self.cfg_params['taskId'] |
1028 |
+ |
|
1029 |
+ |
def getTaskid(self): |
1030 |
+ |
return self._taskId |