Skip to content

Commit

Permalink
Allow job config xml files to be passed as an argument
Browse files Browse the repository at this point in the history
job configuration xml files can now be passed as arguments to the
application with the -j  or the --job-config options. To
facilitate this change, the parse_yaml constructor has been altered
to accept a new parameter, job_conf_path, the path to the job
configuration.

For simplicity, get_destination_list_from_job_config is now called
from parse yaml instead of validate_config. This simply reduces the
amount of times the job_conf path needs to be passed between
functions.
  • Loading branch information
Matthew Spelchak committed Feb 7, 2018
1 parent 25e50cf commit ccf2144
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions lib/galaxy/jobs/dynamic_tool_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ def __validate_users(cls, valid_rule, return_bool, rule, tool, counter):
return valid_rule, rule


def parse_yaml(path="/config/tool_destinations.yml", test=False, return_bool=False):
def parse_yaml(path="/config/tool_destinations.yml", job_conf_path="/config/job_conf.xml", test=False, return_bool=False):
"""
Get a yaml file from path and send it to validate_config for validation.
Expand All @@ -691,6 +691,10 @@ def parse_yaml(path="/config/tool_destinations.yml", test=False, return_bool=Fal
@return: validated rule or result of validation (depending on return_bool)
"""

global destination_list
destination_list = get_destination_list_from_job_config(job_config_location=job_conf_path)

# Import file from path
try:
if test:
Expand Down Expand Up @@ -748,10 +752,7 @@ def validate_config(obj, return_bool=False):
"""

global priority_list
global destination_list

priority_list = set()
destination_list = get_destination_list_from_job_config()

def infinite_defaultdict():
return collections.defaultdict(infinite_defaultdict)
Expand Down Expand Up @@ -1534,7 +1535,12 @@ def get_destination_list_from_job_config(job_config_location='/config/job_conf.x
'-c', '--check-config', dest='check_config', nargs='?',
help='Use this option to validate tool_destinations.yml.' +
' Optionally, provide the path to the tool_destinations.yml' +
' that you would like to check. Default: galaxy/config/tool_destinations.yml')
' that you would like to check, and/or the path to the related' +
' job_conf.xml. Default: galaxy/config/tool_destinations.yml and' +
' galaxy/config/job_conf.xml')

parser.add_argument(
'-j', '--job-config', dest='job_config')

parser.add_argument(
'-V', '--version', action='version', version="%(prog)s " + __version__)
Expand All @@ -1546,11 +1552,18 @@ def get_destination_list_from_job_config(job_config_location='/config/job_conf.x
parser.print_help()
sys.exit(1)

if args.check_config:
valid_config = parse_yaml(path=args.check_config, return_bool=True)
if args.check_config and args.job_config:
valid_config = parse_yaml(path=args.check_config, job_conf_path=args.job_config, return_bool=True)

elif args.check_config:
valid_config = parse_yaml(path=args.check_config, job_conf_path="/config/job_conf.xml", return_bool=True)


elif args.job_config:
valid_config = parse_yaml(path="/config/tool_destinations.yml", job_conf_path=args.job_config, return_bool=True)

else:
valid_config = parse_yaml(path="/config/tool_destinations.yml", return_bool=True)
valid_config = parse_yaml(path="/config/tool_destinations.yml", job_conf_path="/config/job_conf.xml", return_bool=True)

if valid_config:
print("Configuration is valid!")
Expand Down

0 comments on commit ccf2144

Please sign in to comment.