Skip to content

Commit

Permalink
Merge pull request #7854 from jmchilton/job_conf_from_dict
Browse files Browse the repository at this point in the history
Allow YAML/JSON job configuration.
  • Loading branch information
mvdbeek authored May 7, 2019
2 parents 2c2e6ae + 18d182c commit 3dbab3d
Show file tree
Hide file tree
Showing 30 changed files with 1,535 additions and 562 deletions.
5 changes: 5 additions & 0 deletions config/galaxy.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -1530,6 +1530,11 @@ galaxy:
# configuration file.
#job_config_file: config/job_conf.xml

# Description of job running configuration, can be embedded into
# Galaxy configuration or loaded from an additional file with the
# job_config_file option.
#job_config: null

# When jobs fail due to job runner problems, Galaxy can be configured
# to retry these or reroute the jobs to new destinations. Very fine
# control of this is available with resubmit declarations in
Expand Down
12 changes: 12 additions & 0 deletions doc/source/admin/galaxy_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3187,6 +3187,18 @@
:Type: str


~~~~~~~~~~~~~~
``job_config``
~~~~~~~~~~~~~~

:Description:
Description of job running configuration, can be embedded into
Galaxy configuration or loaded from an additional file with the
job_config_file option.
:Default: ``None``
:Type: map


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``default_job_resubmission_condition``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
54 changes: 40 additions & 14 deletions lib/galaxy/dependencies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,46 @@ def __init__(self, config_file):

def parse_configs(self):
self.config = load_app_properties(config_file=self.config_file)
job_conf_xml = self.config.get(
"job_config_file",
join(dirname(self.config_file), 'job_conf.xml'))
try:
for plugin in ElementTree.parse(job_conf_xml).find('plugins').findall('plugin'):
if 'load' in plugin.attrib:
self.job_runners.append(plugin.attrib['load'])
except (OSError, IOError):
pass
try:
for plugin in ElementTree.parse(job_conf_xml).findall('.//destination/param[@id="rules_module"]'):
self.job_rule_modules.append(plugin.text)
except (OSError, IOError):
pass

def load_job_config_dict(job_conf_dict):
for runner in job_conf_dict.get("runners"):
if "load" in runner:
self.job_runners.append(runner.get("load"))
if "rules_module" in runner:
self.job_rule_modules.append(plugin.text)
if "params" in runner:
runner_params = runner["params"]
if "rules_module" in runner_params:
self.job_rule_modules.append(plugin.text)

if "job_config" in self.config:
load_job_config_dict(self.config.get("job_config"))
else:
job_conf_path = self.config.get(
"job_config_file",
join(dirname(self.config_file), 'job_conf.xml'))
if '.xml' in job_conf_path:
try:
try:
for plugin in ElementTree.parse(job_conf_path).find('plugins').findall('plugin'):
if 'load' in plugin.attrib:
self.job_runners.append(plugin.attrib['load'])
except (OSError, IOError):
pass
try:
for plugin in ElementTree.parse(job_conf_path).findall('.//destination/param[@id="rules_module"]'):
self.job_rule_modules.append(plugin.text)
except (OSError, IOError):
pass
except ElementTree.ParseError:
pass
else:
try:
job_conf_dict = yaml.safe_load(job_conf_path)
load_job_config_dict(job_conf_dict)
except (OSError, IOError):
pass

object_store_conf_xml = self.config.get(
"object_store_config_file",
join(dirname(self.config_file), 'object_store_conf.xml'))
Expand Down
Loading

0 comments on commit 3dbab3d

Please sign in to comment.