From f7ce1a5a3a067cd053e109fe1451c6208406f65c Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 20 Dec 2024 16:51:05 +0100 Subject: [PATCH] Delay job scheduling when tools consume expression tool output datasets to determine extension --- lib/galaxy/tools/actions/__init__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/tools/actions/__init__.py b/lib/galaxy/tools/actions/__init__.py index 31c7eb76526c..91bb60202d3d 100644 --- a/lib/galaxy/tools/actions/__init__.py +++ b/lib/galaxy/tools/actions/__init__.py @@ -22,6 +22,7 @@ AuthenticationRequired, ItemAccessibilityException, RequestParameterInvalidException, + ToolInputsNotReadyException, ) from galaxy.job_execution.actions.post import ActionBox from galaxy.managers.context import ProvidesHistoryContext @@ -1156,8 +1157,14 @@ def get_ext_or_implicit_ext(hda): # objects, and their type is the target_ext, so this should be correct even if there # are multiple ImplicitlyConvertedDatasetAssociation objects (meaning 2 datasets had been converted # to produce a dataset with the required datatype) - return hda.implicitly_converted_parent_datasets[0].type - return hda.ext + ext = hda.implicitly_converted_parent_datasets[0].type + else: + ext = hda.ext + if ext == "expression.json" and hda.dataset.state not in model.Dataset.terminal_states: + raise ToolInputsNotReadyException( + "Tool uses expression tool output to determine extension, can only succeed once input is terminal." + ) + return ext def determine_output_format( @@ -1192,6 +1199,8 @@ def determine_output_format( try: input_dataset = input_datasets[output.format_source] ext = get_ext_or_implicit_ext(input_dataset) + except ToolInputsNotReadyException: + raise except Exception: pass elif format_source is not None: