From 65e9605f4a4c77c5af2ab6d473a3a894eabb6bcb Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Sat, 8 Jun 2024 20:02:32 +0200 Subject: [PATCH] Don't fail _finish_or_resubmit if tool_stdout / tool_stderr not written These are only written if the command actually ran, so we'd fail here for instance if the outputs are deleted before the job had a chance to run. --- lib/galaxy/jobs/runners/__init__.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/jobs/runners/__init__.py b/lib/galaxy/jobs/runners/__init__.py index d15aa558648d..db1e1975f5e3 100644 --- a/lib/galaxy/jobs/runners/__init__.py +++ b/lib/galaxy/jobs/runners/__init__.py @@ -625,10 +625,23 @@ def _finish_or_resubmit_job(self, job_state: "JobState", job_stdout, job_stderr, tool_stdout_path = os.path.join(outputs_directory, "tool_stdout") tool_stderr_path = os.path.join(outputs_directory, "tool_stderr") - with open(tool_stdout_path, "rb") as stdout_file: - tool_stdout = self._job_io_for_db(stdout_file) - with open(tool_stderr_path, "rb") as stderr_file: - tool_stderr = self._job_io_for_db(stderr_file) + try: + with open(tool_stdout_path, "rb") as stdout_file: + tool_stdout = self._job_io_for_db(stdout_file) + with open(tool_stderr_path, "rb") as stderr_file: + tool_stderr = self._job_io_for_db(stderr_file) + except FileNotFoundError: + if job.state in (model.Job.states.DELETING, model.Job.states.DELETED): + # We killed the job, so we may not even have the tool stdout / tool stderr + tool_stdout = "" + tool_stderr = "Job cancelled" + else: + # Should we instead just move on ? + # In the end the only consequence here is that we won't be able to determine + # if the job failed for known tool reasons (check_tool_output). + # OTOH I don't know if this can even be reached + # Deal with it if we ever get reports about this. + raise check_output_detected_state = job_wrapper.check_tool_output( tool_stdout,