Fix do not set Aborted task if it is already set to Failed

This commit is contained in:
clearml 2025-06-22 22:39:55 +03:00
parent 3585786348
commit 4881b9638d

View File

@ -3485,16 +3485,24 @@ class Worker(ServiceCommandSection):
session = session or self._session
try:
if stop_reason == TaskStopReason.stopped:
self.log("Stopping - tasks.stop was called for task")
self.send_logs(task_id, ["Process aborted by user"], session=session)
session.send_api(
tasks_api.StoppedRequest(
task=task_id,
status_reason="task was stopped by tasks.stop",
status_message=self._task_status_change_message,
force=False
# do not change the status to stopped if the Task status is already failed
task_status = get_task(
session, task_id, only_fields=["status"]
).status
if str(task_status) == "failed":
self.send_logs(task_id, ["Process aborted by user - Task status was Failed"], session=session)
self.log("Stopping - task was already marked as failed")
else:
self.send_logs(task_id, ["Process aborted by user"], session=session)
self.log("Stopping - tasks.stop was called for task")
session.send_api(
tasks_api.StoppedRequest(
task=task_id,
status_reason="task was stopped by tasks.stop",
status_message=self._task_status_change_message,
force=False
)
)
)
elif stop_reason == TaskStopReason.status_changed:
try: