Skip to content

Commit

Permalink
add 404 error handling to get_job_status
Browse files Browse the repository at this point in the history
  • Loading branch information
mbthornton-lbl committed Nov 26, 2024
1 parent c7797a4 commit 93a4456
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nmdc_automation/workflow_automation/watch_nmdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,10 @@ def cycle(self):
logger.info(f"Found {len(unclaimed_jobs)} unclaimed jobs.")
self.claim_jobs(unclaimed_jobs)


logger.info(f"Checking for finished jobs.")
successful_jobs, failed_jobs = self.job_manager.get_finished_jobs()
logger.debug(f"Found {len(successful_jobs)} successful jobs and {len(failed_jobs)} failed jobs.")
for job in successful_jobs:
job_database = self.job_manager.process_successful_job(job)
# sanity checks
Expand Down
12 changes: 12 additions & 0 deletions nmdc_automation/workflow_automation/wfutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,18 @@ def get_job_status(self) -> str:
if not self.job_id:
return "Unknown"
status_url = f"{self.service_url}/{self.job_id}/status"
# There can be a delay between submitting a job and it
# being available in Cromwell so handle 404 errors
try:
response = requests.get(status_url)
response.raise_for_status()
return response.json().get("status", "Unknown")
except requests.exceptions.HTTPError as e:
if e.response.status_code == 404:
return "Unknown"
raise e


response = requests.get(status_url)
response.raise_for_status()
return response.json().get("status", "Unknown")
Expand Down

0 comments on commit 93a4456

Please sign in to comment.