From 69ca24f67d4b4e6289398df01b1fdc12209f0dc7 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 27 Oct 2023 10:02:39 +0200 Subject: [PATCH] Skip state filering in __MERGE_COLLECTION__ tool Fixes inputs getting skipped that are NEW, QUEUED, etc. If you're after filtering out errored you should use the `__FILTER_FAILED_DATASETS__` tool. --- lib/galaxy/tools/__init__.py | 51 ++++++++++----------------- lib/galaxy_test/api/test_workflows.py | 41 +++++++++++++++++++++ 2 files changed, 60 insertions(+), 32 deletions(-) diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index 5a92fd960e4b..98abc079e416 100644 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -3376,40 +3376,27 @@ def produce_outputs(self, trans, out_data, output_collections, incoming, history for copy, input_list in enumerate(input_lists): for dce in input_list.collection.elements: element = dce.element_object - valid = False - - # dealing with a single element - if hasattr(element, "is_ok"): - if element.is_ok: - valid = True - elif hasattr(element, "dataset_instances"): - # we are probably a list:paired dataset, both need to be in non error state - forward_o, reverse_o = element.dataset_instances - if forward_o.is_ok and reverse_o.is_ok: - valid = True + element_identifier = dce.element_identifier + identifier_seen = element_identifier in new_element_structure + appearances = identifiers_map[element_identifier] + add_suffix = False + if dupl_actions == "suffix_every": + add_suffix = True + elif dupl_actions == "suffix_conflict" and len(appearances) > 1: + add_suffix = True + elif dupl_actions == "suffix_conflict_rest" and len(appearances) > 1 and appearances[0] != copy: + add_suffix = True + + if dupl_actions == "keep_first" and identifier_seen: + continue - if valid: - element_identifier = dce.element_identifier - identifier_seen = element_identifier in new_element_structure - appearances = identifiers_map[element_identifier] - add_suffix = False - if dupl_actions == "suffix_every": - add_suffix = True - elif dupl_actions == "suffix_conflict" and len(appearances) > 1: - add_suffix = True - elif dupl_actions == "suffix_conflict_rest" and len(appearances) > 1 and appearances[0] != copy: - add_suffix = True - - if dupl_actions == "keep_first" and identifier_seen: - continue - - if add_suffix and suffix_pattern: - suffix = suffix_pattern.replace("#", str(copy + 1)) - effective_identifer = f"{element_identifier}{suffix}" - else: - effective_identifer = element_identifier + if add_suffix and suffix_pattern: + suffix = suffix_pattern.replace("#", str(copy + 1)) + effective_identifer = f"{element_identifier}{suffix}" + else: + effective_identifer = element_identifier - new_element_structure[effective_identifer] = element + new_element_structure[effective_identifer] = element # Don't copy until we know everything is fine and we have the structure of the list ready to go. new_elements = {} diff --git a/lib/galaxy_test/api/test_workflows.py b/lib/galaxy_test/api/test_workflows.py index 393546d95ec6..6de9b4f7d79b 100644 --- a/lib/galaxy_test/api/test_workflows.py +++ b/lib/galaxy_test/api/test_workflows.py @@ -2976,6 +2976,47 @@ def test_export_invocation_ro_crate(self): workflow = crate.mainEntity assert workflow + @skip_without_tool("__MERGE_COLLECTION__") + def test_merge_collection_scheduling(self, history_id): + summary = self._run_workflow( + """ +class: GalaxyWorkflow +inputs: + collection: + type: collection + collection_type: list +outputs: + merge_out: + outputSource: merge/output +steps: + sleep: + tool_id: cat_data_and_sleep + in: + input1: collection + state: + sleep_time: 5 + merge: + tool_id: __MERGE_COLLECTION__ + in: + inputs_1|input: sleep/out_file1 + inputs_0|input: sleep/out_file1 +test_data: + collection: + collection_type: list + elements: + - identifier: 1 + content: A +""", + history_id=history_id, + wait=True, + assert_ok=True, + ) + invocation = self.workflow_populator.get_invocation(summary.invocation_id, step_details=True) + merge_out_id = invocation["output_collections"]["merge_out"]["id"] + merge_out = self.dataset_populator.get_history_collection_details(history_id, content_id=merge_out_id) + assert merge_out["element_count"] == 1 + assert merge_out["elements"][0]["object"]["state"] == "ok" + @skip_without_tool("__MERGE_COLLECTION__") @skip_without_tool("cat_collection") @skip_without_tool("head")