2 |
|
from crab_logger import Logger |
3 |
|
from crab_exceptions import * |
4 |
|
from crab_util import * |
5 |
+ |
import math |
6 |
|
import common |
7 |
+ |
import PsetManipulator |
8 |
|
|
9 |
< |
import DataDiscovery |
10 |
< |
import DataLocation |
9 |
> |
import DBSInfo_EDM |
10 |
> |
import DataDiscovery_EDM |
11 |
> |
import DataLocation_EDM |
12 |
|
import Scram |
13 |
|
|
14 |
|
import os, string, re |
19 |
|
common.logger.debug(3,'CMSSW::__init__') |
20 |
|
|
21 |
|
self.analisys_common_info = {} |
22 |
< |
|
22 |
> |
# Marco. |
23 |
> |
self._params = {} |
24 |
> |
self.cfg_params = cfg_params |
25 |
|
log = common.logger |
26 |
|
|
27 |
|
self.scram = Scram.Scram(cfg_params) |
31 |
|
self.executable = '' |
32 |
|
self.tgz_name = 'default.tgz' |
33 |
|
|
34 |
+ |
|
35 |
|
self.version = self.scram.getSWVersion() |
36 |
+ |
self.setParam_('application', self.version) |
37 |
|
common.analisys_common_info['sw_version'] = self.version |
38 |
+ |
### FEDE |
39 |
+ |
common.analisys_common_info['copy_input_data'] = 0 |
40 |
+ |
common.analisys_common_info['events_management'] = 1 |
41 |
|
|
42 |
|
### collect Data cards |
43 |
|
try: |
44 |
< |
self.owner = cfg_params['CMSSW.owner'] |
45 |
< |
log.debug(6, "CMSSW::CMSSW(): owner = "+self.owner) |
46 |
< |
self.dataset = cfg_params['CMSSW.dataset'] |
47 |
< |
log.debug(6, "CMSSW::CMSSW(): dataset = "+self.dataset) |
44 |
> |
tmp = cfg_params['CMSSW.datasetpath'] |
45 |
> |
log.debug(6, "CMSSW::CMSSW(): datasetPath = "+tmp) |
46 |
> |
if string.lower(tmp)=='none': |
47 |
> |
self.datasetPath = None |
48 |
> |
self.selectNoInput = 1 |
49 |
> |
else: |
50 |
> |
self.datasetPath = tmp |
51 |
> |
self.selectNoInput = 0 |
52 |
|
except KeyError: |
53 |
< |
msg = "Error: owner and/or dataset not defined " |
53 |
> |
msg = "Error: datasetpath not defined " |
54 |
|
raise CrabException(msg) |
55 |
|
|
56 |
+ |
# ML monitoring |
57 |
+ |
# split dataset path style: /PreProdR3Minbias/SIM/GEN-SIM |
58 |
+ |
if not self.datasetPath: |
59 |
+ |
self.setParam_('dataset', 'None') |
60 |
+ |
self.setParam_('owner', 'None') |
61 |
+ |
else: |
62 |
+ |
datasetpath_split = self.datasetPath.split("/") |
63 |
+ |
self.setParam_('dataset', datasetpath_split[1]) |
64 |
+ |
self.setParam_('owner', datasetpath_split[-1]) |
65 |
+ |
|
66 |
+ |
self.setTaskid_() |
67 |
+ |
self.setParam_('taskId', self.cfg_params['taskId']) |
68 |
+ |
|
69 |
|
self.dataTiers = [] |
43 |
– |
try: |
44 |
– |
tmpDataTiers = string.split(cfg_params['CMSSW.data_tier'],',') |
45 |
– |
for tmp in tmpDataTiers: |
46 |
– |
tmp=string.strip(tmp) |
47 |
– |
self.dataTiers.append(tmp) |
48 |
– |
pass |
49 |
– |
pass |
50 |
– |
except KeyError: |
51 |
– |
pass |
52 |
– |
log.debug(6, "Cmssw::Cmssw(): dataTiers = "+str(self.dataTiers)) |
70 |
|
|
71 |
|
## now the application |
72 |
|
try: |
73 |
|
self.executable = cfg_params['CMSSW.executable'] |
74 |
+ |
self.setParam_('exe', self.executable) |
75 |
|
log.debug(6, "CMSSW::CMSSW(): executable = "+self.executable) |
76 |
|
msg = "Default executable cmsRun overridden. Switch to " + self.executable |
77 |
|
log.debug(3,msg) |
78 |
|
except KeyError: |
79 |
|
self.executable = 'cmsRun' |
80 |
+ |
self.setParam_('exe', self.executable) |
81 |
|
msg = "User executable not defined. Use cmsRun" |
82 |
|
log.debug(3,msg) |
83 |
|
pass |
102 |
|
tmp=string.strip(tmp) |
103 |
|
self.output_file.append(tmp) |
104 |
|
pass |
86 |
– |
|
105 |
|
else: |
106 |
|
log.message("No output file defined: only stdout/err will be available") |
107 |
|
pass |
112 |
|
|
113 |
|
# script_exe file as additional file in inputSandbox |
114 |
|
try: |
115 |
< |
self.scriptExe = cfg_params['CMSSW.script_exe'] |
116 |
< |
self.additional_inbox_files.append(self.scriptExe) |
115 |
> |
self.scriptExe = cfg_params['USER.script_exe'] |
116 |
> |
self.additional_inbox_files.append(self.scriptExe) |
117 |
> |
if self.scriptExe != '': |
118 |
> |
if not os.path.isfile(self.scriptExe): |
119 |
> |
msg ="WARNING. file "+self.scriptExe+" not found" |
120 |
> |
raise CrabException(msg) |
121 |
|
except KeyError: |
122 |
|
pass |
101 |
– |
if self.scriptExe != '': |
102 |
– |
if os.path.isfile(self.scriptExe): |
103 |
– |
pass |
104 |
– |
else: |
105 |
– |
log.message("WARNING. file "+self.scriptExe+" not found") |
106 |
– |
sys.exit() |
123 |
|
|
124 |
|
## additional input files |
125 |
|
try: |
126 |
|
tmpAddFiles = string.split(cfg_params['CMSSW.additional_input_files'],',') |
127 |
|
for tmp in tmpAddFiles: |
128 |
+ |
if not os.path.exists(tmp): |
129 |
+ |
raise CrabException("Additional input file not found: "+tmp) |
130 |
|
tmp=string.strip(tmp) |
131 |
|
self.additional_inbox_files.append(tmp) |
132 |
|
pass |
134 |
|
except KeyError: |
135 |
|
pass |
136 |
|
|
137 |
+ |
# files per job |
138 |
+ |
try: |
139 |
+ |
self.filesPerJob = int(cfg_params['CMSSW.files_per_jobs']) #Daniele |
140 |
+ |
self.selectFilesPerJob = 1 |
141 |
+ |
except KeyError: |
142 |
+ |
self.filesPerJob = 0 |
143 |
+ |
self.selectFilesPerJob = 0 |
144 |
+ |
|
145 |
+ |
## Events per job |
146 |
+ |
try: |
147 |
+ |
self.eventsPerJob =int( cfg_params['CMSSW.events_per_job']) |
148 |
+ |
self.selectEventsPerJob = 1 |
149 |
+ |
except KeyError: |
150 |
+ |
self.eventsPerJob = -1 |
151 |
+ |
self.selectEventsPerJob = 0 |
152 |
+ |
|
153 |
+ |
## number of jobs |
154 |
+ |
try: |
155 |
+ |
self.theNumberOfJobs =int( cfg_params['CMSSW.number_of_jobs']) |
156 |
+ |
self.selectNumberOfJobs = 1 |
157 |
+ |
except KeyError: |
158 |
+ |
self.theNumberOfJobs = 0 |
159 |
+ |
self.selectNumberOfJobs = 0 |
160 |
+ |
|
161 |
+ |
## source seed for pythia |
162 |
+ |
try: |
163 |
+ |
self.sourceSeed = int(cfg_params['CMSSW.pythia_seed']) |
164 |
+ |
except KeyError: |
165 |
+ |
self.sourceSeed = None |
166 |
+ |
common.logger.debug(5,"No seed given") |
167 |
+ |
|
168 |
+ |
if not (self.selectFilesPerJob + self.selectEventsPerJob + self.selectNumberOfJobs == 1 ): |
169 |
+ |
msg = 'Must define either files_per_jobs or events_per_job or number_of_jobs' |
170 |
+ |
raise CrabException(msg) |
171 |
+ |
|
172 |
|
try: |
173 |
|
self.total_number_of_events = int(cfg_params['CMSSW.total_number_of_events']) |
174 |
|
except KeyError: |
175 |
< |
msg = 'Must define total_number_of_events and job_number_of_events' |
175 |
> |
msg = 'Must define total_number_of_events' |
176 |
|
raise CrabException(msg) |
124 |
– |
|
125 |
– |
#Marco: FirstEvent is nolonger used inside PSet |
126 |
– |
# try: |
127 |
– |
# self.first = int(cfg_params['CMSSW.first_event']) |
128 |
– |
# except KeyError: |
129 |
– |
# self.first = 0 |
130 |
– |
# pass |
131 |
– |
# log.debug(6, "Orca::Orca(): total number of events = "+`self.total_number_of_events`) |
132 |
– |
#log.debug(6, "Orca::Orca(): events per job = "+`self.job_number_of_events`) |
133 |
– |
# log.debug(6, "Orca::Orca(): first event = "+`self.first`) |
177 |
|
|
178 |
|
CEBlackList = [] |
179 |
|
try: |
193 |
|
CEWhiteList = [] |
194 |
|
try: |
195 |
|
tmpGood = string.split(cfg_params['EDG.ce_white_list'],',') |
153 |
– |
#tmpGood = ['cern'] |
196 |
|
for tmp in tmpGood: |
197 |
|
tmp=string.strip(tmp) |
156 |
– |
#if (tmp == 'cnaf'): tmp = 'webserver' ########## warning: temp. patch |
198 |
|
CEWhiteList.append(tmp) |
199 |
|
except KeyError: |
200 |
|
pass |
206 |
|
|
207 |
|
common.logger.debug(5,'CEWhiteList: '+str(CEWhiteList)) |
208 |
|
|
209 |
+ |
self.PsetEdit = PsetManipulator.PsetManipulator(self.pset) #Daniele Pset |
210 |
+ |
|
211 |
|
#DBSDLS-start |
212 |
|
## Initialize the variables that are extracted from DBS/DLS and needed in other places of the code |
213 |
|
self.maxEvents=0 # max events available ( --> check the requested nb. of evts in Creator.py) |
214 |
|
self.DBSPaths={} # all dbs paths requested ( --> input to the site local discovery script) |
215 |
|
## Perform the data location and discovery (based on DBS/DLS) |
216 |
< |
self.DataDiscoveryAndLocation(cfg_params) |
216 |
> |
## SL: Don't if NONE is specified as input (pythia use case) |
217 |
> |
common.analisys_common_info['sites']=None |
218 |
> |
if self.datasetPath: |
219 |
> |
self.DataDiscoveryAndLocation(cfg_params) |
220 |
|
#DBSDLS-end |
221 |
|
|
222 |
|
self.tgzNameWithPath = self.getTarBall(self.executable) |
223 |
+ |
|
224 |
+ |
## Select Splitting |
225 |
+ |
if self.selectNoInput: self.jobSplittingNoInput() |
226 |
+ |
elif self.selectFilesPerJob or self.selectEventsPerJob or self.selectNumberOfJobs: self.jobSplittingPerFiles() |
227 |
+ |
else: |
228 |
+ |
msg = 'Don\'t know how to split...' |
229 |
+ |
raise CrabException(msg) |
230 |
+ |
|
231 |
+ |
# modify Pset |
232 |
+ |
try: |
233 |
+ |
if (self.datasetPath): # standard job |
234 |
+ |
#self.PsetEdit.maxEvent(self.eventsPerJob) |
235 |
+ |
# always process all events in a file |
236 |
+ |
self.PsetEdit.maxEvent("-1") |
237 |
+ |
self.PsetEdit.inputModule("INPUT") |
238 |
+ |
|
239 |
+ |
else: # pythia like job |
240 |
+ |
self.PsetEdit.maxEvent(self.eventsPerJob) |
241 |
+ |
if (self.sourceSeed) : |
242 |
+ |
self.PsetEdit.pythiaSeed("INPUT","INPUTVTX") |
243 |
+ |
self.PsetEdit.psetWriter(self.configFilename()) |
244 |
+ |
except: |
245 |
+ |
msg='Error while manipuliating ParameterSet: exiting...' |
246 |
+ |
raise CrabException(msg) |
247 |
|
|
248 |
|
def DataDiscoveryAndLocation(self, cfg_params): |
249 |
|
|
250 |
< |
fun = "CMSSW::DataDiscoveryAndLocation()" |
250 |
> |
common.logger.debug(10,"CMSSW::DataDiscoveryAndLocation()") |
251 |
> |
|
252 |
> |
datasetPath=self.datasetPath |
253 |
> |
|
254 |
> |
## TODO |
255 |
> |
dataTiersList = "" |
256 |
> |
dataTiers = dataTiersList.split(',') |
257 |
|
|
258 |
|
## Contact the DBS |
259 |
|
try: |
260 |
< |
self.pubdata=DataDiscovery.DataDiscovery(self.owner, |
185 |
< |
self.dataset, |
186 |
< |
self.dataTiers, |
187 |
< |
cfg_params) |
260 |
> |
self.pubdata=DataDiscovery_EDM.DataDiscovery_EDM(datasetPath, dataTiers, cfg_params) |
261 |
|
self.pubdata.fetchDBSInfo() |
262 |
|
|
263 |
< |
except DataDiscovery.NotExistingDatasetError, ex : |
263 |
> |
except DataDiscovery_EDM.NotExistingDatasetError, ex : |
264 |
|
msg = 'ERROR ***: failed Data Discovery in DBS : %s'%ex.getErrorMessage() |
265 |
|
raise CrabException(msg) |
266 |
|
|
267 |
< |
except DataDiscovery.NoDataTierinProvenanceError, ex : |
267 |
> |
except DataDiscovery_EDM.NoDataTierinProvenanceError, ex : |
268 |
|
msg = 'ERROR ***: failed Data Discovery in DBS : %s'%ex.getErrorMessage() |
269 |
|
raise CrabException(msg) |
270 |
< |
except DataDiscovery.DataDiscoveryError, ex: |
270 |
> |
except DataDiscovery_EDM.DataDiscoveryError, ex: |
271 |
|
msg = 'ERROR ***: failed Data Discovery in DBS %s'%ex.getErrorMessage() |
272 |
|
raise CrabException(msg) |
273 |
|
|
274 |
|
## get list of all required data in the form of dbs paths (dbs path = /dataset/datatier/owner) |
275 |
< |
self.DBSPaths=self.pubdata.getDBSPaths() |
276 |
< |
common.logger.message("Required data are : ") |
277 |
< |
for path in self.DBSPaths: |
278 |
< |
common.logger.message(" --> "+path ) |
275 |
> |
## self.DBSPaths=self.pubdata.getDBSPaths() |
276 |
> |
common.logger.message("Required data are :"+self.datasetPath) |
277 |
> |
|
278 |
> |
filesbyblock=self.pubdata.getFiles() |
279 |
> |
# print filesbyblock |
280 |
> |
self.AllInputFiles=filesbyblock.values() |
281 |
> |
self.files = self.AllInputFiles |
282 |
|
|
283 |
|
## get max number of events |
284 |
< |
common.logger.debug(10,"number of events for primary fileblocks %i"%self.pubdata.getMaxEvents()) |
284 |
> |
#common.logger.debug(10,"number of events for primary fileblocks %i"%self.pubdata.getMaxEvents()) |
285 |
|
self.maxEvents=self.pubdata.getMaxEvents() ## self.maxEvents used in Creator.py |
286 |
|
common.logger.message("\nThe number of available events is %s"%self.maxEvents) |
287 |
|
|
212 |
– |
## get fileblocks corresponding to the required data |
213 |
– |
fb=self.pubdata.getFileBlocks() |
214 |
– |
common.logger.debug(5,"fileblocks are %s"%fb) |
215 |
– |
|
288 |
|
## Contact the DLS and build a list of sites hosting the fileblocks |
289 |
|
try: |
290 |
< |
dataloc=DataLocation.DataLocation(self.pubdata.getFileBlocks(),cfg_params) |
290 |
> |
dataloc=DataLocation_EDM.DataLocation_EDM(filesbyblock.keys(),cfg_params) |
291 |
|
dataloc.fetchDLSInfo() |
292 |
< |
except DataLocation.DataLocationError , ex: |
292 |
> |
except DataLocation_EDM.DataLocationError , ex: |
293 |
|
msg = 'ERROR ***: failed Data Location in DLS \n %s '%ex.getErrorMessage() |
294 |
|
raise CrabException(msg) |
295 |
|
|
303 |
|
if len(sites)==0: |
304 |
|
msg = 'No sites hosting all the needed data! Exiting... ' |
305 |
|
raise CrabException(msg) |
306 |
< |
common.logger.message("List of Sites hosting the data : "+str(sites)) |
306 |
> |
|
307 |
> |
common.logger.message("List of Sites ("+str(len(sites))+") hosting the data : "+str(sites)) |
308 |
|
common.logger.debug(6, "List of Sites: "+str(sites)) |
309 |
|
common.analisys_common_info['sites']=sites ## used in SchedulerEdg.py in createSchScript |
310 |
+ |
self.setParam_('TargetCE', ','.join(sites)) |
311 |
+ |
return |
312 |
+ |
|
313 |
+ |
def jobSplittingPerFiles(self): |
314 |
+ |
""" |
315 |
+ |
Perform job splitting based on number of files to be accessed per job |
316 |
+ |
""" |
317 |
+ |
common.logger.debug(5,'Splitting per input files') |
318 |
+ |
common.logger.message('Required '+str(self.total_number_of_events)+' events in total ') |
319 |
+ |
common.logger.message('Available '+str(self.maxEvents)+' events in total ') |
320 |
+ |
common.logger.message('Required '+str(self.filesPerJob)+' files per job ') |
321 |
+ |
common.logger.message('Required '+str(self.theNumberOfJobs)+' jobs in total ') |
322 |
+ |
common.logger.message('Required '+str(self.eventsPerJob)+' events per job') |
323 |
+ |
|
324 |
+ |
## if asked to process all events, do it |
325 |
+ |
if self.total_number_of_events == -1: |
326 |
+ |
self.total_number_of_events=self.maxEvents |
327 |
+ |
else: |
328 |
+ |
if self.total_number_of_events>self.maxEvents: |
329 |
+ |
common.logger.message("Asked "+str(self.total_number_of_events)+" but only "+str(self.maxEvents)+" available.") |
330 |
+ |
self.total_number_of_events=self.maxEvents |
331 |
+ |
pass |
332 |
+ |
|
333 |
+ |
## TODO: SL need to have (from DBS) a detailed list of how many events per each file |
334 |
+ |
n_tot_files = (len(self.files[0])) |
335 |
+ |
## SL: this is wrong if the files have different number of events |
336 |
+ |
evPerFile = int(self.maxEvents)/n_tot_files |
337 |
+ |
|
338 |
+ |
common.logger.debug(5,'Events per File '+str(evPerFile)) |
339 |
+ |
|
340 |
+ |
## compute job splitting parameters: filesPerJob, eventsPerJob and theNumberOfJobs |
341 |
+ |
if self.selectFilesPerJob: |
342 |
+ |
## user define files per event. |
343 |
+ |
filesPerJob = self.filesPerJob |
344 |
+ |
eventsPerJob = filesPerJob*evPerFile |
345 |
+ |
theNumberOfJobs = int(self.total_number_of_events*1./eventsPerJob) |
346 |
+ |
check = int(self.total_number_of_events) - (theNumberOfJobs*eventsPerJob) |
347 |
+ |
if check > 0: |
348 |
+ |
theNumberOfJobs +=1 |
349 |
+ |
filesLastJob = int(check*1./evPerFile+0.5) |
350 |
+ |
common.logger.message('Warning: last job will be created with '+str(check)+' files') |
351 |
+ |
else: |
352 |
+ |
filesLastJob = filesPerJob |
353 |
+ |
|
354 |
+ |
elif self.selectNumberOfJobs: |
355 |
+ |
## User select the number of jobs: last might be bigger to match request of events |
356 |
+ |
theNumberOfJobs = self.theNumberOfJobs |
357 |
+ |
|
358 |
+ |
eventsPerJob = self.total_number_of_events/theNumberOfJobs |
359 |
+ |
filesPerJob = int(eventsPerJob/evPerFile) |
360 |
+ |
if (filesPerJob==0) : filesPerJob=1 |
361 |
+ |
check = int(self.total_number_of_events) - (int(theNumberOfJobs)*filesPerJob*evPerFile) |
362 |
+ |
if not check == 0: |
363 |
+ |
if check<0: |
364 |
+ |
missingFiles = int(check/evPerFile) |
365 |
+ |
additionalJobs = int(missingFiles/filesPerJob) |
366 |
+ |
#print missingFiles, additionalJobs |
367 |
+ |
theNumberOfJobs+=additionalJobs |
368 |
+ |
common.logger.message('Warning: will create only '+str(theNumberOfJobs)+' jobs') |
369 |
+ |
check = int(self.total_number_of_events) - (int(theNumberOfJobs)*filesPerJob*evPerFile) |
370 |
+ |
|
371 |
+ |
if check >0 : |
372 |
+ |
filesLastJob = filesPerJob+int(check*1./evPerFile+0.5) |
373 |
+ |
common.logger.message('Warning: last job will be created with '+str(filesLastJob*evPerFile)+' events') |
374 |
+ |
else: |
375 |
+ |
filesLastJob = filesPerJob |
376 |
+ |
else: |
377 |
+ |
filesLastJob = filesPerJob |
378 |
+ |
elif self.selectEventsPerJob: |
379 |
+ |
# SL case if asked events per job |
380 |
+ |
## estimate the number of files per job to match the user requirement |
381 |
+ |
filesPerJob = int(float(self.eventsPerJob)/float(evPerFile)) |
382 |
+ |
if filesPerJob==0: filesPerJob=1 |
383 |
+ |
common.logger.debug(5,"filesPerJob "+str(filesPerJob)) |
384 |
+ |
if (filesPerJob==0): filesPerJob=1 |
385 |
+ |
eventsPerJob=filesPerJob*evPerFile |
386 |
+ |
theNumberOfJobs = int(self.total_number_of_events)/int(eventsPerJob) |
387 |
+ |
check = int(self.total_number_of_events) - (int(theNumberOfJobs)*eventsPerJob) |
388 |
+ |
if not check == 0: |
389 |
+ |
missingFiles = int(check/evPerFile) |
390 |
+ |
additionalJobs = int(missingFiles/filesPerJob) |
391 |
+ |
if ( additionalJobs>0) : theNumberOfJobs+=additionalJobs |
392 |
+ |
check = int(self.total_number_of_events) - (int(theNumberOfJobs)*eventsPerJob) |
393 |
+ |
if not check == 0: |
394 |
+ |
if (check <0 ): |
395 |
+ |
filesLastJob = filesPerJob+int(check*1./evPerFile-0.5) |
396 |
+ |
else: |
397 |
+ |
theNumberOfJobs+=1 |
398 |
+ |
filesLastJob = int(check*1./evPerFile+0.5) |
399 |
+ |
|
400 |
+ |
common.logger.message('Warning: last job will be created with '+str(filesLastJob*evPerFile)+' events') |
401 |
+ |
else: |
402 |
+ |
filesLastJob = filesPerJob |
403 |
+ |
else: |
404 |
+ |
filesLastJob = filesPerJob |
405 |
+ |
|
406 |
+ |
self.total_number_of_jobs = theNumberOfJobs |
407 |
+ |
|
408 |
+ |
totalEventsToBeUsed=theNumberOfJobs*filesPerJob*evPerFile |
409 |
+ |
if not check == 0: |
410 |
+ |
# print (theNumberOfJobs-1)*filesPerJob*evPerFile,filesLastJob*evPerFile |
411 |
+ |
totalEventsToBeUsed=(theNumberOfJobs-1)*filesPerJob*evPerFile+filesLastJob*evPerFile |
412 |
+ |
|
413 |
+ |
common.logger.message(str(self.total_number_of_jobs)+' jobs will be created, each for '+str(filesPerJob*evPerFile)+' events, for a total of '+str(totalEventsToBeUsed)+' events') |
414 |
+ |
|
415 |
+ |
totalFilesToBeUsed=filesPerJob*(theNumberOfJobs-1)+filesLastJob |
416 |
+ |
|
417 |
+ |
## set job arguments (files) |
418 |
+ |
list_of_lists = [] |
419 |
+ |
lastFile=0 |
420 |
+ |
for i in range(0, int(totalFilesToBeUsed), filesPerJob)[:-1]: |
421 |
+ |
parString = "\\{" |
422 |
+ |
|
423 |
+ |
lastFile=i+filesPerJob |
424 |
+ |
params = self.files[0][i: lastFile] |
425 |
+ |
for i in range(len(params) - 1): |
426 |
+ |
parString += '\\\"' + params[i] + '\\\"\,' |
427 |
+ |
|
428 |
+ |
parString += '\\\"' + params[len(params) - 1] + '\\\"\\}' |
429 |
+ |
list_of_lists.append([parString]) |
430 |
+ |
pass |
431 |
+ |
|
432 |
+ |
## last job |
433 |
+ |
parString = "\\{" |
434 |
+ |
|
435 |
+ |
params = self.files[0][lastFile: lastFile+filesLastJob] |
436 |
+ |
for i in range(len(params) - 1): |
437 |
+ |
parString += '\\\"' + params[i] + '\\\"\,' |
438 |
+ |
|
439 |
+ |
parString += '\\\"' + params[len(params) - 1] + '\\\"\\}' |
440 |
+ |
list_of_lists.append([parString]) |
441 |
+ |
pass |
442 |
+ |
|
443 |
+ |
self.list_of_args = list_of_lists |
444 |
+ |
# print self.list_of_args[0] |
445 |
+ |
return |
446 |
+ |
|
447 |
+ |
def jobSplittingNoInput(self): |
448 |
+ |
""" |
449 |
+ |
Perform job splitting based on number of event per job |
450 |
+ |
""" |
451 |
+ |
common.logger.debug(5,'Splitting per events') |
452 |
+ |
common.logger.message('Required '+str(self.eventsPerJob)+' events per job ') |
453 |
+ |
common.logger.message('Required '+str(self.theNumberOfJobs)+' jobs in total ') |
454 |
+ |
common.logger.message('Required '+str(self.total_number_of_events)+' events in total ') |
455 |
+ |
|
456 |
+ |
if (self.total_number_of_events < 0): |
457 |
+ |
msg='Cannot split jobs per Events with "-1" as total number of events' |
458 |
+ |
raise CrabException(msg) |
459 |
+ |
|
460 |
+ |
if (self.selectEventsPerJob): |
461 |
+ |
self.total_number_of_jobs = int(self.total_number_of_events/self.eventsPerJob) |
462 |
+ |
elif (self.selectNumberOfJobs) : |
463 |
+ |
self.total_number_of_jobs = self.theNumberOfJobs |
464 |
+ |
self.eventsPerJob = int(self.total_number_of_events/self.total_number_of_jobs) |
465 |
+ |
|
466 |
+ |
common.logger.debug(5,'N jobs '+str(self.total_number_of_jobs)) |
467 |
+ |
|
468 |
+ |
# is there any remainder? |
469 |
+ |
check = int(self.total_number_of_events) - (int(self.total_number_of_jobs)*self.eventsPerJob) |
470 |
+ |
|
471 |
+ |
common.logger.debug(5,'Check '+str(check)) |
472 |
+ |
|
473 |
+ |
common.logger.message(str(self.total_number_of_jobs)+' jobs will be created, each for '+str(self.eventsPerJob)+' for a total of '+str(self.total_number_of_jobs*self.eventsPerJob)+' events') |
474 |
+ |
if check > 0: |
475 |
+ |
common.logger.message('Warning: asked '+str(self.total_number_of_events)+' but will do only '+str(int(self.total_number_of_jobs)*self.eventsPerJob)) |
476 |
+ |
|
477 |
+ |
|
478 |
+ |
# argument is seed number.$i |
479 |
+ |
self.list_of_args = [] |
480 |
+ |
for i in range(self.total_number_of_jobs): |
481 |
+ |
if (self.sourceSeed): |
482 |
+ |
self.list_of_args.append([(str(self.sourceSeed)+str(i))]) |
483 |
+ |
else: |
484 |
+ |
self.list_of_args.append([str(i)]) |
485 |
+ |
#print self.list_of_args |
486 |
+ |
|
487 |
|
return |
488 |
+ |
|
489 |
+ |
def split(self, jobParams): |
490 |
+ |
|
491 |
+ |
common.jobDB.load() |
492 |
+ |
#### Fabio |
493 |
+ |
njobs = self.total_number_of_jobs |
494 |
+ |
arglist = self.list_of_args |
495 |
+ |
# create the empty structure |
496 |
+ |
for i in range(njobs): |
497 |
+ |
jobParams.append("") |
498 |
|
|
499 |
+ |
for job in range(njobs): |
500 |
+ |
jobParams[job] = arglist[job] |
501 |
+ |
# print str(arglist[job]) |
502 |
+ |
# print jobParams[job] |
503 |
+ |
common.jobDB.setArguments(job, jobParams[job]) |
504 |
+ |
|
505 |
+ |
common.jobDB.save() |
506 |
+ |
return |
507 |
+ |
|
508 |
+ |
def getJobTypeArguments(self, nj, sched): |
509 |
+ |
result = '' |
510 |
+ |
for i in common.jobDB.arguments(nj): |
511 |
+ |
result=result+str(i)+" " |
512 |
+ |
return result |
513 |
+ |
|
514 |
+ |
def numberOfJobs(self): |
515 |
+ |
# Fabio |
516 |
+ |
return self.total_number_of_jobs |
517 |
+ |
|
518 |
|
def checkBlackList(self, allSites): |
519 |
|
if len(self.reCEBlackList)==0: return allSites |
520 |
|
sites = [] |
531 |
|
common.logger.debug(3,"No sites found after BlackList") |
532 |
|
return sites |
533 |
|
|
534 |
< |
def checkWhiteList(self, allsites): |
534 |
> |
def checkWhiteList(self, allSites): |
535 |
|
|
536 |
< |
if len(self.reCEWhiteList)==0: return pubDBUrls |
536 |
> |
if len(self.reCEWhiteList)==0: return allSites |
537 |
|
sites = [] |
538 |
< |
for site in allsites: |
260 |
< |
#print 'connecting to the URL ',url |
538 |
> |
for site in allSites: |
539 |
|
good=0 |
540 |
|
for re in self.reCEWhiteList: |
541 |
|
if re.search(site): |
605 |
|
if os.path.exists(lib): |
606 |
|
filesToBeTarred.append(libDir) |
607 |
|
|
608 |
+ |
## Now check if module dir is present |
609 |
+ |
moduleDir = 'module' |
610 |
+ |
if os.path.isdir(swArea+'/'+moduleDir): |
611 |
+ |
filesToBeTarred.append(moduleDir) |
612 |
+ |
|
613 |
|
## Now check if the Data dir is present |
614 |
|
dataDir = 'src/Data/' |
615 |
|
if os.path.isdir(swArea+'/'+dataDir): |
637 |
|
the execution environment for the job 'nj'. |
638 |
|
""" |
639 |
|
# Prepare JobType-independent part |
640 |
< |
txt = self.wsSetupCMSEnvironment_() |
640 |
> |
txt = '' |
641 |
> |
|
642 |
> |
## OLI_Daniele at this level middleware already known |
643 |
> |
|
644 |
> |
txt += 'if [ $middleware == LCG ]; then \n' |
645 |
> |
txt += self.wsSetupCMSLCGEnvironment_() |
646 |
> |
txt += 'elif [ $middleware == OSG ]; then\n' |
647 |
> |
txt += ' time=`date -u +"%s"`\n' |
648 |
> |
txt += ' WORKING_DIR=$OSG_WN_TMP/cms_$time\n' |
649 |
> |
txt += ' echo "Creating working directory: $WORKING_DIR"\n' |
650 |
> |
txt += ' /bin/mkdir -p $WORKING_DIR\n' |
651 |
> |
txt += ' if [ ! -d $WORKING_DIR ] ;then\n' |
652 |
> |
txt += ' echo "SET_CMS_ENV 10016 ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n' |
653 |
> |
txt += ' echo "JOB_EXIT_STATUS = 10016"\n' |
654 |
> |
txt += ' echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n' |
655 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
656 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
657 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
658 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
659 |
> |
txt += ' exit 1\n' |
660 |
> |
txt += ' fi\n' |
661 |
> |
txt += '\n' |
662 |
> |
txt += ' echo "Change to working directory: $WORKING_DIR"\n' |
663 |
> |
txt += ' cd $WORKING_DIR\n' |
664 |
> |
txt += self.wsSetupCMSOSGEnvironment_() |
665 |
> |
txt += 'fi\n' |
666 |
|
|
667 |
|
# Prepare JobType-specific part |
668 |
|
scram = self.scram.commandName() |
671 |
|
txt += scram+' project CMSSW '+self.version+'\n' |
672 |
|
txt += 'status=$?\n' |
673 |
|
txt += 'if [ $status != 0 ] ; then\n' |
674 |
< |
txt += ' echo "SET_EXE_ENV 1 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n' |
675 |
< |
txt += ' echo "JOB_EXIT_STATUS = 5"\n' |
676 |
< |
txt += ' echo "SanityCheckCode = 5" | tee -a $RUNTIME_AREA/$repo\n' |
674 |
> |
txt += ' echo "SET_EXE_ENV 10034 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n' |
675 |
> |
txt += ' echo "JOB_EXIT_STATUS = 10034"\n' |
676 |
> |
txt += ' echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n' |
677 |
|
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
678 |
< |
txt += ' exit 5 \n' |
678 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
679 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
680 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
681 |
> |
## OLI_Daniele |
682 |
> |
txt += ' if [ $middleware == OSG ]; then \n' |
683 |
> |
txt += ' echo "Remove working directory: $WORKING_DIR"\n' |
684 |
> |
txt += ' cd $RUNTIME_AREA\n' |
685 |
> |
txt += ' /bin/rm -rf $WORKING_DIR\n' |
686 |
> |
txt += ' if [ -d $WORKING_DIR ] ;then\n' |
687 |
> |
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' |
688 |
> |
txt += ' echo "JOB_EXIT_STATUS = 10018"\n' |
689 |
> |
txt += ' echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n' |
690 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
691 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
692 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
693 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
694 |
> |
txt += ' fi\n' |
695 |
> |
txt += ' fi \n' |
696 |
> |
txt += ' exit 1 \n' |
697 |
|
txt += 'fi \n' |
698 |
|
txt += 'echo "CMSSW_VERSION = '+self.version+'"\n' |
699 |
|
txt += 'cd '+self.version+'\n' |
702 |
|
|
703 |
|
# Handle the arguments: |
704 |
|
txt += "\n" |
705 |
< |
txt += "## ARGUMNETS: $1 Job Number\n" |
380 |
< |
# txt += "## ARGUMNETS: $2 First Event for this job\n" |
381 |
< |
# txt += "## ARGUMNETS: $3 Max Event for this job\n" |
705 |
> |
txt += "## number of arguments (first argument always jobnumber)\n" |
706 |
|
txt += "\n" |
707 |
|
txt += "narg=$#\n" |
708 |
< |
txt += "if [ $narg -lt 1 ]\n" |
708 |
> |
txt += "if [ $narg -lt 2 ]\n" |
709 |
|
txt += "then\n" |
710 |
|
txt += " echo 'SET_EXE_ENV 1 ==> ERROR Too few arguments' +$narg+ \n" |
711 |
< |
txt += ' echo "JOB_EXIT_STATUS = 1"\n' |
712 |
< |
txt += ' echo "SanityCheckCode = 1" | tee -a $RUNTIME_AREA/$repo\n' |
711 |
> |
txt += ' echo "JOB_EXIT_STATUS = 50113"\n' |
712 |
> |
txt += ' echo "JobExitCode=50113" | tee -a $RUNTIME_AREA/$repo\n' |
713 |
|
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
714 |
+ |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
715 |
+ |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
716 |
+ |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
717 |
+ |
## OLI_Daniele |
718 |
+ |
txt += ' if [ $middleware == OSG ]; then \n' |
719 |
+ |
txt += ' echo "Remove working directory: $WORKING_DIR"\n' |
720 |
+ |
txt += ' cd $RUNTIME_AREA\n' |
721 |
+ |
txt += ' /bin/rm -rf $WORKING_DIR\n' |
722 |
+ |
txt += ' if [ -d $WORKING_DIR ] ;then\n' |
723 |
+ |
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' |
724 |
+ |
txt += ' echo "JOB_EXIT_STATUS = 50114"\n' |
725 |
+ |
txt += ' echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n' |
726 |
+ |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
727 |
+ |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
728 |
+ |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
729 |
+ |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
730 |
+ |
txt += ' fi\n' |
731 |
+ |
txt += ' fi \n' |
732 |
|
txt += " exit 1\n" |
733 |
|
txt += "fi\n" |
734 |
|
txt += "\n" |
393 |
– |
txt += "NJob=$1\n" |
394 |
– |
# txt += "FirstEvent=$2\n" |
395 |
– |
# txt += "MaxEvents=$3\n" |
735 |
|
|
736 |
|
# Prepare job-specific part |
737 |
|
job = common.job_list[nj] |
738 |
|
pset = os.path.basename(job.configFilename()) |
739 |
|
txt += '\n' |
740 |
< |
txt += 'cp $RUNTIME_AREA/'+pset+' pset.cfg\n' |
741 |
< |
# txt += 'if [ -e $RUNTIME_AREA/orcarc_$CE ] ; then\n' |
742 |
< |
# txt += ' cat $RUNTIME_AREA/orcarc_$CE .orcarc >> .orcarc_tmp\n' |
743 |
< |
# txt += ' mv .orcarc_tmp .orcarc\n' |
744 |
< |
# txt += 'fi\n' |
745 |
< |
# txt += 'if [ -e $RUNTIME_AREA/init_$CE.sh ] ; then\n' |
746 |
< |
# txt += ' cp $RUNTIME_AREA/init_$CE.sh init.sh\n' |
747 |
< |
# txt += 'fi\n' |
740 |
> |
if (self.datasetPath): # standard job |
741 |
> |
txt += 'InputFiles=$2\n' |
742 |
> |
txt += 'echo "Inputfiles:<$InputFiles>"\n' |
743 |
> |
txt += 'sed "s#{\'INPUT\'}#$InputFiles#" $RUNTIME_AREA/'+pset+' > pset.cfg\n' |
744 |
> |
else: # pythia like job |
745 |
> |
if (self.sourceSeed): |
746 |
> |
txt += 'Seed=$2\n' |
747 |
> |
txt += 'echo "Seed: <$Seed>"\n' |
748 |
> |
txt += 'sed "s#INPUT#$Seed#" $RUNTIME_AREA/'+pset+' > pset.cfg\n' |
749 |
> |
else: |
750 |
> |
txt += '# Copy untouched pset\n' |
751 |
> |
txt += 'cp $RUNTIME_AREA/'+pset+' pset.cfg\n' |
752 |
> |
|
753 |
|
|
754 |
|
if len(self.additional_inbox_files) > 0: |
755 |
|
for file in self.additional_inbox_files: |
759 |
|
txt += 'fi\n' |
760 |
|
pass |
761 |
|
|
418 |
– |
# txt += '\n' |
419 |
– |
# txt += 'chmod +x ./init.sh\n' |
420 |
– |
# txt += './init.sh\n' |
421 |
– |
# txt += 'exitStatus=$?\n' |
422 |
– |
# txt += 'if [ $exitStatus != 0 ] ; then\n' |
423 |
– |
# txt += ' echo "SET_EXE_ENV 1 ==> ERROR StageIn init script failed"\n' |
424 |
– |
# txt += ' echo "JOB_EXIT_STATUS = $exitStatus" \n' |
425 |
– |
# txt += ' echo "SanityCheckCode = $exitStatus" | tee -a $RUNTIME_AREA/$repo\n' |
426 |
– |
# txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
427 |
– |
# txt += ' exit $exitStatus\n' |
428 |
– |
# txt += 'fi\n' |
429 |
– |
# txt += "echo 'SET_EXE_ENV 0 ==> job setup ok'\n" |
762 |
|
txt += 'echo "### END JOB SETUP ENVIRONMENT ###"\n\n' |
763 |
|
|
432 |
– |
# txt += 'echo "FirstEvent=$FirstEvent" >> .orcarc\n' |
433 |
– |
# txt += 'echo "MaxEvents=$MaxEvents" >> .orcarc\n' |
434 |
– |
# if self.ML: |
435 |
– |
# txt += 'echo "MonalisaJobId=$NJob" >> .orcarc\n' |
436 |
– |
|
764 |
|
txt += '\n' |
765 |
|
txt += 'echo "***** cat pset.cfg *********"\n' |
766 |
|
txt += 'cat pset.cfg\n' |
767 |
|
txt += 'echo "****** end pset.cfg ********"\n' |
768 |
+ |
txt += '\n' |
769 |
+ |
# txt += 'echo "***** cat pset1.cfg *********"\n' |
770 |
+ |
# txt += 'cat pset1.cfg\n' |
771 |
+ |
# txt += 'echo "****** end pset1.cfg ********"\n' |
772 |
+ |
return txt |
773 |
+ |
|
774 |
+ |
def wsBuildExe(self, nj): |
775 |
+ |
""" |
776 |
+ |
Put in the script the commands to build an executable |
777 |
+ |
or a library. |
778 |
+ |
""" |
779 |
+ |
|
780 |
+ |
txt = "" |
781 |
+ |
|
782 |
+ |
if os.path.isfile(self.tgzNameWithPath): |
783 |
+ |
txt += 'echo "tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'"\n' |
784 |
+ |
txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n' |
785 |
+ |
txt += 'untar_status=$? \n' |
786 |
+ |
txt += 'if [ $untar_status -ne 0 ]; then \n' |
787 |
+ |
txt += ' echo "SET_EXE 1 ==> ERROR Untarring .tgz file failed"\n' |
788 |
+ |
txt += ' echo "JOB_EXIT_STATUS = $untar_status" \n' |
789 |
+ |
txt += ' echo "JobExitCode=$untar_status" | tee -a $RUNTIME_AREA/$repo\n' |
790 |
+ |
txt += ' if [ $middleware == OSG ]; then \n' |
791 |
+ |
txt += ' echo "Remove working directory: $WORKING_DIR"\n' |
792 |
+ |
txt += ' cd $RUNTIME_AREA\n' |
793 |
+ |
txt += ' /bin/rm -rf $WORKING_DIR\n' |
794 |
+ |
txt += ' if [ -d $WORKING_DIR ] ;then\n' |
795 |
+ |
txt += ' echo "SET_EXE 50999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Untarring .tgz file failed"\n' |
796 |
+ |
txt += ' echo "JOB_EXIT_STATUS = 50999"\n' |
797 |
+ |
txt += ' echo "JobExitCode=50999" | tee -a $RUNTIME_AREA/$repo\n' |
798 |
+ |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
799 |
+ |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
800 |
+ |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
801 |
+ |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
802 |
+ |
txt += ' fi\n' |
803 |
+ |
txt += ' fi \n' |
804 |
+ |
txt += ' \n' |
805 |
+ |
txt += ' exit 1 \n' |
806 |
+ |
txt += 'else \n' |
807 |
+ |
txt += ' echo "Successful untar" \n' |
808 |
+ |
txt += 'fi \n' |
809 |
+ |
pass |
810 |
+ |
|
811 |
|
return txt |
812 |
|
|
813 |
|
def modifySteeringCards(self, nj): |
820 |
|
return self.executable |
821 |
|
|
822 |
|
def executableArgs(self): |
823 |
< |
return "-p pset.cfg" |
823 |
> |
return " -p pset.cfg" |
824 |
|
|
825 |
|
def inputSandbox(self, nj): |
826 |
|
""" |
835 |
|
## config |
836 |
|
inp_box.append(common.job_list[nj].configFilename()) |
837 |
|
## additional input files |
838 |
< |
for file in self.additional_inbox_files: |
839 |
< |
inp_box.append(common.work_space.cwdDir()+file) |
470 |
< |
#print "sono inputSandbox, inp_box = ", inp_box |
838 |
> |
#for file in self.additional_inbox_files: |
839 |
> |
# inp_box.append(common.work_space.cwdDir()+file) |
840 |
|
return inp_box |
841 |
|
|
842 |
|
def outputSandbox(self, nj): |
859 |
|
""" |
860 |
|
Make initial modifications of the user's steering card file. |
861 |
|
""" |
493 |
– |
infile = open(self.pset,'r') |
494 |
– |
|
495 |
– |
outfile = open(common.work_space.jobDir()+self.name()+'.cfg', 'w') |
496 |
– |
|
497 |
– |
outfile.write('\n\n##### The following cards have been created by CRAB: DO NOT TOUCH #####\n') |
498 |
– |
|
499 |
– |
outfile.write('InputCollections=/System/'+self.owner+'/'+self.dataset+'/'+self.dataset+'\n') |
500 |
– |
|
501 |
– |
infile.close() |
502 |
– |
outfile.close() |
862 |
|
return |
863 |
|
|
864 |
|
def wsRenameOutput(self, nj): |
867 |
|
""" |
868 |
|
|
869 |
|
txt = '\n' |
870 |
+ |
txt += '# directory content\n' |
871 |
+ |
txt += 'ls \n' |
872 |
|
file_list = '' |
873 |
|
for fileWithSuffix in self.output_file: |
874 |
|
output_file_num = self.numberFile_(fileWithSuffix, '$NJob') |
875 |
< |
file_list=file_list+output_file_num+',' |
515 |
< |
txt += '\n' |
516 |
< |
txt += 'ls \n' |
875 |
> |
file_list=file_list+output_file_num+' ' |
876 |
|
txt += '\n' |
877 |
+ |
txt += '# check output file\n' |
878 |
|
txt += 'ls '+fileWithSuffix+'\n' |
879 |
< |
txt += 'exe_result=$?\n' |
880 |
< |
txt += 'if [ $exe_result -ne 0 ] ; then\n' |
881 |
< |
txt += ' echo "ERROR: No output file to manage"\n' |
882 |
< |
txt += ' echo "JOB_EXIT_STATUS = $exe_result"\n' |
883 |
< |
txt += ' echo "SanityCheckCode = $exe_result" | tee -a $RUNTIME_AREA/$repo\n' |
884 |
< |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
885 |
< |
txt += ' exit $exe_result \n' |
879 |
> |
txt += 'ls_result=$?\n' |
880 |
> |
#txt += 'exe_result=$?\n' |
881 |
> |
txt += 'if [ $ls_result -ne 0 ] ; then\n' |
882 |
> |
txt += ' echo "ERROR: Problem with output file"\n' |
883 |
> |
#txt += ' echo "JOB_EXIT_STATUS = $exe_result"\n' |
884 |
> |
#txt += ' echo "JobExitCode=60302" | tee -a $RUNTIME_AREA/$repo\n' |
885 |
> |
#txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
886 |
> |
### OLI_DANIELE |
887 |
> |
if common.scheduler.boss_scheduler_name == 'condor_g': |
888 |
> |
txt += ' if [ $middleware == OSG ]; then \n' |
889 |
> |
txt += ' echo "prepare dummy output file"\n' |
890 |
> |
txt += ' echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n' |
891 |
> |
txt += ' fi \n' |
892 |
|
txt += 'else\n' |
893 |
|
txt += ' cp '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n' |
894 |
|
txt += 'fi\n' |
529 |
– |
txt += 'cd $RUNTIME_AREA\n' |
530 |
– |
|
531 |
– |
pass |
895 |
|
|
896 |
+ |
txt += 'cd $RUNTIME_AREA\n' |
897 |
|
file_list=file_list[:-1] |
898 |
< |
txt += 'file_list='+file_list+'\n' |
898 |
> |
txt += 'file_list="'+file_list+'"\n' |
899 |
> |
txt += 'cd $RUNTIME_AREA\n' |
900 |
> |
### OLI_DANIELE |
901 |
> |
txt += 'if [ $middleware == OSG ]; then\n' |
902 |
> |
txt += ' cd $RUNTIME_AREA\n' |
903 |
> |
txt += ' echo "Remove working directory: $WORKING_DIR"\n' |
904 |
> |
txt += ' /bin/rm -rf $WORKING_DIR\n' |
905 |
> |
txt += ' if [ -d $WORKING_DIR ] ;then\n' |
906 |
> |
txt += ' echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n' |
907 |
> |
txt += ' echo "JOB_EXIT_STATUS = 60999"\n' |
908 |
> |
txt += ' echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n' |
909 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
910 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
911 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
912 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
913 |
> |
txt += ' fi\n' |
914 |
> |
txt += 'fi\n' |
915 |
> |
txt += '\n' |
916 |
|
return txt |
917 |
|
|
918 |
|
def numberFile_(self, file, txt): |
940 |
|
return job requirements to add to jdl files |
941 |
|
""" |
942 |
|
req = '' |
943 |
+ |
if common.analisys_common_info['sw_version']: |
944 |
+ |
req='Member("VO-cms-' + \ |
945 |
+ |
common.analisys_common_info['sw_version'] + \ |
946 |
+ |
'", other.GlueHostApplicationSoftwareRunTimeEnvironment)' |
947 |
|
if common.analisys_common_info['sites']: |
563 |
– |
if common.analisys_common_info['sw_version']: |
564 |
– |
req='Member("VO-cms-' + \ |
565 |
– |
common.analisys_common_info['sw_version'] + \ |
566 |
– |
'", other.GlueHostApplicationSoftwareRunTimeEnvironment)' |
948 |
|
if len(common.analisys_common_info['sites'])>0: |
949 |
|
req = req + ' && (' |
950 |
|
for i in range(len(common.analisys_common_info['sites'])): |
955 |
|
req = req + ')' |
956 |
|
#print "req = ", req |
957 |
|
return req |
958 |
+ |
|
959 |
+ |
def configFilename(self): |
960 |
+ |
""" return the config filename """ |
961 |
+ |
return self.name()+'.cfg' |
962 |
+ |
|
963 |
+ |
### OLI_DANIELE |
964 |
+ |
def wsSetupCMSOSGEnvironment_(self): |
965 |
+ |
""" |
966 |
+ |
Returns part of a job script which is prepares |
967 |
+ |
the execution environment and which is common for all CMS jobs. |
968 |
+ |
""" |
969 |
+ |
txt = '\n' |
970 |
+ |
txt += ' echo "### SETUP CMS OSG ENVIRONMENT ###"\n' |
971 |
+ |
txt += ' if [ -f $GRID3_APP_DIR/cmssoft/cmsset_default.sh ] ;then\n' |
972 |
+ |
txt += ' # Use $GRID3_APP_DIR/cmssoft/cmsset_default.sh to setup cms software\n' |
973 |
+ |
txt += ' source $GRID3_APP_DIR/cmssoft/cmsset_default.sh '+self.version+'\n' |
974 |
+ |
txt += ' elif [ -f $OSG_APP/cmssoft/cmsset_default.sh ] ;then\n' |
975 |
+ |
txt += ' # Use $OSG_APP/cmssoft/cmsset_default.sh to setup cms software\n' |
976 |
+ |
txt += ' source $OSG_APP/cmssoft/cmsset_default.sh '+self.version+'\n' |
977 |
+ |
txt += ' else\n' |
978 |
+ |
txt += ' echo "SET_CMS_ENV 10020 ==> ERROR $GRID3_APP_DIR/cmssoft/cmsset_default.sh and $OSG_APP/cmssoft/cmsset_default.sh file not found"\n' |
979 |
+ |
txt += ' echo "JOB_EXIT_STATUS = 10020"\n' |
980 |
+ |
txt += ' echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n' |
981 |
+ |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
982 |
+ |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
983 |
+ |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
984 |
+ |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
985 |
+ |
txt += ' exit 1\n' |
986 |
+ |
txt += '\n' |
987 |
+ |
txt += ' echo "Remove working directory: $WORKING_DIR"\n' |
988 |
+ |
txt += ' cd $RUNTIME_AREA\n' |
989 |
+ |
txt += ' /bin/rm -rf $WORKING_DIR\n' |
990 |
+ |
txt += ' if [ -d $WORKING_DIR ] ;then\n' |
991 |
+ |
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' |
992 |
+ |
txt += ' echo "JOB_EXIT_STATUS = 10017"\n' |
993 |
+ |
txt += ' echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n' |
994 |
+ |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
995 |
+ |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
996 |
+ |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
997 |
+ |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
998 |
+ |
txt += ' fi\n' |
999 |
+ |
txt += '\n' |
1000 |
+ |
txt += ' exit 1\n' |
1001 |
+ |
txt += ' fi\n' |
1002 |
+ |
txt += '\n' |
1003 |
+ |
txt += ' echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n' |
1004 |
+ |
txt += ' echo " END SETUP CMS OSG ENVIRONMENT "\n' |
1005 |
+ |
|
1006 |
+ |
return txt |
1007 |
+ |
|
1008 |
+ |
### OLI_DANIELE |
1009 |
+ |
def wsSetupCMSLCGEnvironment_(self): |
1010 |
+ |
""" |
1011 |
+ |
Returns part of a job script which is prepares |
1012 |
+ |
the execution environment and which is common for all CMS jobs. |
1013 |
+ |
""" |
1014 |
+ |
txt = ' \n' |
1015 |
+ |
txt += ' echo " ### SETUP CMS LCG ENVIRONMENT ### "\n' |
1016 |
+ |
txt += ' if [ ! $VO_CMS_SW_DIR ] ;then\n' |
1017 |
+ |
txt += ' echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n' |
1018 |
+ |
txt += ' echo "JOB_EXIT_STATUS = 10031" \n' |
1019 |
+ |
txt += ' echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n' |
1020 |
+ |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
1021 |
+ |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
1022 |
+ |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
1023 |
+ |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
1024 |
+ |
txt += ' exit 1\n' |
1025 |
+ |
txt += ' else\n' |
1026 |
+ |
txt += ' echo "Sourcing environment... "\n' |
1027 |
+ |
txt += ' if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n' |
1028 |
+ |
txt += ' echo "SET_CMS_ENV 10020 ==> ERROR cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n' |
1029 |
+ |
txt += ' echo "JOB_EXIT_STATUS = 10020"\n' |
1030 |
+ |
txt += ' echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n' |
1031 |
+ |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
1032 |
+ |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
1033 |
+ |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
1034 |
+ |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
1035 |
+ |
txt += ' exit 1\n' |
1036 |
+ |
txt += ' fi\n' |
1037 |
+ |
txt += ' echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n' |
1038 |
+ |
txt += ' source $VO_CMS_SW_DIR/cmsset_default.sh\n' |
1039 |
+ |
txt += ' result=$?\n' |
1040 |
+ |
txt += ' if [ $result -ne 0 ]; then\n' |
1041 |
+ |
txt += ' echo "SET_CMS_ENV 10032 ==> ERROR problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n' |
1042 |
+ |
txt += ' echo "JOB_EXIT_STATUS = 10032"\n' |
1043 |
+ |
txt += ' echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n' |
1044 |
+ |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
1045 |
+ |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
1046 |
+ |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
1047 |
+ |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
1048 |
+ |
txt += ' exit 1\n' |
1049 |
+ |
txt += ' fi\n' |
1050 |
+ |
txt += ' fi\n' |
1051 |
+ |
txt += ' \n' |
1052 |
+ |
txt += ' string=`cat /etc/redhat-release`\n' |
1053 |
+ |
txt += ' echo $string\n' |
1054 |
+ |
txt += ' if [[ $string = *alhalla* ]]; then\n' |
1055 |
+ |
txt += ' echo "SCRAM_ARCH= $SCRAM_ARCH"\n' |
1056 |
+ |
txt += ' elif [[ $string = *Enterprise* ]] || [[ $string = *cientific* ]]; then\n' |
1057 |
+ |
txt += ' export SCRAM_ARCH=slc3_ia32_gcc323\n' |
1058 |
+ |
txt += ' echo "SCRAM_ARCH= $SCRAM_ARCH"\n' |
1059 |
+ |
txt += ' else\n' |
1060 |
+ |
txt += ' echo "SET_CMS_ENV 10033 ==> ERROR OS unknown, LCG environment not initialized"\n' |
1061 |
+ |
txt += ' echo "JOB_EXIT_STATUS = 10033"\n' |
1062 |
+ |
txt += ' echo "JobExitCode=10033" | tee -a $RUNTIME_AREA/$repo\n' |
1063 |
+ |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
1064 |
+ |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
1065 |
+ |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
1066 |
+ |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
1067 |
+ |
txt += ' exit 1\n' |
1068 |
+ |
txt += ' fi\n' |
1069 |
+ |
txt += ' echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n' |
1070 |
+ |
txt += ' echo "### END SETUP CMS LCG ENVIRONMENT ###"\n' |
1071 |
+ |
return txt |
1072 |
+ |
|
1073 |
+ |
def setParam_(self, param, value): |
1074 |
+ |
self._params[param] = value |
1075 |
+ |
|
1076 |
+ |
def getParams(self): |
1077 |
+ |
return self._params |
1078 |
+ |
|
1079 |
+ |
def setTaskid_(self): |
1080 |
+ |
self._taskId = self.cfg_params['taskId'] |
1081 |
+ |
|
1082 |
+ |
def getTaskid(self): |
1083 |
+ |
return self._taskId |