diff --git a/task-runner/task_runner/task_request_handler.py b/task-runner/task_runner/task_request_handler.py index d5d7c049..0a55b799 100644 --- a/task-runner/task_runner/task_request_handler.py +++ b/task-runner/task_runner/task_request_handler.py @@ -200,9 +200,9 @@ def save_output( ) -> bool: output_size_bytes = self._pack_output(output_filename=output_filename) - if output_size_bytes == 0: - return False - + # NOTE: This event is published even if the output size is 0, to + # inform the BE that the task has finished. The TaskOutputUploadFailed + # event is only published if an exception occurs during upload. self._publish_event( events.TaskOutputUploaded( id=self.task_id, @@ -212,6 +212,9 @@ def save_output( force=force, ) + if output_size_bytes == 0: + return False + # Remove the request JSON file to prevent multiple uploads # after a successful task data upload if os.path.exists(self.request_path):