Skip to content

Commit a92ddcf

Browse files
committed
[cms] Improve crab job status parsing.
1 parent 0216445 commit a92ddcf

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

law/contrib/cms/job.py

+16-8
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def cancel(self, proj_dir, job_ids=None, proxy=None, instance=None, myproxy_user
261261
return {job_id: None for job_id in job_ids}
262262

263263
def cleanup(self, proj_dir, job_ids=None, proxy=None, instance=None, myproxy_username=None,
264-
silent=False):
264+
silent=False, _processes=None):
265265
if job_ids is None:
266266
job_ids = self._job_ids_from_proj_dir(proj_dir)
267267

@@ -363,24 +363,32 @@ def extra(job_id, job_data=None):
363363
extra["tracking_url"] = monitoring_url
364364
return extra
365365

366-
# in case scheduler status or the json line is missing, the submission could be too new
366+
# in case scheduler status or the json line is missing, the submission could be too new or
367+
# it failed entirely
367368
if not scheduler_status or not json_line:
368-
accepted_server_states = [
369+
pending_server_states = {
369370
"HOLDING on command SUBMIT",
370371
"NEW on command SUBMIT",
371372
"QUEUED on command SUBMIT",
372373
"WAITING on command SUBMIT",
373374
"SUBMITTED",
374-
]
375-
if server_status not in accepted_server_states:
376-
s = ",".join(map("'{}'".format, accepted_server_states))
375+
}
376+
failed_server_states = {"SUBMITFAILED"}
377+
error = None
378+
if server_status in pending_server_states:
379+
status = cls.PENDING
380+
elif server_status in failed_server_states:
381+
status = cls.FAILED
382+
error = "submission failed"
383+
else:
384+
s = ",".join(map("'{}'".format, pending_server_states | failed_server_states))
377385
raise Exception(
378386
"no per-job information available (yet?), which is only accepted if the crab " +
379387
"server status is any of {}, but got '{}'".format(s, server_status),
380388
)
381-
# interpret all jobs as pending
382389
return {
383-
job_id: cls.job_status_dict(job_id=job_id, status=cls.PENDING, extra=extra(job_id))
390+
job_id: cls.job_status_dict(job_id=job_id, status=status, error=error,
391+
extra=extra(job_id))
384392
for job_id in job_ids
385393
}
386394

law/contrib/cms/workflow.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,7 @@ def crab_output_directory(self):
240240

241241
def crab_request_name(self, submit_jobs):
242242
"""
243-
Returns a random name for a request, i.e., the project directory inside the crab job working
244-
area.
243+
Returns a name for a request, i.e., the project directory inside the crab job working area.
245244
"""
246245
return "{}_{}".format(self.live_task_id, str(uuid.uuid4())[:8])
247246

0 commit comments

Comments
 (0)