Unverified Commit 6551f316 authored by mvdbeek's avatar mvdbeek
Browse files

Implement default format on collection level

parent e5fca086
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -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)

+6 −4
Original line number Diff line number Diff line
@@ -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">
+14 −0
Original line number Diff line number Diff line
@@ -128,6 +128,20 @@ class TestCollectPrimaryDatasets(TestCase, tools_support.UsesTools):
        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>