1 |
from JobType import JobType
|
2 |
from crab_logger import Logger
|
3 |
from crab_exceptions import *
|
4 |
from crab_util import *
|
5 |
import common
|
6 |
import DataDiscovery
|
7 |
import DataLocation
|
8 |
import Scram
|
9 |
import TarBall
|
10 |
|
11 |
import os, string, re
|
12 |
|
13 |
###Fabio
|
14 |
import math
|
15 |
|
16 |
class Orca(JobType):
|
17 |
def __init__(self, cfg_params, ncjobs):
|
18 |
JobType.__init__(self, 'ORCA')
|
19 |
common.logger.debug(3,'ORCA::__init__')
|
20 |
|
21 |
self.analisys_common_info = {}
|
22 |
# Marco.
|
23 |
self._params = {}
|
24 |
self.cfg_params = cfg_params
|
25 |
|
26 |
# number of jobs requested to be created, limit ojb splitting
|
27 |
self.ncjobs = ncjobs
|
28 |
|
29 |
log = common.logger
|
30 |
|
31 |
self.scram = Scram.Scram(cfg_params)
|
32 |
scramArea = ''
|
33 |
self.additional_inbox_files = []
|
34 |
self.scriptExe = ''
|
35 |
|
36 |
self.version = self.scram.getSWVersion()
|
37 |
self.setParam_('application', self.version)
|
38 |
common.analisys_common_info['sw_version'] = self.version
|
39 |
common.analisys_common_info['copy_input_data'] = 0
|
40 |
|
41 |
self.total_number_of_jobs = 0
|
42 |
self.job_number_of_events = 0
|
43 |
|
44 |
### collect Data cards
|
45 |
try:
|
46 |
self.owner = cfg_params['ORCA.owner']
|
47 |
self.setParam_('owner', self.owner)
|
48 |
log.debug(6, "Orca::Orca(): owner = "+self.owner)
|
49 |
self.dataset = cfg_params['ORCA.dataset']
|
50 |
self.setParam_('dataset', self.dataset)
|
51 |
log.debug(6, "Orca::Orca(): dataset = "+self.dataset)
|
52 |
except KeyError:
|
53 |
msg = "Error: owner and/or dataset not defined "
|
54 |
raise CrabException(msg)
|
55 |
|
56 |
self.dataTiers = []
|
57 |
try:
|
58 |
tmpDataTiers = string.split(cfg_params['ORCA.data_tier'],',')
|
59 |
for tmp in tmpDataTiers:
|
60 |
tmp=string.strip(tmp)
|
61 |
self.dataTiers.append(tmp)
|
62 |
pass
|
63 |
pass
|
64 |
except KeyError:
|
65 |
pass
|
66 |
log.debug(6, "Orca::Orca(): dataTiers = "+str(self.dataTiers))
|
67 |
|
68 |
## now the application
|
69 |
try:
|
70 |
self.executable = cfg_params['ORCA.executable']
|
71 |
log.debug(6, "Orca::Orca(): executable = "+self.executable)
|
72 |
self.setParam_('exe', self.executable)
|
73 |
except KeyError:
|
74 |
msg = "Error: executable not defined "
|
75 |
raise CrabException(msg)
|
76 |
|
77 |
try:
|
78 |
self.orcarc_file = cfg_params['ORCA.orcarc_file']
|
79 |
log.debug(6, "Orca::Orca(): orcarc file = "+self.orcarc_file)
|
80 |
if (not os.path.exists(self.orcarc_file)):
|
81 |
raise CrabException("User defined .orcarc file "+self.orcarc_file+" does not exist")
|
82 |
except KeyError:
|
83 |
log.message("Using empty orcarc file")
|
84 |
self.orcarc_file = ''
|
85 |
|
86 |
# output files
|
87 |
try:
|
88 |
self.output_file = []
|
89 |
|
90 |
tmp = cfg_params['ORCA.output_file']
|
91 |
if tmp != '':
|
92 |
tmpOutFiles = string.split(cfg_params['ORCA.output_file'],',')
|
93 |
log.debug(7, 'Orca::Orca(): output files '+str(tmpOutFiles))
|
94 |
for tmp in tmpOutFiles:
|
95 |
tmp=string.strip(tmp)
|
96 |
self.output_file.append(tmp)
|
97 |
pass
|
98 |
|
99 |
else:
|
100 |
log.message("No output file defined: only stdout/err will be available")
|
101 |
pass
|
102 |
pass
|
103 |
except KeyError:
|
104 |
log.message("No output file defined: only stdout/err will be available")
|
105 |
pass
|
106 |
|
107 |
# script_exe file as additional file in inputSandbox
|
108 |
try:
|
109 |
self.scriptExe = cfg_params['ORCA.script_exe']
|
110 |
self.additional_inbox_files.append(self.scriptExe)
|
111 |
except KeyError:
|
112 |
pass
|
113 |
if self.scriptExe != '':
|
114 |
if os.path.isfile(self.scriptExe):
|
115 |
pass
|
116 |
else:
|
117 |
log.message("WARNING. file "+self.scriptExe+" not found")
|
118 |
sys.exit()
|
119 |
|
120 |
## additional input files
|
121 |
try:
|
122 |
tmpAddFiles = string.split(cfg_params['USER.additional_input_files'],',')
|
123 |
for tmp in tmpAddFiles:
|
124 |
tmp=string.strip(tmp)
|
125 |
self.additional_inbox_files.append(tmp)
|
126 |
pass
|
127 |
pass
|
128 |
except KeyError:
|
129 |
pass
|
130 |
|
131 |
try:
|
132 |
self.total_number_of_events = int(cfg_params['ORCA.total_number_of_events'])
|
133 |
except KeyError:
|
134 |
msg = 'Must define total_number_of_events and job_number_of_events'
|
135 |
raise CrabException(msg)
|
136 |
|
137 |
try:
|
138 |
self.first_event = int(cfg_params['ORCA.first_event'])
|
139 |
except KeyError:
|
140 |
self.first_event = 0
|
141 |
pass
|
142 |
log.debug(6, "Orca::Orca(): total number of events = "+`self.total_number_of_events`)
|
143 |
#log.debug(6, "Orca::Orca(): events per job = "+`self.job_number_of_events`)
|
144 |
log.debug(6, "Orca::Orca(): first event = "+`self.first_event`)
|
145 |
|
146 |
#DBSDLS-start
|
147 |
## Initialize the variables that are extracted from DBS/DLS and needed in other places of the code
|
148 |
self.maxEvents=0 # max events available ( --> check the requested nb. of evts in Creator.py)
|
149 |
self.DBSPaths={} # all dbs paths requested ( --> input to the site local discovery script)
|
150 |
## Perform the data location and discovery (based on DBS/DLS)
|
151 |
self.DataDiscoveryAndLocation(cfg_params)
|
152 |
#DBSDLS-end
|
153 |
|
154 |
self.TarBaller = TarBall.TarBall(self.executable, self.scram)
|
155 |
self.tgzNameWithPath = self.TarBaller.prepareTarBall()
|
156 |
|
157 |
try:
|
158 |
self.ML = int(cfg_params['USER.activate_monalisa'])
|
159 |
except KeyError:
|
160 |
self.ML = 0
|
161 |
pass
|
162 |
|
163 |
self.setTaskid_()
|
164 |
self.setParam_('taskId', self.cfg_params['taskId'])
|
165 |
|
166 |
return
|
167 |
|
168 |
def split(self, jobParams):
|
169 |
"""
|
170 |
This method returns the list of orca specific job type items
|
171 |
needed to run the jobs
|
172 |
"""
|
173 |
common.jobDB.load()
|
174 |
njobs = self.total_number_of_jobs
|
175 |
# create the empty structure
|
176 |
for i in range(njobs):
|
177 |
jobParams.append("")
|
178 |
|
179 |
# fill the both the list and the DB (part of the code taken from jobsToDB)
|
180 |
firstEvent = self.first_event
|
181 |
lastJobsNumberOfEvents = str(self.job_number_of_events)
|
182 |
# last jobs is different...
|
183 |
for job in range(njobs-1):
|
184 |
jobParams[job] = [str(firstEvent), str(lastJobsNumberOfEvents)]
|
185 |
common.jobDB.setArguments(job, jobParams[job])
|
186 |
common.jobDB.setDestination(job, self.sites)
|
187 |
firstEvent += self.job_number_of_events
|
188 |
|
189 |
# this is the last job
|
190 |
lastJobsNumberOfEvents = (self.total_number_of_events + self.first_event) - firstEvent
|
191 |
status = common.jobDB.status(njobs - 1)
|
192 |
jobParams[njobs - 1] = [str(firstEvent), str(lastJobsNumberOfEvents)]
|
193 |
common.jobDB.setArguments(njobs - 1, jobParams[njobs - 1])
|
194 |
|
195 |
if (lastJobsNumberOfEvents!=self.job_number_of_events):
|
196 |
common.logger.message(str(self.total_number_of_jobs-1)+' jobs will be created for '+str(self.job_number_of_events)+' events each plus 1 for '+str(lastJobsNumberOfEvents)+' events for a total of '+str(self.job_number_of_events*(self.total_number_of_jobs-1)+lastJobsNumberOfEvents)+' events')
|
197 |
else:
|
198 |
common.logger.message(str(self.total_number_of_jobs)+' jobs will be created for '+str(self.job_number_of_events)+' events each for a total of '+str(self.job_number_of_events*(self.total_number_of_jobs-1)+lastJobsNumberOfEvents)+' events')
|
199 |
|
200 |
common.jobDB.save()
|
201 |
return
|
202 |
|
203 |
def getJobTypeArguments(self, nj, sched):
|
204 |
params = common.jobDB.arguments(nj)
|
205 |
|
206 |
if sched=="EDG" or sched=="CONDOR" or sched=="GRID":
|
207 |
parString = "" + str(params[0])+' '+str(params[1])
|
208 |
elif sched=="BOSS":
|
209 |
parString = "" + str(params[0])+' '+str(params[1])
|
210 |
else:
|
211 |
return ""
|
212 |
return parString
|
213 |
|
214 |
def numberOfJobs(self):
|
215 |
first_event = self.first_event
|
216 |
maxAvailableEvents = int(self.maxEvents)
|
217 |
common.logger.debug(1,"Available events: "+str(maxAvailableEvents))
|
218 |
if first_event>=maxAvailableEvents:
|
219 |
raise CrabException('First event is bigger than maximum number of available events!')
|
220 |
|
221 |
try:
|
222 |
n = self.total_number_of_events
|
223 |
if n == 'all': n = '-1'
|
224 |
if n == '-1':
|
225 |
tot_num_events = (maxAvailableEvents - first_event)
|
226 |
common.logger.debug(1,"Analysing all available events "+str(tot_num_events))
|
227 |
else:
|
228 |
if maxAvailableEvents<(int(n)+ first_event): # + self.first_event):
|
229 |
raise CrabException('(First event + total events)='+str(int(n)+first_event)+' is bigger than maximum number of available events '+str(maxAvailableEvents)+' !! Use "total_number_of_events=-1" to analyze to whole dataset')
|
230 |
tot_num_events = int(n)
|
231 |
except KeyError:
|
232 |
common.logger.message("total_number_of_events not defined, set it to maximum available")
|
233 |
tot_num_events = (maxAvailableEvents - first_event)
|
234 |
pass
|
235 |
common.logger.message("Total number of events to be analyzed: "+str(self.total_number_of_events))
|
236 |
|
237 |
|
238 |
# read user directives
|
239 |
eventPerJob=0
|
240 |
try:
|
241 |
eventPerJob = self.cfg_params['ORCA.job_number_of_events']
|
242 |
except KeyError:
|
243 |
pass
|
244 |
|
245 |
jobsPerTask=0
|
246 |
try:
|
247 |
jobsPerTask = int(self.cfg_params['ORCA.total_number_of_jobs'])
|
248 |
except KeyError:
|
249 |
pass
|
250 |
|
251 |
# If both the above set, complain and use event per jobs
|
252 |
if eventPerJob>0 and jobsPerTask>0:
|
253 |
msg = 'Warning. '
|
254 |
msg += 'job_number_of_events and total_number_of_jobs are both defined '
|
255 |
msg += 'Using job_number_of_events.'
|
256 |
common.logger.message(msg)
|
257 |
jobsPerTask = 0
|
258 |
if eventPerJob==0 and jobsPerTask==0:
|
259 |
msg = 'Warning. '
|
260 |
msg += 'job_number_of_events and total_number_of_jobs are not defined '
|
261 |
msg += 'Creating just one job for all events.'
|
262 |
common.logger.message(msg)
|
263 |
jobsPerTask = 1
|
264 |
|
265 |
# first case: events per job defined
|
266 |
if eventPerJob>0:
|
267 |
n=eventPerJob
|
268 |
#if n == 'all' or n == '-1' or (int(n)>self.total_number_of_events and self.total_number_of_events>0):
|
269 |
if n == 'all' or n == '-1' or (int(n)>tot_num_events and tot_num_events>0):
|
270 |
common.logger.message("Asking more events than available: set it to maximum available")
|
271 |
job_num_events = tot_num_events
|
272 |
tot_num_jobs = 1
|
273 |
else:
|
274 |
job_num_events = int(n)
|
275 |
tot_num_jobs = int((tot_num_events-1)/job_num_events)+1
|
276 |
|
277 |
elif jobsPerTask>0:
|
278 |
common.logger.debug(2,"total number of events: "+str(tot_num_events)+" JobPerTask "+str(jobsPerTask))
|
279 |
job_num_events = int(math.floor((tot_num_events)/jobsPerTask))
|
280 |
tot_num_jobs = jobsPerTask
|
281 |
|
282 |
# should not happen...
|
283 |
else:
|
284 |
raise CrabException('Something wrong with splitting')
|
285 |
|
286 |
common.logger.debug(2,"total number of events: "+str(tot_num_events)+" events per job: "+str(job_num_events))
|
287 |
|
288 |
#used by jobsToDB for logs
|
289 |
self.job_number_of_events = job_num_events
|
290 |
self.total_number_of_jobs = tot_num_jobs
|
291 |
return tot_num_jobs
|
292 |
|
293 |
|
294 |
def jobsToDB(self, nJobs):
|
295 |
"""
|
296 |
Fill the DB with proper entries for ORCA
|
297 |
"""
|
298 |
|
299 |
firstEvent = self.first_event
|
300 |
lastJobsNumberOfEvents = self.job_number_of_events
|
301 |
|
302 |
# last jobs is different...
|
303 |
for job in range(nJobs-1):
|
304 |
common.jobDB.setFirstEvent(job, firstEvent)
|
305 |
common.jobDB.setMaxEvents(job, self.job_number_of_events)
|
306 |
firstEvent=firstEvent+self.job_number_of_events
|
307 |
|
308 |
# this is the last job
|
309 |
common.jobDB.setFirstEvent(nJobs-1, firstEvent)
|
310 |
lastJobsNumberOfEvents= (self.total_number_of_events+self.first_event)-firstEvent
|
311 |
common.jobDB.setMaxEvents(nJobs-1, lastJobsNumberOfEvents)
|
312 |
|
313 |
if (lastJobsNumberOfEvents!=self.job_number_of_events):
|
314 |
common.logger.message(str(self.total_number_of_jobs-1)+' jobs will be created for '+str(self.job_number_of_events)+' events each plus 1 for '+str(lastJobsNumberOfEvents)+' events for a total of '+str(self.job_number_of_events*(self.total_number_of_jobs-1)+lastJobsNumberOfEvents)+' events')
|
315 |
else:
|
316 |
common.logger.message(str(self.total_number_of_jobs)+' jobs will be created for '+str(self.job_number_of_events)+' events each for a total of '+str(self.job_number_of_events*(self.total_number_of_jobs-1)+lastJobsNumberOfEvents)+' events')
|
317 |
|
318 |
return
|
319 |
|
320 |
|
321 |
def wsSetupEnvironment(self, nj):
|
322 |
"""
|
323 |
Returns part of a job script which prepares
|
324 |
the execution environment for the job 'nj'.
|
325 |
"""
|
326 |
|
327 |
# Prepare JobType-independent part
|
328 |
txt = ''
|
329 |
|
330 |
## OLI_Daniele at this level middleware already known
|
331 |
|
332 |
txt += 'if [ $middleware == LCG ]; then \n'
|
333 |
txt += self.wsSetupCMSLCGEnvironment_()
|
334 |
txt += 'elif [ $middleware == OSG ]; then\n'
|
335 |
txt += ' WORKING_DIR=`/bin/mktemp -d $OSG_WN_TMP/cms_XXXXXXXXXXXX`\n'
|
336 |
txt += ' echo "Created working directory: $WORKING_DIR"\n'
|
337 |
txt += ' if [ ! -d $WORKING_DIR ] ;then\n'
|
338 |
txt += ' echo "SET_CMS_ENV 10016 ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
|
339 |
txt += ' echo "JOB_EXIT_STATUS = 10016"\n'
|
340 |
txt += ' echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
|
341 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
342 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
343 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
344 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
345 |
txt += ' exit 1\n'
|
346 |
txt += ' fi\n'
|
347 |
txt += '\n'
|
348 |
txt += ' echo "Change to working directory: $WORKING_DIR"\n'
|
349 |
txt += ' cd $WORKING_DIR\n'
|
350 |
txt += self.wsSetupCMSOSGEnvironment_()
|
351 |
txt += 'fi\n'
|
352 |
|
353 |
# Prepare JobType-specific part
|
354 |
scram = self.scram.commandName()
|
355 |
txt += '\n\n'
|
356 |
txt += 'echo "### SPECIFIC JOB SETUP ENVIRONMENT ###"\n'
|
357 |
txt += scram+' project ORCA '+self.version+'\n'
|
358 |
txt += 'status=$?\n'
|
359 |
txt += 'if [ $status != 0 ] ; then\n'
|
360 |
txt += ' echo "SET_EXE_ENV 10034 ==>ERROR ORCA '+self.version+' not found on `hostname`" \n'
|
361 |
txt += ' echo "JOB_EXIT_STATUS = 10034"\n'
|
362 |
txt += ' echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n'
|
363 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
364 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
365 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
366 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
367 |
## OLI_Daniele
|
368 |
txt += ' if [ $middleware == OSG ]; then \n'
|
369 |
txt += ' echo "Remove working directory: $WORKING_DIR"\n'
|
370 |
txt += ' cd $RUNTIME_AREA\n'
|
371 |
txt += ' /bin/rm -rf $WORKING_DIR\n'
|
372 |
txt += ' if [ -d $WORKING_DIR ] ;then\n'
|
373 |
txt += ' echo "SET_CMS_ENV 10018 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after ORCA not found on `hostname`"\n'
|
374 |
txt += ' echo "JOB_EXIT_STATUS = 10018"\n'
|
375 |
txt += ' echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n'
|
376 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
377 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
378 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
379 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
380 |
txt += ' fi\n'
|
381 |
txt += ' fi \n'
|
382 |
txt += ' exit 1\n'
|
383 |
txt += 'fi \n'
|
384 |
txt += 'echo "ORCA_VERSION = '+self.version+'"\n'
|
385 |
txt += 'cd '+self.version+'\n'
|
386 |
### needed grep for bug in scramv1 ###
|
387 |
|
388 |
#txt += 'eval `'+scram+' runtime -sh | grep -v SCRAMRT_LSB_JOBNAME`\n'
|
389 |
|
390 |
# Handle the arguments:
|
391 |
txt += "\n"
|
392 |
# txt += "## ARGUMNETS: $1 Job Number\n"
|
393 |
# txt += "## ARGUMNETS: $2 First Event for this job\n"
|
394 |
# txt += "## ARGUMNETS: $3 Max Event for this job\n"
|
395 |
txt += "## ARGUMENTS: ${args[0]} Job Number\n"
|
396 |
txt += "## ARGUMENTS: ${args[1]} First Event for this job\n"
|
397 |
txt += "## ARGUMENTS: ${args[2]} Max Event for this job\n"
|
398 |
txt += "\n"
|
399 |
# txt += "narg=$#\n"
|
400 |
# txt += "NJob=$1\n"
|
401 |
# txt += "FirstEvent=$2\n"
|
402 |
# txt += "MaxEvents=$3\n"
|
403 |
txt += "NJob=${args[0]}\n"
|
404 |
txt += "FirstEvent=${args[1]}\n"
|
405 |
txt += "MaxEvents=${args[2]}\n"
|
406 |
txt += "if [ $nargs -lt 3 ]\n"
|
407 |
txt += "then\n"
|
408 |
txt += " echo 'SET_EXE_ENV 50113 ==> ERROR Too few arguments' +$nargs+ \n"
|
409 |
txt += ' echo "JOB_EXIT_STATUS = 50113"\n'
|
410 |
txt += ' echo "JobExitCode=50113" | tee -a $RUNTIME_AREA/$repo\n'
|
411 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
412 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
413 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
414 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
415 |
|
416 |
## OLI_Daniele
|
417 |
txt += ' if [ $middleware == OSG ]; then \n'
|
418 |
txt += ' echo "Remove working directory: $WORKING_DIR"\n'
|
419 |
txt += ' cd $RUNTIME_AREA\n'
|
420 |
txt += ' /bin/rm -rf $WORKING_DIR\n'
|
421 |
txt += ' if [ -d $WORKING_DIR ] ;then\n'
|
422 |
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'
|
423 |
txt += ' echo "JOB_EXIT_STATUS = 50114"\n'
|
424 |
txt += ' echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n'
|
425 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
426 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
427 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
428 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
429 |
txt += ' fi\n'
|
430 |
txt += ' fi \n'
|
431 |
txt += " exit 1\n"
|
432 |
txt += "fi\n"
|
433 |
txt += "\n"
|
434 |
|
435 |
# Prepare job-specific part
|
436 |
job = common.job_list[nj]
|
437 |
orcarc = os.path.basename(job.configFilename())
|
438 |
txt += '\n'
|
439 |
#DBSDLS-start
|
440 |
#### site-local catalogue discovery mechanism:
|
441 |
## check that the site configuration file exists
|
442 |
txt += 'echo "### Site Local Catalogue Discovery ### "\n'
|
443 |
txt += 'if [ $middleware == LCG ]; then \n'
|
444 |
txt += ' if [ -f $VO_CMS_SW_DIR/cms_site_config ]; then \n'
|
445 |
txt += ' dbsdls_cms_site_config=$VO_CMS_SW_DIR/cms_site_config\n'
|
446 |
txt += ' else\n'
|
447 |
txt += ' echo "Site Local Catalogue Discovery Failed: No site configuration file $VO_CMS_SW_DIR/cms_site_config !" \n'
|
448 |
txt += ' echo "JOB_EXIT_STATUS = 10037"\n'
|
449 |
txt += ' echo "JobExitCode=10037" | tee -a $RUNTIME_AREA/$repo\n'
|
450 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
451 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
452 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
453 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
454 |
txt += ' exit 1\n'
|
455 |
txt += ' fi \n'
|
456 |
txt += 'elif [ $middleware == OSG ]; then\n'
|
457 |
txt += ' if [ -f $GRID3_APP_DIR/cmssoft/cms_site_config ]; then \n'
|
458 |
txt += ' dbsdls_cms_site_config=$GRID3_APP_DIR/cmssoft/cms_site_config\n'
|
459 |
txt += ' elif [ -f $OSG_APP/cmssoft/cms_site_config ]; then \n'
|
460 |
txt += ' dbsdls_cms_site_config=$OSG_APP/cmssoft/cms_site_config\n'
|
461 |
txt += ' else\n'
|
462 |
txt += ' echo "Site Local Catalogue Discovery Failed: No site configuration file $GRID3_APP_DIR/cmssoft/cms_site_config or $OSG_APP/cmssoft/cms_site_config !" \n'
|
463 |
txt += ' echo "JOB_EXIT_STATUS = 10037"\n'
|
464 |
txt += ' echo "JobExitCode=10037" | tee -a $RUNTIME_AREA/$repo\n'
|
465 |
txt += ' if [ $middleware == OSG ]; then \n'
|
466 |
txt += ' echo "Remove working directory: $WORKING_DIR"\n'
|
467 |
txt += ' cd $RUNTIME_AREA\n'
|
468 |
txt += ' /bin/rm -rf $WORKING_DIR\n'
|
469 |
txt += ' if [ -d $WORKING_DIR ] ;then\n'
|
470 |
txt += ' echo "SET_EXE_ENV 10019 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after No site configuration file $GRID3_APP_DIR/cmssoft/cms_site_config or $OSG_APP/cmssoft/cms_site_config"\n'
|
471 |
txt += ' echo "JOB_EXIT_STATUS = 10019"\n'
|
472 |
txt += ' echo "JobExitCode=10019" | tee -a $RUNTIME_AREA/$repo\n'
|
473 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
474 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
475 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
476 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
477 |
txt += ' fi\n'
|
478 |
txt += ' fi \n'
|
479 |
txt += ' exit 1\n'
|
480 |
txt += ' fi \n'
|
481 |
txt += 'fi\n'
|
482 |
txt += 'echo "Site Local Catalog Discovery, selected site configuration: $dbsdls_cms_site_config"\n'
|
483 |
## look for a site local script sent as inputsandbox otherwise use the default one under $VO_CMS_SW_DIR for LCG or $GRID3_APP_DIR/cmssoft or $OSG_APP/cmssoft for OSG
|
484 |
txt += 'if [ -f $RUNTIME_AREA/cms_site_catalogue.sh ]; then \n'
|
485 |
txt += ' sitelocalscript=$RUNTIME_AREA/cms_site_catalogue.sh \n'
|
486 |
txt += 'elif [ $middleware == LCG ]; then \n'
|
487 |
txt += ' if [ -f $VO_CMS_SW_DIR/cms_site_catalogue.sh ]; then \n'
|
488 |
txt += ' sitelocalscript=$VO_CMS_SW_DIR/cms_site_catalogue.sh \n'
|
489 |
txt += ' else \n'
|
490 |
txt += ' echo "Site Local Catalogue Discovery Failed: No site local script cms_site_catalogue.sh !"\n'
|
491 |
txt += ' echo "JOB_EXIT_STATUS = 10038"\n'
|
492 |
txt += ' echo "JobExitCode=10038" | tee -a $RUNTIME_AREA/$repo\n'
|
493 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
494 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
495 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
496 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
497 |
txt += ' exit 1\n'
|
498 |
txt += ' fi \n'
|
499 |
txt += 'elif [ $middleware == OSG ]; then\n'
|
500 |
txt += ' if [ -f $GRID3_APP_DIR/cmssoft/cms_site_catalogue.sh ]; then \n'
|
501 |
txt += ' sitelocalscript=$GRID3_APP_DIR/cmssoft/cms_site_catalogue.sh\n'
|
502 |
txt += ' elif [ -f $OSG_APP/cmssoft/cms_site_catalogue.sh ]; then \n'
|
503 |
txt += ' sitelocalscript=$OSG_APP/cmssoft/cms_site_catalogue.sh\n'
|
504 |
txt += ' else\n'
|
505 |
txt += ' echo "Site Local Catalogue Discovery Failed: No site local script cms_site_catalogue.sh !"\n'
|
506 |
txt += ' echo "JOB_EXIT_STATUS = 10038"\n'
|
507 |
txt += ' echo "JobExitCode=10038" | tee -a $RUNTIME_AREA/$repo\n'
|
508 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
509 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
510 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
511 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
512 |
txt += ' if [ $middleware == OSG ]; then \n'
|
513 |
txt += ' echo "Remove working directory: $WORKING_DIR"\n'
|
514 |
txt += ' cd $RUNTIME_AREA\n'
|
515 |
txt += ' /bin/rm -rf $WORKING_DIR\n'
|
516 |
txt += ' if [ -d $WORKING_DIR ] ;then\n'
|
517 |
txt += ' echo "SET_EXE_ENV 10014 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after No site local script cms_site_catalogue.sh"\n'
|
518 |
txt += ' echo "JOB_EXIT_STATUS = 10014"\n'
|
519 |
txt += ' echo "JobExitCode=10014" | tee -a $RUNTIME_AREA/$repo\n'
|
520 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
521 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
522 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
523 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
524 |
txt += ' fi\n'
|
525 |
txt += ' fi \n'
|
526 |
txt += ' exit 1\n'
|
527 |
txt += ' fi \n'
|
528 |
txt += 'fi\n'
|
529 |
txt += 'echo "Site Local Catalog Discovery, selected local script: $sitelocalscript"\n'
|
530 |
## execute the site local configuration script with the user requied data as input
|
531 |
inputdata=string.join(self.DBSPaths,' ')
|
532 |
sitecatalog_cmd='$sitelocalscript -c $dbsdls_cms_site_config '+inputdata
|
533 |
txt += sitecatalog_cmd+'\n'
|
534 |
txt += 'sitestatus=$?\n'
|
535 |
txt += 'if [ ! -f inputurl_orcarc ] || [ $sitestatus -ne 0 ]; then\n'
|
536 |
txt += ' echo "Site Local Catalogue Discovery Failed: exiting with $sitestatus"\n'
|
537 |
txt += ' echo "JOB_EXIT_STATUS = 1"\n'
|
538 |
txt += ' echo "JobExitCode=10039" | tee -a $RUNTIME_AREA/$repo\n'
|
539 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
540 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
541 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
542 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
543 |
txt += ' if [ $middleware == OSG ]; then \n'
|
544 |
txt += ' echo "Remove working directory: $WORKING_DIR"\n'
|
545 |
txt += ' cd $RUNTIME_AREA\n'
|
546 |
txt += ' /bin/rm -rf $WORKING_DIR\n'
|
547 |
txt += ' if [ -d $WORKING_DIR ] ;then\n'
|
548 |
txt += ' echo "SET_EXE_ENV 10013 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Site Local Catalogue Discovery Failed: exiting with $sitestatus"\n'
|
549 |
txt += ' echo "JOB_EXIT_STATUS = 10013"\n'
|
550 |
txt += ' echo "JobExitCode=10013" | tee -a $RUNTIME_AREA/$repo\n'
|
551 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
552 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
553 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
554 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
555 |
txt += ' fi\n'
|
556 |
txt += ' fi \n'
|
557 |
txt += ' exit 1\n'
|
558 |
txt += 'fi \n'
|
559 |
## append the orcarc fragment about the Input catalogues to the .orcarc
|
560 |
txt += 'cp $RUNTIME_AREA/'+orcarc+' .orcarc\n'
|
561 |
txt +=' cat inputurl_orcarc >> .orcarc\n'
|
562 |
#DBSDLS-end
|
563 |
|
564 |
if len(self.additional_inbox_files) > 0:
|
565 |
for file in self.additional_inbox_files:
|
566 |
file = os.path.basename(file)
|
567 |
txt += 'if [ -e $RUNTIME_AREA/'+file+' ] ; then\n'
|
568 |
txt += ' cp $RUNTIME_AREA/'+file+' .\n'
|
569 |
txt += ' chmod +x '+file+'\n'
|
570 |
txt += 'fi\n'
|
571 |
pass
|
572 |
|
573 |
### OLI_DANIELE
|
574 |
txt += "echo 'SET_EXE_ENV 0 ==> job setup ok'\n"
|
575 |
txt += 'echo "### END JOB SETUP ENVIRONMENT ###"\n\n'
|
576 |
|
577 |
txt += 'echo "FirstEvent=$FirstEvent" >> .orcarc\n'
|
578 |
txt += 'echo "MaxEvents=$MaxEvents" >> .orcarc\n'
|
579 |
if self.ML:
|
580 |
txt += 'echo "MonalisaJobId=$NJob" >> .orcarc\n'
|
581 |
|
582 |
txt += '\n'
|
583 |
txt += 'echo "***** cat .orcarc *********"\n'
|
584 |
txt += 'cat .orcarc\n'
|
585 |
txt += 'echo "****** end .orcarc ********"\n'
|
586 |
return txt
|
587 |
|
588 |
def wsBuildExe(self, nj):
|
589 |
"""
|
590 |
Put in the script the commands to build an executable
|
591 |
or a library.
|
592 |
"""
|
593 |
|
594 |
txt = ""
|
595 |
|
596 |
if os.path.isfile(self.tgzNameWithPath):
|
597 |
txt += 'echo "tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'"\n'
|
598 |
txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
|
599 |
txt += 'untar_status=$? \n'
|
600 |
txt += 'if [ $untar_status -ne 0 ]; then \n'
|
601 |
txt += ' echo "SET_EXE 1 ==> ERROR Untarring .tgz file failed"\n'
|
602 |
txt += ' echo "JOB_EXIT_STATUS = $untar_status" \n'
|
603 |
txt += ' echo "JobExitCode=$untar_status" | tee -a $repo\n'
|
604 |
|
605 |
### OLI_DANIELE
|
606 |
txt += ' if [ $middleware == OSG ]; then \n'
|
607 |
txt += ' echo "Remove working directory: $WORKING_DIR"\n'
|
608 |
txt += ' cd $RUNTIME_AREA\n'
|
609 |
txt += ' /bin/rm -rf $WORKING_DIR\n'
|
610 |
txt += ' if [ -d $WORKING_DIR ] ;then\n'
|
611 |
txt += ' echo "SET_EXE 50999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Untarring .tgz file failed"\n'
|
612 |
txt += ' echo "JOB_EXIT_STATUS = 50999"\n'
|
613 |
txt += ' echo "JobExitCode=50999" | tee -a $RUNTIME_AREA/$repo\n'
|
614 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
615 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
616 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
617 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
618 |
txt += ' fi\n'
|
619 |
txt += ' fi \n'
|
620 |
txt += ' \n'
|
621 |
txt += ' exit 1 \n'
|
622 |
txt += 'else \n'
|
623 |
txt += ' echo "Successful untar" \n'
|
624 |
txt += 'fi \n'
|
625 |
# TODO: what does this code do here ?
|
626 |
# SL check that lib/Linux__... is present
|
627 |
txt += 'mkdir -p lib/${SCRAM_ARCH} \n'
|
628 |
pass
|
629 |
txt += 'eval `'+self.scram.commandName()+' runtime -sh |grep -v SCRAMRT_LSB_JOBNAME`'+'\n'
|
630 |
|
631 |
return txt
|
632 |
|
633 |
def wsRenameOutput(self, nj):
|
634 |
"""
|
635 |
Returns part of a job script which renames the produced files.
|
636 |
"""
|
637 |
|
638 |
txt = '\n'
|
639 |
txt += '# directory content\n'
|
640 |
txt += 'ls \n'
|
641 |
file_list = ''
|
642 |
for fileWithSuffix in self.output_file:
|
643 |
output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
|
644 |
file_list=file_list+output_file_num+' '
|
645 |
txt += '\n'
|
646 |
txt += 'ls '+fileWithSuffix+'\n'
|
647 |
#txt += 'exe_result=$?\n'
|
648 |
txt += 'ls_result=$?\n'
|
649 |
#txt += 'if [ $exe_result -ne 0 ] ; then\n'
|
650 |
txt += 'if [ $ls_result -ne 0 ] ; then\n'
|
651 |
txt += ' echo "ERROR: Problem with output file"\n'
|
652 |
#txt += ' echo "ERROR: No output file to manage"\n'
|
653 |
#txt += ' echo "JOB_EXIT_STATUS = $exe_result"\n'
|
654 |
#txt += ' echo "JobExitCode=60302" | tee -a $RUNTIME_AREA/$repo\n'
|
655 |
#txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
656 |
# txt += 'exe_result=$?\n'
|
657 |
# txt += 'if [ $exe_result -ne 0 ] ; then\n'
|
658 |
# txt += ' echo "ERROR: No output file to manage"\n'
|
659 |
# txt += ' echo "JOB_EXIT_STATUS = $exe_result"\n'
|
660 |
# txt += ' echo "JobExitCode=60302" | tee -a $RUNTIME_AREA/$repo\n'
|
661 |
# txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
662 |
# txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
663 |
# txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
664 |
# txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
665 |
|
666 |
### OLI_DANIELE
|
667 |
if common.scheduler.boss_scheduler_name == 'condor_g':
|
668 |
txt += ' if [ $middleware == OSG ]; then \n'
|
669 |
txt += ' echo "prepare dummy output file"\n'
|
670 |
txt += ' echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
|
671 |
txt += ' fi \n'
|
672 |
txt += 'else\n'
|
673 |
txt += ' cp '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
|
674 |
txt += 'fi\n'
|
675 |
|
676 |
|
677 |
txt += 'cd $RUNTIME_AREA\n'
|
678 |
file_list=file_list[:-1]
|
679 |
txt += 'file_list="'+file_list+'"\n'
|
680 |
### OLI_DANIELE
|
681 |
txt += 'if [ $middleware == OSG ]; then\n'
|
682 |
txt += ' cd $RUNTIME_AREA\n'
|
683 |
txt += ' echo "Remove working directory: $WORKING_DIR"\n'
|
684 |
txt += ' /bin/rm -rf $WORKING_DIR\n'
|
685 |
txt += ' if [ -d $WORKING_DIR ] ;then\n'
|
686 |
txt += ' echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
|
687 |
txt += ' echo "JOB_EXIT_STATUS = 60999"\n'
|
688 |
txt += ' echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
|
689 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
690 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
691 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
692 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
693 |
txt += ' fi\n'
|
694 |
txt += 'fi\n'
|
695 |
txt += '\n'
|
696 |
|
697 |
return txt
|
698 |
|
699 |
def executableName(self):
|
700 |
if self.scriptExe != '':
|
701 |
return "./" + os.path.basename(self.scriptExe)
|
702 |
else:
|
703 |
return self.executable
|
704 |
|
705 |
#DBSDLS-start
|
706 |
def DataDiscoveryAndLocation(self, cfg_params):
|
707 |
|
708 |
fun = "Orca::DataDiscoveryAndLocation()"
|
709 |
|
710 |
## Contact the DBS
|
711 |
try:
|
712 |
self.pubdata=DataDiscovery.DataDiscovery(self.owner,
|
713 |
self.dataset,
|
714 |
self.dataTiers,
|
715 |
cfg_params)
|
716 |
self.pubdata.fetchDBSInfo()
|
717 |
|
718 |
except DataDiscovery.NotExistingDatasetError, ex :
|
719 |
msg = 'ERROR ***: failed Data Discovery in DBS : %s'%ex.getErrorMessage()
|
720 |
raise CrabException(msg)
|
721 |
|
722 |
except DataDiscovery.NoDataTierinProvenanceError, ex :
|
723 |
msg = 'ERROR ***: failed Data Discovery in DBS : %s'%ex.getErrorMessage()
|
724 |
raise CrabException(msg)
|
725 |
except DataDiscovery.DataDiscoveryError, ex:
|
726 |
msg = 'ERROR ***: failed Data Discovery in DBS %s'%ex.getErrorMessage()
|
727 |
raise CrabException(msg)
|
728 |
|
729 |
## get list of all required data in the form of dbs paths (dbs path = /dataset/datatier/owner)
|
730 |
self.DBSPaths=self.pubdata.getDBSPaths()
|
731 |
common.logger.message("Required data are : ")
|
732 |
for path in self.DBSPaths:
|
733 |
common.logger.message(" --> "+path )
|
734 |
|
735 |
## get max number of events
|
736 |
#common.logger.debug(10,"number of events for primary fileblocks %i"%self.pubdata.getMaxEvents())
|
737 |
self.maxEvents=self.pubdata.getMaxEvents() ## self.maxEvents used in Creator.py
|
738 |
common.logger.message("\nThe number of available events is %s"%self.maxEvents)
|
739 |
|
740 |
## get fileblocks corresponding to the required data
|
741 |
fb=self.pubdata.getFileBlocks()
|
742 |
|
743 |
|
744 |
## Contact the DLS and build a list of sites hosting the fileblocks
|
745 |
try:
|
746 |
dataloc=DataLocation.DataLocation(self.pubdata.getFileBlocks(),cfg_params)
|
747 |
dataloc.fetchDLSInfo()
|
748 |
except DataLocation.DataLocationError , ex:
|
749 |
msg = 'ERROR ***: failes Data Location in DLS \n %s '%ex.getErrorMessage()
|
750 |
raise CrabException(msg)
|
751 |
|
752 |
|
753 |
self.sites=dataloc.getSites()
|
754 |
|
755 |
if len(self.sites)==0:
|
756 |
msg = 'No sites hosting all the needed data! Exiting... '
|
757 |
raise CrabException(msg)
|
758 |
common.logger.message("List of Sites ("+str(len(self.sites))+") hosting the data : "+str(self.sites))
|
759 |
common.logger.debug(6, "List of Sites: "+str(self.sites))
|
760 |
|
761 |
return
|
762 |
|
763 |
#DBDDLS-stop
|
764 |
|
765 |
|
766 |
def nJobs(self):
|
767 |
# TODO: should not be here !
|
768 |
# JobType should have no internal knowledge about submitted jobs
|
769 |
# One possibility is to use len(common.job_list).
|
770 |
""" return the number of job to be created """
|
771 |
return len(common.job_list)
|
772 |
|
773 |
def prepareSteeringCards(self):
|
774 |
"""
|
775 |
modify the orcarc card provided by the user,
|
776 |
writing a new card into share dir
|
777 |
"""
|
778 |
infile = ''
|
779 |
try:
|
780 |
infile = open(self.orcarc_file,'r')
|
781 |
except:
|
782 |
self.orcarc_file = 'empty.orcarc'
|
783 |
cmd='touch '+self.orcarc_file
|
784 |
runCommand(cmd)
|
785 |
infile = open(self.orcarc_file,'r')
|
786 |
|
787 |
outfile = open(common.work_space.jobDir()+self.name()+'.orcarc', 'w')
|
788 |
|
789 |
inline=infile.readlines()
|
790 |
### remove from user card these lines ###
|
791 |
wordRemove=['InputFileCatalogURL', 'InputCollections', 'FirstEvent', 'MaxEvents', 'TFileAdaptor']
|
792 |
for line in inline:
|
793 |
word = string.strip(string.split(line,'=')[0])
|
794 |
|
795 |
if word not in wordRemove:
|
796 |
outfile.write(line)
|
797 |
else:
|
798 |
continue
|
799 |
pass
|
800 |
|
801 |
outfile.write('\n\n##### The following cards have been created by CRAB: DO NOT TOUCH #####\n')
|
802 |
outfile.write('TFileAdaptor = true\n')
|
803 |
|
804 |
outfile.write('MonRecAlisaBuilder=false\n')
|
805 |
|
806 |
outfile.write('InputCollections=/System/'+self.owner+'/'+self.dataset+'/'+self.dataset+'\n')
|
807 |
|
808 |
infile.close()
|
809 |
outfile.close()
|
810 |
return
|
811 |
|
812 |
def modifySteeringCards(self, nj):
|
813 |
"""
|
814 |
Creates steering cards file modifying a template file
|
815 |
"""
|
816 |
return
|
817 |
|
818 |
def cardsBaseName(self):
|
819 |
"""
|
820 |
Returns name of user orcarc card-file
|
821 |
"""
|
822 |
return os.path.split (self.orcarc_file)[1]
|
823 |
|
824 |
### content of input_sanbdox ...
|
825 |
def inputSandbox(self, nj):
|
826 |
"""
|
827 |
Returns a list of filenames to be put in JDL input sandbox.
|
828 |
"""
|
829 |
inp_box = []
|
830 |
# dict added to delete duplicate from input sandbox file list
|
831 |
seen = {}
|
832 |
## code
|
833 |
if os.path.isfile(self.tgzNameWithPath):
|
834 |
inp_box.append(self.tgzNameWithPath)
|
835 |
|
836 |
##DBSDLS: no orcarc_CE and init_CE.sh produced on UI , thus not inserting them in inputSandbox
|
837 |
# ## orcarc
|
838 |
# for o in self.allOrcarcs:
|
839 |
# for f in o.fileList():
|
840 |
# if (f not in seen.keys()):
|
841 |
# inp_box.append(common.work_space.jobDir()+f)
|
842 |
# seen[f] = 1
|
843 |
|
844 |
## config
|
845 |
inp_box.append(common.job_list[nj].configFilename())
|
846 |
## additional input files
|
847 |
#inp_box = inp_box + self.additional_inbox_files
|
848 |
return inp_box
|
849 |
|
850 |
### and of output_sandbox
|
851 |
def outputSandbox(self, nj):
|
852 |
"""
|
853 |
Returns a list of filenames to be put in JDL output sandbox.
|
854 |
"""
|
855 |
out_box = []
|
856 |
|
857 |
stdout=common.job_list[nj].stdout()
|
858 |
stderr=common.job_list[nj].stderr()
|
859 |
#out_box.append(stdout)
|
860 |
#out_box.append(stderr)
|
861 |
|
862 |
## User Declared output files
|
863 |
for out in self.output_file:
|
864 |
n_out = nj + 1
|
865 |
#FEDE
|
866 |
#out_box.append(self.version+'/'+self.numberFile_(out,str(n_out)))
|
867 |
out_box.append(self.numberFile_(out,str(n_out)))
|
868 |
return out_box
|
869 |
|
870 |
def getRequirements(self, nj):
|
871 |
"""
|
872 |
return job requirements to add to jdl files
|
873 |
"""
|
874 |
req = ''
|
875 |
#if common.analisys_common_info['sites']:
|
876 |
if common.analisys_common_info['sw_version']:
|
877 |
req='Member("VO-cms-' + \
|
878 |
common.analisys_common_info['sw_version'] + \
|
879 |
'", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
|
880 |
|
881 |
sites = common.jobDB.destination(nj)
|
882 |
|
883 |
if len(sites)>0:
|
884 |
req = req + ' && ('
|
885 |
for site in sites:
|
886 |
req = req + 'other.GlueCEInfoHostName == "' + site + '" || '
|
887 |
pass
|
888 |
# remove last ||
|
889 |
req = req[0:-4]
|
890 |
req = req + ')'
|
891 |
#print "req = ", req
|
892 |
|
893 |
return req
|
894 |
|
895 |
def numberFile_(self, file, txt):
|
896 |
"""
|
897 |
append _'txt' before last extension of a file
|
898 |
"""
|
899 |
p = string.split(file,".")
|
900 |
# take away last extension
|
901 |
name = p[0]
|
902 |
for x in p[1:-1]:
|
903 |
name=name+"."+x
|
904 |
# add "_txt"
|
905 |
if len(p)>1:
|
906 |
ext = p[len(p)-1]
|
907 |
#result = name + '_' + str(txt) + "." + ext
|
908 |
result = name + '_' + txt + "." + ext
|
909 |
else:
|
910 |
#result = name + '_' + str(txt)
|
911 |
result = name + '_' + txt
|
912 |
|
913 |
return result
|
914 |
|
915 |
|
916 |
def stdOut(self):
|
917 |
return self.stdOut_
|
918 |
|
919 |
def stdErr(self):
|
920 |
return self.stdErr_
|
921 |
|
922 |
# marco
|
923 |
def setParam_(self, param, value):
|
924 |
self._params[param] = value
|
925 |
|
926 |
def getParams(self):
|
927 |
return self._params
|
928 |
|
929 |
def setTaskid_(self):
|
930 |
self._taskId = self.cfg_params['taskId']
|
931 |
|
932 |
def getTaskid(self):
|
933 |
return self._taskId
|
934 |
# marco
|
935 |
|
936 |
def configFilename(self):
|
937 |
""" return the config filename """
|
938 |
return self.name()+'.orcarc'
|
939 |
|
940 |
### OLI_DANIELE
|
941 |
def wsSetupCMSOSGEnvironment_(self):
|
942 |
"""
|
943 |
Returns part of a job script which is prepares
|
944 |
the execution environment and which is common for all CMS jobs.
|
945 |
"""
|
946 |
txt = '\n'
|
947 |
txt += ' echo "### SETUP CMS OSG ENVIRONMENT ###"\n'
|
948 |
txt += ' if [ -f $GRID3_APP_DIR/cmssoft/cmsset_default.sh ] ;then\n'
|
949 |
txt += ' # Use $GRID3_APP_DIR/cmssoft/cmsset_default.sh to setup cms software\n'
|
950 |
txt += ' source $GRID3_APP_DIR/cmssoft/cmsset_default.sh '+self.version+'\n'
|
951 |
txt += ' elif [ -f $OSG_APP/cmssoft/cmsset_default.sh ] ;then\n'
|
952 |
txt += ' # Use $OSG_APP/cmssoft/cmsset_default.sh to setup cms software\n'
|
953 |
txt += ' source $OSG_APP/cmssoft/cmsset_default.sh '+self.version+'\n'
|
954 |
txt += ' else\n'
|
955 |
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'
|
956 |
txt += ' echo "JOB_EXIT_STATUS = 10020"\n'
|
957 |
txt += ' echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
|
958 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
959 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
960 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
961 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
962 |
txt += ' exit 1\n'
|
963 |
txt += '\n'
|
964 |
txt += ' echo "Remove working directory: $WORKING_DIR"\n'
|
965 |
txt += ' cd $RUNTIME_AREA\n'
|
966 |
txt += ' /bin/rm -rf $WORKING_DIR\n'
|
967 |
txt += ' if [ -d $WORKING_DIR ] ;then\n'
|
968 |
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'
|
969 |
txt += ' echo "JOB_EXIT_STATUS = 10017"\n'
|
970 |
txt += ' echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
|
971 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
972 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
973 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
974 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
975 |
txt += ' fi\n'
|
976 |
txt += '\n'
|
977 |
txt += ' exit 1\n'
|
978 |
txt += ' fi\n'
|
979 |
txt += '\n'
|
980 |
txt += ' echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
|
981 |
txt += ' echo " END SETUP CMS OSG ENVIRONMENT "\n'
|
982 |
|
983 |
return txt
|
984 |
|
985 |
### OLI_DANIELE
|
986 |
def wsSetupCMSLCGEnvironment_(self):
|
987 |
"""
|
988 |
Returns part of a job script which is prepares
|
989 |
the execution environment and which is common for all CMS jobs.
|
990 |
"""
|
991 |
txt = ' \n'
|
992 |
txt += ' echo " ### SETUP CMS LCG ENVIRONMENT ### "\n'
|
993 |
txt += ' if [ ! $VO_CMS_SW_DIR ] ;then\n'
|
994 |
txt += ' echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n'
|
995 |
txt += ' echo "JOB_EXIT_STATUS = 10031" \n'
|
996 |
txt += ' echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n'
|
997 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
998 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
999 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
1000 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
1001 |
txt += ' exit 1\n'
|
1002 |
txt += ' else\n'
|
1003 |
txt += ' echo "Sourcing environment... "\n'
|
1004 |
txt += ' if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n'
|
1005 |
txt += ' echo "SET_CMS_ENV 10020 ==> ERROR cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
|
1006 |
txt += ' echo "JOB_EXIT_STATUS = 10020"\n'
|
1007 |
txt += ' echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
|
1008 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
1009 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
1010 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
1011 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
1012 |
txt += ' exit 1\n'
|
1013 |
txt += ' fi\n'
|
1014 |
txt += ' echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
|
1015 |
txt += ' source $VO_CMS_SW_DIR/cmsset_default.sh\n'
|
1016 |
txt += ' result=$?\n'
|
1017 |
txt += ' if [ $result -ne 0 ]; then\n'
|
1018 |
txt += ' echo "SET_CMS_ENV 10032 ==> ERROR problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
|
1019 |
txt += ' echo "JOB_EXIT_STATUS = 10032"\n'
|
1020 |
txt += ' echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n'
|
1021 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
1022 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
1023 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
1024 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
1025 |
txt += ' exit 1\n'
|
1026 |
txt += ' fi\n'
|
1027 |
txt += ' fi\n'
|
1028 |
txt += ' \n'
|
1029 |
txt += ' string=`cat /etc/redhat-release`\n'
|
1030 |
txt += ' echo $string\n'
|
1031 |
txt += ' if [[ $string = *alhalla* ]]; then\n'
|
1032 |
txt += ' echo "SCRAM_ARCH= $SCRAM_ARCH"\n'
|
1033 |
txt += ' elif [[ $string = *Enterprise* ]] || [[ $string = *cientific* ]]; then\n'
|
1034 |
txt += ' export SCRAM_ARCH=slc3_ia32_gcc323\n'
|
1035 |
txt += ' echo "SCRAM_ARCH= $SCRAM_ARCH"\n'
|
1036 |
txt += ' else\n'
|
1037 |
txt += ' echo "SET_CMS_ENV 10033 ==> ERROR OS unknown, LCG environment not initialized"\n'
|
1038 |
txt += ' echo "JOB_EXIT_STATUS = 10033"\n'
|
1039 |
txt += ' echo "JobExitCode=10033" | tee -a $RUNTIME_AREA/$repo\n'
|
1040 |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
1041 |
txt += ' rm -f $RUNTIME_AREA/$repo \n'
|
1042 |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
|
1043 |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
|
1044 |
txt += ' exit 1\n'
|
1045 |
txt += ' fi\n'
|
1046 |
txt += ' echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
|
1047 |
txt += ' echo "### END SETUP CMS LCG ENVIRONMENT ###"\n'
|
1048 |
return txt
|
1049 |
|