From b92c9cf1eadb918cfc4d90864dceac11f5d0b014 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 22 Aug 2024 12:20:42 -0400 Subject: [PATCH] Implement tool upgrade assistant script. Inspect a tool's XML file and provide advice on upgrading to new tool versions. It is implemented as a library in tool_util for integration with Planemo in the future but I've added a script here to run it on the command-line directly. It can also output in JSON for integration with external tools such as the galaxy language server. --- lib/galaxy/tool_util/parser/xml.py | 6 +++++- lib/galaxy/tool_util/xsd/galaxy.xsd | 6 +++++- packages/tool_util/setup.cfg | 1 + test/functional/tools/legacy_interpreter.xml | 19 +++++++++++++++++++ .../tools/legacy_interpreter_write_output.py | 2 ++ test/functional/tools/output_format_input.xml | 2 +- test/functional/tools/sample_tool_conf.xml | 1 + 7 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 test/functional/tools/legacy_interpreter.xml create mode 100644 test/functional/tools/legacy_interpreter_write_output.py diff --git a/lib/galaxy/tool_util/parser/xml.py b/lib/galaxy/tool_util/parser/xml.py index 9ab4a30f65b6..8e098236a110 100644 --- a/lib/galaxy/tool_util/parser/xml.py +++ b/lib/galaxy/tool_util/parser/xml.py @@ -376,6 +376,10 @@ def _get_option_value(self, key, default): def _command_el(self): return self.root.find("command") + @property + def _outputs_el(self): + return self.root.find("outputs") + def _get_attribute_as_bool(self, attribute, default, elem=None): if elem is None: elem = self.root @@ -411,7 +415,7 @@ def parse_input_pages(self) -> "XmlPagesSource": def parse_provided_metadata_style(self): style = None - out_elem = self.root.find("outputs") + out_elem = self._outputs_el if out_elem is not None and "provided_metadata_style" in out_elem.attrib: style = out_elem.attrib["provided_metadata_style"] diff --git a/lib/galaxy/tool_util/xsd/galaxy.xsd b/lib/galaxy/tool_util/xsd/galaxy.xsd index 7c17312c4f0b..de34e758331b 100644 --- a/lib/galaxy/tool_util/xsd/galaxy.xsd +++ b/lib/galaxy/tool_util/xsd/galaxy.xsd @@ -29,10 +29,14 @@ List of behavior changes associated with profile versions: - Disable default tool version of 1.0.0. - Use non zero exit code as default stdio error condition (before non-empty stderr). +#### 17.09 + +- Introduce `provided_metadata_style` with default `"default"`. Restore legacy behavior by setting + this to `"legacy"`. + #### 18.01 - Use a separate home directory for each job. -- Introduce `provided_metadata_style` with default `"default"` before `"legacy"`. #### 18.09 diff --git a/packages/tool_util/setup.cfg b/packages/tool_util/setup.cfg index 7c8fd75feec1..a83feee3e048 100644 --- a/packages/tool_util/setup.cfg +++ b/packages/tool_util/setup.cfg @@ -49,6 +49,7 @@ python_requires = >=3.7 [options.entry_points] console_scripts = galaxy-tool-test = galaxy.tool_util.verify.script:main + galaxy-tool-upgrade-advisor = galaxy.tool_util.upgrade.script:main mulled-build = galaxy.tool_util.deps.mulled.mulled_build:main mulled-build-channel = galaxy.tool_util.deps.mulled.mulled_build_channel:main mulled-build-files = galaxy.tool_util.deps.mulled.mulled_build_files:main diff --git a/test/functional/tools/legacy_interpreter.xml b/test/functional/tools/legacy_interpreter.xml new file mode 100644 index 000000000000..7ca65584d388 --- /dev/null +++ b/test/functional/tools/legacy_interpreter.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + diff --git a/test/functional/tools/legacy_interpreter_write_output.py b/test/functional/tools/legacy_interpreter_write_output.py new file mode 100644 index 000000000000..25791f7b3d86 --- /dev/null +++ b/test/functional/tools/legacy_interpreter_write_output.py @@ -0,0 +1,2 @@ +with open("output1", "w") as f: + f.write("hello world") diff --git a/test/functional/tools/output_format_input.xml b/test/functional/tools/output_format_input.xml index c346b10dedf3..6080f0c21ca2 100644 --- a/test/functional/tools/output_format_input.xml +++ b/test/functional/tools/output_format_input.xml @@ -1,6 +1,6 @@ + (for legacy tools, i.e. profile <16.04, the format of a random input is used) --> cat '$input' > '$output' diff --git a/test/functional/tools/sample_tool_conf.xml b/test/functional/tools/sample_tool_conf.xml index 80c032c93601..4afe5cf253f8 100644 --- a/test/functional/tools/sample_tool_conf.xml +++ b/test/functional/tools/sample_tool_conf.xml @@ -176,6 +176,7 @@ +