mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 10:24:38 +08:00
Merge pull request #19716 from jmchilton/fix_citation_handling
[24.2] Fix #19515 - invalid citation handling changed with 24.2.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
from typing import (
|
||||
Dict,
|
||||
Type,
|
||||
@@ -8,6 +9,7 @@ from galaxy.util import plugin_config
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from galaxy.tool_util.locations import ToolLocationResolver
|
||||
from galaxy.util.path import StrPath
|
||||
|
||||
|
||||
class ToolLocationFetcher:
|
||||
@@ -19,8 +21,8 @@ class ToolLocationFetcher:
|
||||
|
||||
return plugin_config.plugins_dict(galaxy.tool_util.locations, "scheme")
|
||||
|
||||
def to_tool_path(self, path_or_uri_like: str, **kwds) -> str:
|
||||
if "://" not in path_or_uri_like:
|
||||
def to_tool_path(self, path_or_uri_like: "StrPath", **kwds) -> "StrPath":
|
||||
if isinstance(path_or_uri_like, os.PathLike) or "://" not in path_or_uri_like:
|
||||
path = path_or_uri_like
|
||||
else:
|
||||
uri_like = path_or_uri_like
|
||||
|
||||
@@ -86,9 +86,8 @@ def get_tool_source(
|
||||
tool_location_fetcher = ToolLocationFetcher()
|
||||
|
||||
assert config_file
|
||||
config_file = str(config_file)
|
||||
|
||||
config_file = tool_location_fetcher.to_tool_path(config_file)
|
||||
config_file = str(tool_location_fetcher.to_tool_path(config_file))
|
||||
if not enable_beta_formats:
|
||||
tree, macro_paths = load_tool_with_refereces(config_file)
|
||||
return XmlToolSource(tree, source_path=config_file, macro_paths=macro_paths)
|
||||
|
||||
@@ -708,7 +708,13 @@ class XmlToolSource(ToolSource):
|
||||
return citations
|
||||
|
||||
for citation_elem in citations_elem:
|
||||
citation = parse_citation_elem(citation_elem)
|
||||
try:
|
||||
citation = parse_citation_elem(citation_elem)
|
||||
except Exception:
|
||||
if Version(self.parse_profile()) < Version("24.2"):
|
||||
continue
|
||||
else:
|
||||
raise
|
||||
if citation:
|
||||
citations.append(citation)
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<tool id="invalid_citation" name="invalid_citation" version="1.0.0">
|
||||
<command>
|
||||
cat $input1 > $out_file1
|
||||
</command>
|
||||
<inputs>
|
||||
<param name="input1" type="data" label="Concatenate Dataset"/>
|
||||
</inputs>
|
||||
<outputs>
|
||||
<data name="out_file1" format="input" metadata_source="input1"/>
|
||||
</outputs>
|
||||
<!-- https://github.com/workflow4metabolomics/anova/blob/4bd408440b71359eac2c373917f5daff2ec9f69f/galaxy/stat_anova/abims_anova.xml -->
|
||||
<citations>
|
||||
<citation>Ronald A. Fisher in the 1930s</citation>
|
||||
</citations>
|
||||
<help>
|
||||
</help>
|
||||
</tool>
|
||||
@@ -0,0 +1,17 @@
|
||||
<tool id="invalid_citation" name="invalid_citation" version="1.0.0" profile="24.2">
|
||||
<command>
|
||||
cat $input1 > $out_file1
|
||||
</command>
|
||||
<inputs>
|
||||
<param name="input1" type="data" label="Concatenate Dataset"/>
|
||||
</inputs>
|
||||
<outputs>
|
||||
<data name="out_file1" format="input" metadata_source="input1"/>
|
||||
</outputs>
|
||||
<!-- https://github.com/workflow4metabolomics/anova/blob/4bd408440b71359eac2c373917f5daff2ec9f69f/galaxy/stat_anova/abims_anova.xml -->
|
||||
<citations>
|
||||
<citation>Ronald A. Fisher in the 1930s</citation>
|
||||
</citations>
|
||||
<help>
|
||||
</help>
|
||||
</tool>
|
||||
@@ -20,6 +20,10 @@ from galaxy.tool_util.parser.output_models import (
|
||||
)
|
||||
from galaxy.tool_util.unittest_utils import functional_test_tool_path
|
||||
from galaxy.util import galaxy_directory
|
||||
from galaxy.util.resources import (
|
||||
as_file,
|
||||
resource_path,
|
||||
)
|
||||
from galaxy.util.unittest import TestCase
|
||||
|
||||
TOOL_XML_1 = """
|
||||
@@ -948,6 +952,23 @@ class TestCollectionCatGroupTag(FunctionalTestToolTestCase):
|
||||
assert output_dataset_model.metadata_source == "input1"
|
||||
|
||||
|
||||
def test_old_invalid_citation_dont_cause_failure_to_load():
|
||||
with as_file(resource_path(__name__, "invalid_citation.xml")) as tool_path:
|
||||
tool_source = get_tool_source(tool_path)
|
||||
assert tool_source.parse_citations() == []
|
||||
|
||||
|
||||
def test_invalid_citation_not_allowed_in_modern_tools():
|
||||
with as_file(resource_path(__name__, "invalid_citation_24.2.xml")) as tool_path:
|
||||
tool_source = get_tool_source(tool_path)
|
||||
exc = None
|
||||
try:
|
||||
tool_source.parse_citations()
|
||||
except Exception as e:
|
||||
exc = e
|
||||
assert exc is not None
|
||||
|
||||
|
||||
class TestToolProvidedMetadata2(FunctionalTestToolTestCase):
|
||||
test_path = "tool_provided_metadata_2.xml"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user