Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[24.1] Determine expression tool output extension when input terminal #19364

Draft
wants to merge 2 commits into
base: release_24.1
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions lib/galaxy/tools/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
AuthenticationRequired,
ItemAccessibilityException,
RequestParameterInvalidException,
ToolInputsNotReadyException,
)
from galaxy.job_execution.actions.post import ActionBox
from galaxy.managers.context import ProvidesHistoryContext
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -1231,6 +1240,8 @@ def determine_output_format(
break
input_dataset = input_element.element_object
ext = get_ext_or_implicit_ext(input_dataset)
except ToolInputsNotReadyException:
raise
except Exception as e:
log.debug("Exception while trying to determine format_source: %s", e)

Expand Down
32 changes: 32 additions & 0 deletions lib/galaxy_test/api/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -2157,6 +2157,38 @@ def test_run_workflow_pick_value_bam_pja(self):
assert dataset_details["metadata_bam_index"]
assert dataset_details["file_ext"] == "bam"

def test_expression_tool_output_in_format_source(self):
with self.dataset_populator.test_history() as history_id:
self._run_workflow(
"""class: GalaxyWorkflow
inputs:
input:
type: data
steps:
skip:
tool_id: cat_data_and_sleep
in:
input1: input
when: $(false)
pick_larger:
tool_id: expression_pick_larger_file
in:
input1: skip/out_file1
input2: input
format_source:
tool_id: cat_data_and_sleep
in:
input1: pick_larger/larger_file
test_data:
input:
value: 1.fastqsanger.gz
type: File
file_type: fastqsanger.gz
""",
history_id=history_id,
)
self.dataset_populator.wait_for_history(history_id=history_id, assert_ok=True)

def test_run_workflow_simple_conditional_step(self):
with self.dataset_populator.test_history() as history_id:
summary = self._run_workflow(
Expand Down
2 changes: 1 addition & 1 deletion test/functional/tools/expression_pick_larger_file.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<param name="input2" type="data" optional="true" label="Second file" />
</inputs>
<outputs>
<output name="larger_file" type="data" from="output" />
<output name="larger_file" type="data" from="output" format_source="input1" />
</outputs>
<tests>
<test>
Expand Down
Loading