Merge pull request #3657 from lecorguille/dynamic_tool_nest_param

Allow nest param in the dynamic_tool rule -> argument
This commit is contained in:
John Chilton
2017-04-06 08:24:55 -04:00
committed by GitHub
2 changed files with 23 additions and 6 deletions
+3 -1
View File
@@ -121,7 +121,9 @@
# destination: fail
# fail_message: Don't do that
# arguments:
# careful: true
# my_section:
# my_condition:
# careful: true
# default_destination: cluster_low
# default_destination: cluster
# verbose: False
+20 -5
View File
@@ -11,6 +11,7 @@ import sys
import copy
import collections
import re
from functools import reduce
# log to galaxy's logger
@@ -28,6 +29,17 @@ class ScannerError(Exception):
pass
def get_keys_from_dict(dl, keys_list):
"""
This function builds a list using the keys from nest dictionaries
"""
if isinstance(dl, dict):
keys_list += dl.keys()
map(lambda x: get_keys_from_dict(x, keys_list), dl.values())
elif isinstance(dl, list):
map(lambda x: get_keys_from_dict(x, keys_list), dl)
class RuleValidator:
"""
This class is the primary facility for validating configs. It's always called
@@ -1290,14 +1302,17 @@ def map_tool_to_destination(
elif rule["rule_type"] == "arguments":
options = job.get_param_values(app)
matched = True
# check if the args in the config file are available
for arg in rule["arguments"]:
if arg in options:
if rule["arguments"][arg] != options[arg]:
arg_dict = {arg : rule["arguments"][arg]}
arg_keys_list = []
get_keys_from_dict(arg_dict, arg_keys_list)
try:
options_value = reduce(dict.__getitem__, arg_keys_list, options)
arg_value = reduce(dict.__getitem__, arg_keys_list, arg_dict)
if (arg_value != options_value):
matched = False
options = "test"
else:
except KeyError:
matched = False
if verbose:
error = "Argument '" + str(arg)