mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 10:24:38 +08:00
Merge pull request #20158 from mvdbeek/yaml_parser_fixes
Yaml parser fixes and improvements (part 1)
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
<span v-localize class="footer-section-name">References</span>
|
||||
<div v-for="(xref, index) in xrefs" :key="index">
|
||||
-
|
||||
<template v-if="xref.reftype == 'bio.tools'">
|
||||
<template v-if="xref.type == 'bio.tools'">
|
||||
bio.tools: {{ xref.value }} (<a :href="`https://bio.tools/${xref.value}`" target="_blank"
|
||||
>bio.tools
|
||||
<FontAwesomeIcon
|
||||
@@ -55,13 +55,13 @@
|
||||
icon="external-link-alt" /> </a
|
||||
>)
|
||||
</template>
|
||||
<template v-else-if="xref.reftype == 'bioconductor'">
|
||||
<template v-else-if="xref.type == 'bioconductor'">
|
||||
Bioconductor Package:
|
||||
<a :href="`https://bioconductor.org/packages/${xref.value}/`" target="_blank"
|
||||
>{{ xref.value }} (doi:10.18129/B9.bioc.{{ xref.value }})</a
|
||||
>
|
||||
</template>
|
||||
<template v-else> {{ xref.reftype }}: {{ xref.value }} </template>
|
||||
<template v-else> {{ xref.type }}: {{ xref.value }} </template>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="hasCreators" class="mb-1">
|
||||
|
||||
@@ -237,7 +237,7 @@ class BioToolsValid(Linter):
|
||||
_, tool_node = _tool_xml_and_root(tool_source)
|
||||
xrefs = tool_source.parse_xrefs()
|
||||
for xref in xrefs:
|
||||
if xref["reftype"] != "bio.tools":
|
||||
if xref["type"] != "bio.tools":
|
||||
continue
|
||||
metadata_source = ApiBiotoolsMetadataSource()
|
||||
if not metadata_source.get_biotools_metadata(xref["value"]):
|
||||
|
||||
@@ -53,7 +53,7 @@ class OntologyData(NamedTuple):
|
||||
|
||||
def biotools_reference(xrefs):
|
||||
for xref in xrefs:
|
||||
if xref["reftype"] == "bio.tools":
|
||||
if xref["type"] == "bio.tools":
|
||||
return xref["value"]
|
||||
return None
|
||||
|
||||
@@ -69,11 +69,11 @@ def expand_ontology_data(
|
||||
tool_source: ToolSource, all_ids: List[str], biotools_metadata_source: Optional[BiotoolsMetadataSource]
|
||||
) -> OntologyData:
|
||||
xrefs = tool_source.parse_xrefs()
|
||||
has_biotools_reference = any(x["reftype"] == "bio.tools" for x in xrefs)
|
||||
has_biotools_reference = any(x["type"] == "bio.tools" for x in xrefs)
|
||||
if not has_biotools_reference:
|
||||
for legacy_biotools_ref in legacy_biotools_external_reference(all_ids):
|
||||
if legacy_biotools_ref is not None:
|
||||
xrefs.append({"value": legacy_biotools_ref, "reftype": "bio.tools"})
|
||||
xrefs.append({"value": legacy_biotools_ref, "type": "bio.tools"})
|
||||
|
||||
edam_operations = tool_source.parse_edam_operations()
|
||||
edam_topics = tool_source.parse_edam_topics()
|
||||
|
||||
@@ -159,7 +159,7 @@ class CwlToolSource(ToolSource):
|
||||
output.format = "expression.json"
|
||||
output.change_format = []
|
||||
output.format_source = None
|
||||
output.metadata_source = ""
|
||||
output.metadata_source = None
|
||||
output.parent = None
|
||||
output.label = None
|
||||
output.count = None
|
||||
|
||||
@@ -58,7 +58,7 @@ def dataset_collector_descriptions_from_elem(elem, legacy=True):
|
||||
|
||||
|
||||
def dataset_collector_descriptions_from_output_dict(as_dict):
|
||||
discover_datasets_dicts = as_dict.get("discover_datasets", [])
|
||||
discover_datasets_dicts = as_dict.get("discover_datasets") or []
|
||||
if is_dict(discover_datasets_dicts):
|
||||
discover_datasets_dicts = [discover_datasets_dicts]
|
||||
dataset_collector_descriptions = dataset_collector_descriptions_from_list(discover_datasets_dicts)
|
||||
|
||||
@@ -175,24 +175,25 @@ class ToolOutput(ToolOutputBase):
|
||||
hidden=self.hidden,
|
||||
format=self.format,
|
||||
format_source=self.format_source,
|
||||
metadata_source=self.metadata_source or None, # model is decorated as Optional
|
||||
metadata_source=self.metadata_source,
|
||||
discover_datasets=[d.to_model() for d in self.dataset_collector_descriptions],
|
||||
from_work_dir=self.from_work_dir,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def from_dict(name: str, output_dict: Dict[str, Any], app: Optional[ToolOutputActionApp] = None) -> "ToolOutput":
|
||||
output = ToolOutput(name)
|
||||
output.format = output_dict.get("format", "data")
|
||||
output.format = output_dict.get("format") or "data"
|
||||
output.change_format = []
|
||||
output.format_source = output_dict.get("format_source", None)
|
||||
output.default_identifier_source = output_dict.get("default_identifier_source", None)
|
||||
output.metadata_source = output_dict.get("metadata_source", "")
|
||||
output.parent = output_dict.get("parent", None)
|
||||
output.label = output_dict.get("label", None)
|
||||
output.format_source = output_dict.get("format_source")
|
||||
output.default_identifier_source = output_dict.get("default_identifier_source")
|
||||
output.metadata_source = output_dict.get("metadata_source")
|
||||
output.parent = output_dict.get("parent")
|
||||
output.label = output_dict.get("label")
|
||||
output.count = output_dict.get("count", 1)
|
||||
output.filters = []
|
||||
output.from_work_dir = output_dict.get("from_work_dir", None)
|
||||
output.hidden = output_dict.get("hidden", False)
|
||||
output.from_work_dir = output_dict.get("from_work_dir")
|
||||
output.hidden = output_dict.get("hidden") or False
|
||||
# TODO: implement tool output action group fixes
|
||||
if app is not None:
|
||||
output.actions = ToolOutputActionGroup(app, None)
|
||||
|
||||
@@ -224,7 +224,7 @@ class XmlToolSource(ToolSource):
|
||||
if xrefs is None:
|
||||
return []
|
||||
return [
|
||||
XrefDict(value=xref.text.strip(), reftype=str(xref.attrib["type"]))
|
||||
XrefDict(value=xref.text.strip(), type=str(xref.attrib["type"]))
|
||||
for xref in xrefs.findall("xref")
|
||||
if xref.get("type") and xref.text
|
||||
]
|
||||
@@ -489,7 +489,7 @@ class XmlToolSource(ToolSource):
|
||||
inherit_format = string_as_bool(collection_elem.get("inherit_format", None))
|
||||
inherit_metadata = string_as_bool(collection_elem.get("inherit_metadata", None))
|
||||
default_format_source = collection_elem.get("format_source", None)
|
||||
default_metadata_source = collection_elem.get("metadata_source", "")
|
||||
default_metadata_source = collection_elem.get("metadata_source", None)
|
||||
filters = collection_elem.findall("filter")
|
||||
|
||||
dataset_collector_descriptions = None
|
||||
@@ -560,7 +560,7 @@ class XmlToolSource(ToolSource):
|
||||
app: Optional[ToolOutputActionApp] = None,
|
||||
default_format="data",
|
||||
default_format_source=None,
|
||||
default_metadata_source="",
|
||||
default_metadata_source=None,
|
||||
expression_type=None,
|
||||
):
|
||||
from_expression = data_elem.get("from")
|
||||
|
||||
@@ -86,7 +86,7 @@ class YamlToolSource(ToolSource):
|
||||
|
||||
def parse_xrefs(self) -> List[XrefDict]:
|
||||
xrefs = self.root_dict.get("xrefs", [])
|
||||
return [XrefDict(value=xref["value"], reftype=xref["type"]) for xref in xrefs if xref["type"]]
|
||||
return [XrefDict(value=xref["value"], type=xref["type"]) for xref in xrefs if xref["type"]]
|
||||
|
||||
def parse_sanitize(self):
|
||||
return self.root_dict.get("sanitize", True)
|
||||
@@ -192,7 +192,7 @@ class YamlToolSource(ToolSource):
|
||||
inherit_format = output_dict.get("inherit_format", None)
|
||||
inherit_metadata = output_dict.get("inherit_metadata", None)
|
||||
default_format_source = output_dict.get("format_source", None)
|
||||
default_metadata_source = output_dict.get("metadata_source", "")
|
||||
default_metadata_source = output_dict.get("metadata_source", None)
|
||||
filters = []
|
||||
dataset_collector_descriptions = dataset_collector_descriptions_from_output_dict(output_dict)
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ class ToolOutputDataset(ToolOutputBaseModel):
|
||||
format_source: Optional[str]
|
||||
metadata_source: Optional[str]
|
||||
discover_datasets: Optional[List["DatasetCollectionDescriptionT"]]
|
||||
from_work_dir: Optional[str] = None
|
||||
|
||||
|
||||
class ToolOutputCollectionStructure(BaseModel):
|
||||
|
||||
@@ -15,7 +15,7 @@ from typing_extensions import (
|
||||
|
||||
class XrefDict(TypedDict):
|
||||
value: str
|
||||
reftype: str
|
||||
type: str
|
||||
|
||||
|
||||
class Citation(BaseModel):
|
||||
|
||||
@@ -257,7 +257,7 @@ class TestToolsApi(ApiTestCase, TestsTools):
|
||||
assert "xrefs" in get_json
|
||||
assert len(get_json["xrefs"]) == 1
|
||||
xref = get_json["xrefs"][0]
|
||||
assert xref["reftype"] == "bio.tools"
|
||||
assert xref["type"] == "bio.tools"
|
||||
assert xref["value"] == "bwa"
|
||||
|
||||
@skip_without_tool("test_data_source")
|
||||
|
||||
@@ -156,11 +156,11 @@ const linkedFromOlderRevision = computed(() => {
|
||||
<q-list bordered separator>
|
||||
<q-item v-for="xref in xrefs" :key="xref.value">
|
||||
<q-item-section>
|
||||
<q-item-label overline>REFERENCE {{ xref.reftype }}</q-item-label>
|
||||
<q-item-label v-if="xref.reftype == 'bio.tools'">
|
||||
<q-item-label overline>REFERENCE {{ xref.type }}</q-item-label>
|
||||
<q-item-label v-if="xref.type == 'bio.tools'">
|
||||
<bio-tools-link :id="xref.value" />
|
||||
</q-item-label>
|
||||
<q-item-label v-else-if="xref.reftype == 'bioconductor'">
|
||||
<q-item-label v-else-if="xref.type == 'bioconductor'">
|
||||
<bioconductor-link :id="xref.value" />
|
||||
</q-item-label>
|
||||
<q-item-label v-else>
|
||||
|
||||
@@ -2727,6 +2727,8 @@ export interface components {
|
||||
format: string
|
||||
/** Format Source */
|
||||
format_source: string | null
|
||||
/** From Work Dir */
|
||||
from_work_dir?: string | null
|
||||
/** Hidden */
|
||||
hidden: boolean
|
||||
/** Label */
|
||||
@@ -3006,8 +3008,8 @@ export interface components {
|
||||
}
|
||||
/** XrefDict */
|
||||
XrefDict: {
|
||||
/** Reftype */
|
||||
reftype: string
|
||||
/** Type */
|
||||
type: string
|
||||
/** Value */
|
||||
value: string
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ def test_parse_edam_mapping_operations_legacy():
|
||||
def test_parse_biotools_default_mapping():
|
||||
test_source = get_test_tool_source(source_file_name="testtool.yml", source_contents=TOOL_YAML_NO_EXPLICIT_XREFS)
|
||||
ontology_data = expand_ontology_data(test_source, ["cheetah_problem_unbound_var_input"], None)
|
||||
assert ontology_data.xrefs[0]["reftype"] == "bio.tools"
|
||||
assert ontology_data.xrefs[0]["type"] == "bio.tools"
|
||||
assert ontology_data.xrefs[0]["value"] == "bwa"
|
||||
|
||||
test_source = get_test_tool_source(source_file_name="testtool.yml", source_contents=TOOL_YAML_NO_EXPLICIT_XREFS)
|
||||
|
||||
@@ -416,7 +416,7 @@ class TestXmlLoader(BaseLoaderTestCase):
|
||||
|
||||
def test_xrefs(self):
|
||||
xrefs = self._tool_source.parse_xrefs()
|
||||
assert xrefs == [{"value": "bwa", "reftype": "bio.tools"}]
|
||||
assert xrefs == [{"value": "bwa", "type": "bio.tools"}]
|
||||
|
||||
def test_exit_code(self):
|
||||
tool_source = self._get_tool_source(
|
||||
@@ -622,7 +622,7 @@ class TestYamlLoader(BaseLoaderTestCase):
|
||||
|
||||
def test_xrefs(self):
|
||||
xrefs = self._tool_source.parse_xrefs()
|
||||
assert xrefs == [{"value": "bwa", "reftype": "bio.tools"}]
|
||||
assert xrefs == [{"value": "bwa", "type": "bio.tools"}]
|
||||
|
||||
def test_sanitize(self):
|
||||
assert self._tool_source.parse_sanitize() is True
|
||||
|
||||
Reference in New Issue
Block a user