Skip to content

Commit

Permalink
Use default max time in badly formatted tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
snwessel committed Nov 26, 2024
1 parent 30498e6 commit c23114e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions portal-backend/depmap/celery_task/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,15 @@ def format_task_status(task):
percent_complete = task.result.get("percent_complete")
start_time = task.result.get("start_time")

# For some reason, max time is occasionally null in tasks originating from the
# compound page's Genomic Associations tab. For now, just use a default value instead of throwing an error.
max_time = task.result.get("max_time", 45)

if percent_complete is None and start_time is not None:
# if "start_time" is provided, compute a fake status bar
assert "max_time" in task.result
max_percent = 95
current_runtime = time.time() - task.result["start_time"]
percent_complete = (
min(current_runtime / task.result["max_time"], 1) * max_percent
)
percent_complete = min(current_runtime / max_time, 1) * max_percent

elif task.state == TaskState.SUCCESS.name:
# done, return the result payload
Expand Down

0 comments on commit c23114e

Please sign in to comment.