diff --git a/law/contrib/cms/job.py b/law/contrib/cms/job.py index 1805f086..787e2fd7 100644 --- a/law/contrib/cms/job.py +++ b/law/contrib/cms/job.py @@ -466,24 +466,36 @@ def extra( extra["tracking_url"] = monitoring_url return extra - # in case scheduler status or the json line is missing, the submission could be too new + # in case scheduler status or the json line is missing, the submission could be too new or + # it failed entirely if not scheduler_status or not json_line: - accepted_server_states = [ + pending_server_states = { "HOLDING on command SUBMIT", "NEW on command SUBMIT", "QUEUED on command SUBMIT", "WAITING on command SUBMIT", "SUBMITTED", - ] - if server_status not in accepted_server_states: - s = ",".join(map("'{}'".format, accepted_server_states)) + } + failed_server_states = {"SUBMITFAILED"} + error = None + if server_status in pending_server_states: + status = cls.PENDING + elif server_status in failed_server_states: + status = cls.FAILED + error = "submission failed" + else: + s = ",".join(map("'{}'".format, pending_server_states | failed_server_states)) raise Exception( "no per-job information available (yet?), which is only accepted if the crab " f"server status is any of {s}, but got '{server_status}'", ) - # interpret all jobs as pending return { - job_id: cls.job_status_dict(job_id=job_id, status=cls.PENDING, extra=extra(job_id)) + job_id: cls.job_status_dict( + job_id=job_id, + status=status, + error=error, + extra=extra(job_id), + ) for job_id in job_ids }