119 |
|
#=================================================================================================== |
120 |
|
# Define string to explain usage of the script |
121 |
|
usage = \ |
122 |
< |
"\nUsage: jobSitter.py [ --pattern= --blacklist=" + \ |
123 |
< |
" --status --help --backward --clean --extend --one --exe ]\n" |
122 |
> |
"\nUsage: jobSitter.py [ --pattern= --apattern= --blacklist=" \ |
123 |
> |
+ " --status --kill --remove --help --backward --clean --extend --one" \ |
124 |
> |
+ " --exe ]\n" |
125 |
|
|
126 |
|
# Define the valid options which can be specified and check out the command line |
127 |
< |
valid = ['pattern=','blacklist=','catalog=','help','backward','kill','clean','exe','extend','one'] |
127 |
> |
valid = ['pattern=','apattern=','blacklist=','catalog=', |
128 |
> |
'help','backward','kill','remove','clean','exe','extend','one'] |
129 |
|
try: |
130 |
|
opts, args = getopt.getopt(sys.argv[1:], "", valid) |
131 |
|
except getopt.GetoptError, ex: |
138 |
|
# -------------------------------------------------------------------------------------------------- |
139 |
|
# Set defaults |
140 |
|
pattern = '' |
141 |
+ |
apattern = '' |
142 |
|
blacklist = '' |
143 |
|
catalog = 0 |
144 |
|
clean = 0 |
145 |
|
kill = 0 |
146 |
+ |
remove = 0 |
147 |
|
exe = 0 |
148 |
|
extend = 0 |
149 |
|
one = 0 |
156 |
|
sys.exit(0) |
157 |
|
if opt == "--pattern": |
158 |
|
pattern = arg |
159 |
+ |
if opt == "--apattern": |
160 |
+ |
apattern = arg |
161 |
|
if opt == "--blacklist": |
162 |
|
blacklist = arg |
163 |
|
if opt == "--catalog": |
174 |
|
backward = ' -r ' |
175 |
|
if opt == "--kill": |
176 |
|
kill = 1 |
177 |
+ |
if opt == "--remove": |
178 |
+ |
remove = 1 |
179 |
|
|
180 |
|
# -------------------------------------------------------------------------------------------------- |
181 |
|
# Here is where the real action starts ------------------------------------------------------------- |
196 |
|
crabTask = task.Task(tag) |
197 |
|
|
198 |
|
#print 'Pattern: ' + pattern + ' tag: ' + crabTask.mitDataset |
199 |
+ |
if apattern != '' and re.search(apattern,crabTask.mitDataset): |
200 |
+ |
print '\n Skipping: ' + crabTask.mitDataset + '\n\n' |
201 |
|
if re.search(pattern,crabTask.mitDataset): |
202 |
|
crabTasks.append(crabTask) |
203 |
|
crabTask.show() |
207 |
|
|
208 |
|
# Process the crab tasks determined to be relevant in the last query |
209 |
|
print '\n==============================================================================' |
210 |
< |
print ' Process crab task list (please wait, crab commands are first fully parsed)\n' |
210 |
> |
print ' Process crab task list\n' |
211 |
|
i = 0 |
212 |
|
for crabTask in crabTasks: |
213 |
|
|
214 |
+ |
print '\n------------------------------------------------------------------------------' |
215 |
+ |
print ' --> PREPPING ' + crabTask.tag \ |
216 |
+ |
+ '\n -> ' + crabTask.mitDataset |
217 |
+ |
print '------------------------------------------------------------------------------\n' |
218 |
+ |
|
219 |
|
dataset = crabTask.cmsDataset |
220 |
|
storageEle = crabTask.storageEle |
221 |
|
storagePath = crabTask.storagePath |
224 |
|
crabTask.killAndRemove(1) |
225 |
|
continue |
226 |
|
|
227 |
+ |
if remove == 1: |
228 |
+ |
crabTask.remove(1) |
229 |
+ |
continue |
230 |
+ |
|
231 |
|
crabTask.loadAllLfns(crabTask.mitCfg + '/' + crabTask.mitVersion + '/' + \ |
232 |
|
crabTask.mitDataset + '.lfns') |
233 |
|
#if crabTask.status == 'cataloged': |
255 |
|
if catalog == 7: |
256 |
|
cmd = 'catalog.sh -g -m ' + crabTask.mitCfg + ' ' + crabTask.mitVersion + \ |
257 |
|
' ' + crabTask.mitDataset + '/' + crabTask.tag + ' --compact' |
258 |
< |
print ' CATALOG: ' + cmd |
258 |
> |
|
259 |
> |
|
260 |
> |
print '\n------------------------------------------------------------------------------' |
261 |
> |
print ' --> CATALOG ' + crabTask.tag \ |
262 |
> |
+ '\n -> ' + dataset + ' (' + crabTask.mitDataset + ')'\ |
263 |
> |
+ '\n -> ' + storageEle \ |
264 |
> |
+ '\n -> ' + storagePath |
265 |
> |
print '------------------------------------------------------------------------------\n' |
266 |
> |
#print ' --> ' + cmd |
267 |
> |
|
268 |
|
if catalog != 0: |
269 |
|
os.system(cmd) |
270 |
|
|
274 |
|
|
275 |
|
# do we need to extend the task |
276 |
|
if extend == 1: |
277 |
+ |
cmd = 'crab -extend -c ' + crabTask.tag |
278 |
|
print '\n------------------------------------------------------------------------------' |
279 |
< |
print ' --> EXTEND ' + crabTask.tag + ' -- wait crab commands first fully parsed -- ' \ |
279 |
> |
print ' --> EXTEND ' + crabTask.tag + ' -- ' \ |
280 |
|
+ '\n -> ' + dataset + ' (' + crabTask.mitDataset + ')'\ |
281 |
|
+ '\n -> ' + storageEle \ |
282 |
|
+ '\n -> ' + storagePath |
283 |
|
print '------------------------------------------------------------------------------\n' |
284 |
< |
cmd = 'crab -extend -c ' + crabTask.tag |
284 |
> |
print ' --> ' + cmd |
285 |
|
os.system(cmd) |
286 |
|
|
287 |
|
print '\n------------------------------------------------------------------------------' |
288 |
< |
print ' --> STATUS ' + crabTask.tag + ' -- wait crab commands first fully parsed -- ' \ |
288 |
> |
print ' --> STATUS ' + crabTask.tag + ' -- ' \ |
289 |
|
+ '\n -> ' + dataset + ' (' + crabTask.mitDataset + ')'\ |
290 |
|
+ '\n -> ' + storageEle \ |
291 |
|
+ '\n -> ' + storagePath |
302 |
|
print ' Task status: ' + crabTask.status |
303 |
|
if crabTask.status == 'completed' or crabTask.status == 'finished': |
304 |
|
crabTask.remove(clean) |
305 |
+ |
print ' INFO - crab task has been removed, continuing.\n' |
306 |
+ |
continue |
307 |
|
print ' ' |
308 |
|
|
309 |
|
# review failing sites |
334 |
|
subList += '%d'%(status.index) |
335 |
|
else: |
336 |
|
subList += ',%d'%(status.index) |
337 |
< |
if ((status.tag == 'Aborted' or status.exitCode > 0 or status.exitStatus > 0) or |
338 |
< |
(status.tag == 'Retrieved' and status.outputFile == 0)): |
337 |
> |
if ((status.tag == 'Aborted' or status.exitCode > 0 or status.exitStatus > 0)): |
338 |
> |
##or(status.tag == 'Retrieved' and status.outputFile == 0)): |
339 |
|
status.showCompact() |
340 |
|
if resubList == '': |
341 |
|
resubList += '%d'%(status.index) |
349 |
|
if not re.search('-',subList) and not re.search(',',subList): |
350 |
|
subList = subList + ',999999999' |
351 |
|
cmd = 'crab -c ' + crabTask.tag + ' -submit ' + subList |
352 |
< |
print '\nACTION -- SUBMIT.PY: ' + cmd |
353 |
< |
if exe == 1: |
354 |
< |
status = os.system(cmd) |
352 |
> |
##print '\nACTION -- SUBMIT.PY: ' + cmd |
353 |
> |
##if exe == 1: |
354 |
> |
## status = os.system(cmd) |
355 |
|
if resubList != '': |
356 |
|
cmd = 'crab -c ' + crabTask.tag + ' -resubmit ' + resubList |
357 |
< |
print '\nACTION -- RE-SUBMIT.PY: ' + cmd |
358 |
< |
if exe == 1: |
359 |
< |
status = os.system(cmd) |
357 |
> |
##print '\nACTION -- RE-SUBMIT.PY: ' + cmd |
358 |
> |
##if exe == 1: |
359 |
> |
## status = os.system(cmd) |
360 |
|
|
361 |
|
|
362 |
+ |
cmd = 'crab -getoutput -continue ' + crabTask.tag |
363 |
|
print '\n------------------------------------------------------------------------------' |
364 |
< |
print ' --> GETOUTPUT ' + crabTask.tag + ' -- wait crab commands first fully parsed -- ' \ |
364 |
> |
print ' --> GETOUTPUT ' + crabTask.tag + ' -- ' \ |
365 |
|
+ '\n -> ' + dataset \ |
366 |
|
+ '\n -> ' + storageEle \ |
367 |
|
+ '\n -> ' + storagePath |
368 |
|
print '------------------------------------------------------------------------------\n' |
369 |
< |
|
338 |
< |
cmd = 'crab -getoutput -continue ' + crabTask.tag |
369 |
> |
print ' --> ' + cmd |
370 |
|
status = os.system(cmd) |
371 |
|
|
372 |
|
cmd = 'cleanupLog.py --crabId ' + crabTask.tag |