diff --git a/lib/galaxy/jobs/__init__.py b/lib/galaxy/jobs/__init__.py index bf0f8a422052..9040f24b6366 100644 --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -1696,7 +1696,13 @@ def fail(message=job.info, exception=None): else: # Prior to fail we need to set job.state job.set_state(final_job_state) - return self.fail(f"Job {job.id}'s output dataset(s) could not be read") + return fail(f"Job {job.id}'s output dataset(s) could not be read") + else: + # check existence of outputs (tools may delete outputs) + for dataset_path in self.get_output_fnames(): + if not os.path.exists(dataset_path.real_path): + job.set_state(final_job_state) + return fail(f"Job {job.id}'s output dataset(s) could not be read") job_context = ExpressionContext(dict(stdout=job.stdout, stderr=job.stderr)) if extended_metadata: @@ -2005,6 +2011,8 @@ def compute_outputs(self): results = [] for da in job.output_datasets + job.output_library_datasets: + if da.purged: + continue da_false_path = dataset_path_rewriter.rewrite_dataset_path(da.dataset, 'output') mutable = da.dataset.dataset.external_filename is None dataset_path = DatasetPath(da.dataset.dataset.id, da.dataset.file_name, false_path=da_false_path, mutable=mutable) diff --git a/lib/galaxy/metadata/set_metadata.py b/lib/galaxy/metadata/set_metadata.py index 87ad6c7fe890..787cc75191c0 100644 --- a/lib/galaxy/metadata/set_metadata.py +++ b/lib/galaxy/metadata/set_metadata.py @@ -273,7 +273,7 @@ def set_meta(new_dataset_instance, file_dict): external_filename = unnamed_id_to_path.get(dataset_instance_id, dataset_filename_override) if not os.path.exists(external_filename): matches = glob.glob(external_filename) - assert len(matches) == 1, f"More than one file matched by output glob '{external_filename}'" + assert len(matches) == 1, f"{len(matches)} file matched by output glob '{external_filename}', should be 1" external_filename = matches[0] assert safe_contains(tool_job_working_directory, external_filename), f"Cannot collect output '{external_filename}' from outside of working directory" created_from_basename = os.path.relpath(external_filename, os.path.join(tool_job_working_directory, 'working')) diff --git a/test/functional/tools/samples_tool_conf.xml b/test/functional/tools/samples_tool_conf.xml index 8eeb4238f5e1..d5c61cd59d13 100644 --- a/test/functional/tools/samples_tool_conf.xml +++ b/test/functional/tools/samples_tool_conf.xml @@ -214,6 +214,8 @@ + + diff --git a/test/functional/tools/tool_deleting_output.xml b/test/functional/tools/tool_deleting_output.xml new file mode 100644 index 000000000000..4dd8cc47971e --- /dev/null +++ b/test/functional/tools/tool_deleting_output.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + diff --git a/test/integration/test_job_outputs_to_working_directory.py b/test/integration/test_job_outputs_to_working_directory.py index 7e9cbeb063e0..007b65ce73e3 100644 --- a/test/integration/test_job_outputs_to_working_directory.py +++ b/test/integration/test_job_outputs_to_working_directory.py @@ -15,4 +15,4 @@ def handle_galaxy_config_kwds(cls, config): instance = integration_util.integration_module_instance(JobOutputsToWorkingDirectoryIntegrationInstance) -test_tools = integration_util.integration_tool_runner(["output_format", "output_empty_work_dir", "collection_creates_pair_from_work_dir"]) +test_tools = integration_util.integration_tool_runner(["output_format", "output_empty_work_dir", "collection_creates_pair_from_work_dir", "tool_deleting_output"])