Merge pull request #22801 from bernt-matthias/on_string_fix

[26.1] Fix on_string containing redundant datasets
This commit is contained in:
Marius van den Beek
2026-06-11 09:27:23 +02:00
committed by GitHub
2 changed files with 37 additions and 0 deletions
+4
View File
@@ -941,8 +941,12 @@ class DefaultToolAction(ToolAction):
for input_name in inp_data:
data = inp_data[input_name]
# Skip collection inputs and any suffixed dataset names derived from them (e.g., "datasets1", "datasets2")
if input_name in inp_dataset_collections:
continue
# Also skip if the name starts with a collection input key and the remainder is a numeric suffix
if any(input_name.startswith(key) and input_name[len(key) :].isdigit() for key in inp_dataset_collections):
continue
if getattr(data, "hid", None):
input_hids.append(data.hid)
return on_text_for_dataset_and_collections(dataset_hids=input_hids, collection_hids=collection_hids)
+33
View File
@@ -51,6 +51,18 @@ TWO_OUTPUTS = """<tool id="test_tool" name="Test Tool">
</tool>
"""
# Tool with a multiple="true" data parameter – used to test on_string handling for collections.
MULTIPLE_DATA_TOOL = """<tool id="test_tool" name="Test Tool" version="1.0" profile="26.1">
<command>cat "$param1" &lt; $out1</command>
<inputs>
<param type="data" format="tabular" name="param1" multiple="true" value="" />
</inputs>
<outputs>
<data name="out1" format="data" />
</outputs>
</tool>
"""
def test_on_text_for_numeric_ids():
def assert_on_text_is(expected, hids):
@@ -83,6 +95,27 @@ def test_on_text_for_dataset_and_collections():
class TestDefaultToolAction(TestCase, tools_support.UsesTools):
def test_on_text_multiple_true_collection(self):
# Create a collection with three datasets
hdca = model.HistoryDatasetCollectionAssociation()
hdca.id = 999
hdca.hid = 55
collection = model.DatasetCollection()
hdca.collection = collection
# add three datasets to the collection
hda1 = self.__add_dataset()
hda2 = self.__add_dataset()
hda3 = self.__add_dataset()
model.DatasetCollectionElement(collection=collection, element=hda1)
model.DatasetCollectionElement(collection=collection, element=hda2)
model.DatasetCollectionElement(collection=collection, element=hda3)
collection.collection_type = "list"
self.history.dataset_collections.append(hdca)
# incoming param with the collection
incoming = {"param1": hdca}
job, output = self._simple_execute(contents=MULTIPLE_DATA_TOOL, incoming=incoming)
assert output["out1"].name == f"Test Tool on collection {hdca.hid}"
def setUp(self):
self.setup_app()
history = model.History()