Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_job_status(self):
if not self._batch_job_id:
return JobStatus.aborted
try:
job_status = _batch_job_status_cache[self._batch_job_id]
except KeyError:
return JobStatus.aborted
if job_status in [HTCondorJobStatus.completed]:
return JobStatus.successful
elif job_status in [HTCondorJobStatus.idle, HTCondorJobStatus.running]:
return JobStatus.running
elif job_status in [HTCondorJobStatus.removed, HTCondorJobStatus.held, HTCondorJobStatus.failed]:
return JobStatus.aborted
else:
raise ValueError(f"Unknown HTCondor Job status: {job_status}")
def get_job_status(self):
if not self._batch_job_id:
return JobStatus.aborted
try:
job_status = _batch_job_status_cache[self._batch_job_id]
except KeyError:
return JobStatus.aborted
if job_status in [HTCondorJobStatus.completed]:
return JobStatus.successful
elif job_status in [HTCondorJobStatus.idle, HTCondorJobStatus.running]:
return JobStatus.running
elif job_status in [HTCondorJobStatus.removed, HTCondorJobStatus.held, HTCondorJobStatus.failed]:
return JobStatus.aborted
else:
raise ValueError(f"Unknown HTCondor Job status: {job_status}")
def get_job_status(self):
if not self._batch_job_id:
return JobStatus.aborted
try:
job_status = _batch_job_status_cache[self._batch_job_id]
except KeyError:
return JobStatus.aborted
if job_status in [HTCondorJobStatus.completed]:
return JobStatus.successful
elif job_status in [HTCondorJobStatus.idle, HTCondorJobStatus.running]:
return JobStatus.running
elif job_status in [HTCondorJobStatus.removed, HTCondorJobStatus.held, HTCondorJobStatus.failed]:
return JobStatus.aborted
else:
raise ValueError(f"Unknown HTCondor Job status: {job_status}")
def _fill_from_output(self, output):
output = output.decode()
seen_ids = set()
if not output:
return seen_ids
for status_dict in json.loads(output):
if status_dict["JobStatus"] == HTCondorJobStatus.completed and status_dict["ExitCode"]:
self[status_dict["ClusterId"]] = HTCondorJobStatus.failed
else:
self[status_dict["ClusterId"]] = status_dict["JobStatus"]
seen_ids.add(status_dict["ClusterId"])
return seen_ids