From 49a1be4f1de3cfe48bbfd0b709bc8a158f7d36e6 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 31 May 2018 11:45:44 +0200 Subject: [PATCH 1/3] Allow from_param to reference a child collection This is necessary when mapping over a collection over an input that is referenced in the output section, like so: ``` ... ... ``` --- lib/galaxy/tools/parser/output_actions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/tools/parser/output_actions.py b/lib/galaxy/tools/parser/output_actions.py index 35798452b5a..475eecebdd2 100644 --- a/lib/galaxy/tools/parser/output_actions.py +++ b/lib/galaxy/tools/parser/output_actions.py @@ -243,7 +243,10 @@ class FromParamToolOutputActionOption(ToolOutputActionOption): # if this is an HDCA for instance let reverse.ext grab # the reverse element and then continue for loop to grab # dataset extension - value = value.collection[attr_name].element_object + try: + value = value.collection[attr_name].element_object + except KeyError: + value = value.child_collection[attr_name].element_object elif hasattr(value, "collection") and value in COLLECTION_ATTRIBUTES: value = getattr(value.collection, attr_name) else: From bc8254faecf9b9f9bbd000d9ba7601ce9fe472a5 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 31 May 2018 11:49:49 +0200 Subject: [PATCH 2/3] Do not adapt target collection to child collection type Otherwise mapping over list:list:pair to a pair input breaks at https://github.com/galaxyproject/galaxy/blob/21b44bf348ae10d170ab96a3b6f30bf9dbbd5a4a/lib/galaxy/dataset_collections/subcollections.py#L12. This and the previous commit should fix https://github.com/galaxyproject/tools-iuc/issues/1563. --- lib/galaxy/dataset_collections/subcollections.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/dataset_collections/subcollections.py b/lib/galaxy/dataset_collections/subcollections.py index 3a536a34da4..99bd289e28b 100644 --- a/lib/galaxy/dataset_collections/subcollections.py +++ b/lib/galaxy/dataset_collections/subcollections.py @@ -20,6 +20,6 @@ def _split_dataset_collection(dataset_collection, collection_type): if child_collection.collection_type == collection_type: split_elements.append(element) else: - split_elements.extend(_split_dataset_collection(element.child_collection, element.child_collection.collection_type)) + split_elements.extend(_split_dataset_collection(element.child_collection, collection_type)) return split_elements From 3e22b0b11b600a4e957557d3cece03665bdc7de5 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 31 May 2018 13:37:42 +0200 Subject: [PATCH 3/3] Test case for mapping over inputs with output ftype determined via input extension --- test/api/test_tools.py | 17 ++++++++++ .../output_action_change_format_paired.xml | 32 +++++++++++++++++++ test/functional/tools/samples_tool_conf.xml | 1 + 3 files changed, 50 insertions(+) create mode 100644 test/functional/tools/output_action_change_format_paired.xml diff --git a/test/api/test_tools.py b/test/api/test_tools.py index e18965d69b0..432debda4d6 100644 --- a/test/api/test_tools.py +++ b/test/api/test_tools.py @@ -736,6 +736,23 @@ class ToolsTestCase(api.ApiTestCase): assert output1_details["file_ext"] == "txt" if (use_action == "do") else "data" assert output2_details["file_ext"] == "txt" if (use_action == "do") else "data" + @skip_without_tool("output_action_change_format_paired") + def test_map_over_with_nested_paired_output_format_actions(self): + history_id = self.dataset_populator.new_history() + hdca_id = self.__build_nested_list(history_id) + inputs = { + "input": {'batch': True, 'values': [dict(map_over_type='paired', src="hdca", id=hdca_id)]} + } + create = self._run('output_action_change_format_paired', history_id, inputs).json() + outputs = create['outputs'] + jobs = create['jobs'] + implicit_collections = create['implicit_collections'] + self.assertEquals(len(jobs), 2) + self.assertEquals(len(outputs), 2) + self.assertEquals(len(implicit_collections), 1) + for output in outputs: + assert output["file_ext"] == "txt" + @skip_without_tool("output_filter_with_input") def test_map_over_with_output_filter_no_filtering(self): with self.dataset_populator.test_history() as history_id: diff --git a/test/functional/tools/output_action_change_format_paired.xml b/test/functional/tools/output_action_change_format_paired.xml new file mode 100644 index 00000000000..7c31145f063 --- /dev/null +++ b/test/functional/tools/output_action_change_format_paired.xml @@ -0,0 +1,32 @@ + + + printf "1\t2\n" > out1; + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/functional/tools/samples_tool_conf.xml b/test/functional/tools/samples_tool_conf.xml index cb8e49d5f46..fa7179cb073 100644 --- a/test/functional/tools/samples_tool_conf.xml +++ b/test/functional/tools/samples_tool_conf.xml @@ -106,6 +106,7 @@ +