diff --git a/doc/schema_template.md b/doc/schema_template.md index 789157c3dd3..239a5cf318b 100644 --- a/doc/schema_template.md +++ b/doc/schema_template.md @@ -17,7 +17,7 @@ $toc $tag:tool://element[@name='tool'] $tag:tool|description://element[@name='tool']//element[@name='description'] -$tag:tool|version_command://element[@name='tool']//element[@name='version_command'] +$tag:tool|version_command://complexType[@name='VersionCommand'] $tag:tool|command://element[@name='tool']//element[@name='command'] hide_attributes $tag:tool|inputs://complexType[@name='Inputs'] $tag:tool|inputs|section://complexType[@name='Section'] diff --git a/lib/galaxy/jobs/__init__.py b/lib/galaxy/jobs/__init__.py index 9ca65ee0bec..f87e6844bbe 100644 --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -8,6 +8,7 @@ import os import pwd import random import shutil +import string import subprocess import sys import time @@ -919,8 +920,10 @@ class JobWrapper( object ): self.sa_session.flush() # Return list of all extra files self.param_dict = tool_evaluator.param_dict - version_string_cmd = self.tool.version_string_cmd - if version_string_cmd: + version_string_cmd_raw = self.tool.version_string_cmd + if version_string_cmd_raw: + version_command_template = string.Template(version_string_cmd_raw) + version_string_cmd = version_command_template.safe_substitute({"__tool_directory__": compute_environment.tool_directory() }) self.write_version_cmd = "%s > %s 2>&1" % ( version_string_cmd, compute_environment.version_path() ) else: self.write_version_cmd = None diff --git a/lib/galaxy/tools/xsd/galaxy.xsd b/lib/galaxy/tools/xsd/galaxy.xsd index 07fbc989ac5..15c45c6604b 100644 --- a/lib/galaxy/tools/xsd/galaxy.xsd +++ b/lib/galaxy/tools/xsd/galaxy.xsd @@ -61,23 +61,7 @@ the tool menu immediately following the hyperlink for the tool (based on the - - - tophat -version -``` -]]> - + @@ -1428,7 +1412,7 @@ many of the default assertion tags that come with Galaxy and examples of each can be found below. The implementation of these tags are simply Python functions defined in the -[``galaxy.tools.verify.asserts``](https://github.com/galaxyproject/galaxy/tree/dev/lib/galaxy/tools/verify/asserts] +[``galaxy.tools.verify.asserts``](https://github.com/galaxyproject/galaxy/tree/dev/lib/galaxy/tools/verify/asserts) module. ]]> @@ -4215,7 +4199,6 @@ define. - + + + tophat -version +``` + +An example that leverages a Python script (e.g. ``count_reads.py``) shipped with +the tool might be: + +```xml +python $__tool_directory__/count_reads.py +``` + +Examples are included in the test tools directory including: + +- [version_command_plain.xml](https://github.com/galaxyproject/galaxy/blob/dev/test/functional/tools/version_command_plain.xml) +- [version_command_tool_dir.xml](https://github.com/galaxyproject/galaxy/blob/dev/test/functional/tools/version_tool_dir.xml) +- [version_command_interpreter.xml](https://github.com/galaxyproject/galaxy/blob/dev/test/functional/tools/version_command_interpreter.xml) (*deprecated*) + +]]> + + + + + + $__tool_directory__/``.]]> + + + + + + --> + + + diff --git a/test/functional/tools/version_command.py b/test/functional/tools/version_command.py new file mode 100644 index 00000000000..7781eb1d769 --- /dev/null +++ b/test/functional/tools/version_command.py @@ -0,0 +1,2 @@ +from __future__ import print_function +print("4.0.0") diff --git a/test/functional/tools/version_command_interpreter.xml b/test/functional/tools/version_command_interpreter.xml new file mode 100644 index 00000000000..15b6ce8567d --- /dev/null +++ b/test/functional/tools/version_command_interpreter.xml @@ -0,0 +1,20 @@ + + + version_command.py + + + cp $input $output + + + + + + + + + + + + + + diff --git a/test/functional/tools/version_command_plain.xml b/test/functional/tools/version_command_plain.xml new file mode 100644 index 00000000000..8211fde9b6b --- /dev/null +++ b/test/functional/tools/version_command_plain.xml @@ -0,0 +1,20 @@ + + + echo "4.0.0" + + + cp $input $output + + + + + + + + + + + + + + diff --git a/test/functional/tools/version_command_tool_dir.xml b/test/functional/tools/version_command_tool_dir.xml new file mode 100644 index 00000000000..87023ee1a63 --- /dev/null +++ b/test/functional/tools/version_command_tool_dir.xml @@ -0,0 +1,20 @@ + + + python $__tool_directory__/version_command.py + + + cp $input $output + + + + + + + + + + + + + + diff --git a/test/unit/jobs/test_job_wrapper.py b/test/unit/jobs/test_job_wrapper.py index b66619014c7..9386f054475 100644 --- a/test/unit/jobs/test_job_wrapper.py +++ b/test/unit/jobs/test_job_wrapper.py @@ -157,6 +157,7 @@ class MockTool(object): def __init__(self, app): self.version_string_cmd = TEST_VERSION_COMMAND + self.tool_dir = "/path/to/tools" self.dependencies = [] def build_dependency_shell_commands(self, job_directory):