Skip to content

Commit

Permalink
feat: dia-862: support for cancel model run (#117)
Browse files Browse the repository at this point in the history
Co-authored-by: Forum Gala <[email protected]>
Co-authored-by: Matt Bernstein <[email protected]>
  • Loading branch information
3 people authored Jun 3, 2024
1 parent e33537e commit 29db35e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,23 @@ def cancel_job(job_id):
Returns:
JobStatusResponse[status.CANCELED]
"""
job = process_file.AsyncResult(job_id)
job = streaming_parent_task.AsyncResult(job_id)
input_job_id = job.info.get("input_job_id", None)
output_job_id = job.info.get("output_job_id", None)
if input_job_id:
input_job = process_file_streaming.AsyncResult(input_job_id)
input_job.revoke()
else:
logger.debug(
f"Input job id: {input_job_id} unavailable to cancel for parent job: {job_id}"
)
if output_job_id:
output_job = process_streaming_output.AsyncResult(output_job_id)
output_job.revoke()
else:
logger.debug(
f"output job id: {input_job_id} unavailable to cancel for parent job: {job_id}"
)
job.revoke()
return Response[JobStatusResponse](data=JobStatusResponse(status=Status.CANCELED))

Expand Down

0 comments on commit 29db35e

Please sign in to comment.