From dff6307e91c68550be97c802304f393091d30cb2 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 7 Jun 2024 17:26:20 +0200 Subject: [PATCH] Allow DCE as outer input to to_cwl --- lib/galaxy/workflow/modules.py | 4 ++-- test/unit/workflows/test_modules.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/workflow/modules.py b/lib/galaxy/workflow/modules.py index 79aac7f72115..882eaebde4f5 100644 --- a/lib/galaxy/workflow/modules.py +++ b/lib/galaxy/workflow/modules.py @@ -128,9 +128,9 @@ def to_cwl(value, hda_references, step): element_identifier = None if isinstance(value, model.HistoryDatasetCollectionAssociation): value = value.collection - if isinstance(value, model.DatasetCollectionElement) and value.hda: + if isinstance(value, model.DatasetCollectionElement): element_identifier = value.element_identifier - value = value.hda + value = value.element_object if isinstance(value, model.HistoryDatasetAssociation): # I think the following two checks are needed but they may # not be needed. diff --git a/test/unit/workflows/test_modules.py b/test/unit/workflows/test_modules.py index 8e0df5f81624..9e2bf5c4516e 100644 --- a/test/unit/workflows/test_modules.py +++ b/test/unit/workflows/test_modules.py @@ -274,6 +274,18 @@ def test_to_cwl_nested_collection(): assert result["outer"][0]["basename"] == "inner" +def test_to_cwl_dataset_collection_element(): + hda = model.HistoryDatasetAssociation(create_dataset=True, flush=False) + hda.dataset.state = model.Dataset.states.OK + dc_inner = model.DatasetCollection(collection_type="list") + model.DatasetCollectionElement(collection=dc_inner, element_identifier="inner", element=hda) + dc_outer = model.DatasetCollection(collection_type="list:list") + dce_outer = model.DatasetCollectionElement(collection=dc_outer, element_identifier="outer", element=dc_inner) + result = modules.to_cwl(dce_outer, [], model.WorkflowStep()) + assert result[0]["class"] == "File" + assert result[0]["basename"] == "inner" + + class MapOverTestCase(NamedTuple): data_input: str step_input_def: Union[str, List[str]]