mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Add example and test case for job configuration expansion.
First suggestion by @nsoranzo and second was easy once example was added to advanced config.
This commit is contained in:
@@ -442,6 +442,13 @@
|
||||
<param id="docker_enabled" from_config="use_docker">false</param>
|
||||
</destination>
|
||||
|
||||
<!-- Templatized destinations - macros can be used to create templated
|
||||
destinations with reduced XML duplication. Here we are creating 4 destinations in 4 lines instead of 28 using the macros defined below.
|
||||
-->
|
||||
<expand macro="foohost_destination" id="foo_small" ncpus="1" walltime="1:00:00" />
|
||||
<expand macro="foohost_destination" id="foo_medium" ncpus="2" walltime="4:00:00" />
|
||||
<expand macro="foohost_destination" id="foo_large" ncpus="8" walltime="24:00:00" />
|
||||
<expand macro="foohost_destination" id="foo_longrunning" ncpus="1" walltime="48:00:00" />
|
||||
</destinations>
|
||||
<resources default="default">
|
||||
<!-- Group different parameters defined in job_resource_params_conf.xml
|
||||
@@ -515,4 +522,15 @@
|
||||
-->
|
||||
<limit type="output_size">10GB</limit>
|
||||
</limits>
|
||||
<macros>
|
||||
<xml name="foohost_destination" tokens="id,walltime,ncpus">
|
||||
<destination id="@ID@" runner="cli">
|
||||
<param id="shell_plugin">SecureShell</param>
|
||||
<param id="job_plugin">Torque</param>
|
||||
<param id="shell_username">galaxy</param>
|
||||
<param id="shell_hostname">foohost_destination.example.org</param>
|
||||
<param id="job_Resource_List">walltime=@WALLTIME@,ncpus=@NCPUS@</param>
|
||||
</destination>
|
||||
</xml>
|
||||
</macros>
|
||||
</job_conf>
|
||||
|
||||
@@ -127,7 +127,6 @@ def _expand_macro(element, expand_el, macros, tokens):
|
||||
_expand_macros(expanded_elements, macros, tokens)
|
||||
macro_tokens = macro_def.macro_tokens(expand_el)
|
||||
if macro_tokens:
|
||||
print macro_tokens
|
||||
_expand_tokens(expanded_elements, macro_tokens)
|
||||
|
||||
# HACK for elementtree, newer implementations (etree/lxml) won't
|
||||
|
||||
@@ -128,6 +128,12 @@ class JobConfXmlParserTestCase( unittest.TestCase ):
|
||||
|
||||
assert env_dest.env[ 3 ][ "execute" ] == "module load javastuff/2.10"
|
||||
|
||||
def test_macro_expansion( self ):
|
||||
self.__with_advanced_config()
|
||||
for name in ["foo_small", "foo_medium", "foo_large", "foo_longrunning"]:
|
||||
print self.job_config.destinations.keys()
|
||||
assert self.job_config.destinations[ name ]
|
||||
|
||||
# TODO: Add job metrics parsing test.
|
||||
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user