Skip to content

Commit

Permalink
Implement default format on collection level
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Jun 13, 2024
1 parent e5fca08 commit 6551f31
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
8 changes: 7 additions & 1 deletion lib/galaxy/tool_util/parser/output_collection_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ def dataset_collector_descriptions_from_elem(elem, legacy=True):
if num_discover_dataset_blocks == 0 and legacy:
collectors = [DEFAULT_DATASET_COLLECTOR_DESCRIPTION]
else:
collectors = [dataset_collection_description(**e.attrib) for e in primary_dataset_elems]
default_format = elem.attrib.get("format")
collectors = []
for e in primary_dataset_elems:
description_attributes = e.attrib
if default_format and "format" not in description_attributes and "ext" not in description_attributes:
description_attributes["format"] = default_format
collectors.append(dataset_collection_description(**description_attributes))

return _validate_collectors(collectors)

Expand Down
10 changes: 6 additions & 4 deletions lib/galaxy/tool_util/xsd/galaxy.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -5360,11 +5360,13 @@ The default is ``galaxy.json``.
<xs:attributeGroup name="OutputCommon">
<xs:attribute name="format" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="en">The short name for the output datatype.
The valid values for format can be found in
<xs:documentation xml:lang="en"><![CDATA[
The short name for the output datatype. The valid values for format can be found in
[/config/datatypes_conf.xml.sample](https://github.com/galaxyproject/galaxy/blob/dev/config/datatypes_conf.xml.sample)
(e.g. ``format="pdf"`` or ``format="fastqsanger"``). For collections this is the default format for all included
elements. Note that the format specified here is ignored for discovered data sets.</xs:documentation>
(e.g. ``format="pdf"`` or ``format="fastqsanger"``). For collections this is the default
format for all included elements. Note that the format specified here is ignored for
discovered data sets on Galaxy versions prior to 24.0 and should be specified using the ``<discovered_data>`` tag set.
]]></xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="format_source" type="xs:string">
Expand Down
14 changes: 14 additions & 0 deletions test/unit/app/tools/test_collect_primary_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ def test_collect_multiple_recurse_dict(self):
created_hda_3 = datasets[DEFAULT_TOOL_OUTPUT]["test3"]
assert_created_with_path(self.app.object_store, created_hda_3.dataset, path3)

def test_collect_collection_default_format(self):
self._replace_output_collectors(
"""<dataset_collection name="parent" format="abcdef">
<discover_datasets pattern="__name__" directory="subdir_for_name_discovery" sort_by="reverse_filename" />
</dataset_collection>"""
)
self._setup_extra_file(subdir="subdir_for_name_discovery", filename="test1")
self._setup_extra_file(subdir="subdir_for_name_discovery", filename="test2")

datasets = self._collect()
assert DEFAULT_TOOL_OUTPUT in datasets
for dataset in datasets[DEFAULT_TOOL_OUTPUT].values():
assert dataset.ext == "abcdef"

def test_collect_sorted_reverse(self):
self._replace_output_collectors(
"""<output>
Expand Down

0 comments on commit 6551f31

Please sign in to comment.