Skip to content

Commit

Permalink
Implement tool upgrade assistant script.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jmchilton committed Aug 22, 2024
1 parent 2cd33e8 commit b92c9cf
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/galaxy/tool_util/parser/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]

Expand Down
6 changes: 5 additions & 1 deletion lib/galaxy/tool_util/xsd/galaxy.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/tool_util/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions test/functional/tools/legacy_interpreter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<tool id="legacy_interpreter" name="legacy_interpreter" version="1.0.0">
<command interpreter="python"><![CDATA[
legacy_interpreter_write_output.py
]]></command>
<inputs>
</inputs>
<outputs>
<data name="output1" format="xml" from_work_dir="output1" />
</outputs>
<tests>
<test>
<output name="output1">
<assert_contents>
<has_text text="hello world" />
</assert_contents>
</output>
</test>
</tests>
</tool>
2 changes: 2 additions & 0 deletions test/functional/tools/legacy_interpreter_write_output.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
with open("output1", "w") as f:
f.write("hello world")
2 changes: 1 addition & 1 deletion test/functional/tools/output_format_input.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<tool id="output_format_input" name="output_format_input" version="1.0" profile="21.01">
<!-- test format="input" for the profile version where the format is set to "input"
(for legacy tools, i.e. profile <16.04, the format of a ramdom input is used) -->
(for legacy tools, i.e. profile <16.04, the format of a random input is used) -->
<description></description>
<command>
cat '$input' > '$output'
Expand Down
1 change: 1 addition & 0 deletions test/functional/tools/sample_tool_conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
<tool file="identifier_in_actions.xml" />
<tool file="fail_identifier.xml" />
<tool file="fail_writing_work_dir_file.xml" />
<tool file="legacy_interpreter.xml" />
<tool file="tool_directory.xml" />
<tool file="tool_directory_docker.xml" />
<tool file="output_action_change_format.xml" />
Expand Down

0 comments on commit b92c9cf

Please sign in to comment.