Commit 54f7e79d authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Add rules to parameters + check them on jflow_cli (command line)

parent efba1798
......@@ -18,6 +18,7 @@
import sys
import argparse
import time
import re
try:
import _preamble
......@@ -55,6 +56,176 @@ class JflowArgumentParser (argparse.ArgumentParser):
return new_arg_strings
def _check_rule(rule: str, src_arg: str, user_args: dict, parameters: dict, all_files: list, wf_sub_parser):
"""
Check a parameter rule
@param rule: string describing the rule
@param src_arg: the argument containing the rule (string)
@param user_args: all arguments given by the user, with their values: {parameter_name1: value, ...}
@param parameters: all workflow parameters objects as dict: {parameter_name1: parameter_object1, ...}
@param all_files: all files given by the user
"""
from jflow.parameter import InputFileList, InputFile, InputDirectory
# Rule: Unique
if rule == "unique":
if isinstance(parameters[src_arg], InputFileList):
for file in user_args[src_arg]:
if user_args[src_arg].count(file) > 1:
wf_sub_parser.error("the file \"" + file + "\" in parameter \"" + src_arg + "\" is duplicated")
else:
print("\033[93mWarning: rule unique is ignored: " + src_arg + " is not an input file list\033[0m")
# Rule: Unique_all
elif rule == "unique_all":
if isinstance(parameters[src_arg], InputFile) or isinstance(parameters[src_arg], InputFileList):
files = user_args[src_arg]
if type(files) == str:
files = [files]
for file in files:
if all_files.count(file) > 1:
wf_sub_parser.error("the file \"" + file + "\" from parameter \"" + src_arg + "\" is given "
"several times (on this or another argument)")
else:
print("\033[93mWarning: rule unique_all is ignored: " + src_arg + " is not an input file or input file "
"list\033[0m")
# Rule: Exclude
elif rule.startswith("exclude="):
match = re.match(r"exclude=(.+)", rule)
if match:
excludes = match.group(1).split(",")
for exclude in excludes:
if exclude in user_args and user_args[exclude] is not None:
wf_sub_parser.error("arguments " + src_arg + " and " + exclude + " are mutually excluded")
else:
print("\033[93mWarning: unrecognized exclude list: " + rule + "\033[0m")
# Rule: Exclude if
elif rule.startswith("exclude_if"):
if not isinstance(parameters[src_arg], InputFile) and not isinstance(parameters[src_arg], InputFileList) and \
not isinstance(parameters[src_arg], InputDirectory):
match = re.match(r"exclude_if\[([^\]]+)\]=(.+)", rule)
if match:
conditions = match.group(1).split(",")
excludes = match.group(2).split(",")
condition_raised = None
for condition in conditions:
if (condition[0] == "!" and user_args[src_arg] != condition[1:]) or (condition[0] != "!" and
str(user_args[src_arg]) == str(condition)):
condition_raised = condition
break
if condition_raised is not None:
for exclude in excludes:
if exclude in user_args and user_args[exclude] is not None:
if not condition_raised.startswith("!"):
wf_sub_parser.error("argument " + src_arg + " is set to " + condition_raised + ", so the " + \
exclude + " argument is not allowed")
else:
wf_sub_parser.error("argument " + src_arg + " is not set to " + condition_raised[1:] + \
", so the " + exclude + " argument is not allowed")
else:
print("\033[93mWarning: unrecognized conditional exclude list: " + rule + "\033[0m")
else:
print("\033[93mWarning: rule exclude_if is not accepted for inputs files/directories. "
"The rule has been ignored\033[0m")
# Rule: To be required
elif rule.startswith("to_be_required="):
match = re.match(r"to_be_required=(.+)", rule)
if match:
requires = match.group(1).split(",")
for require in requires:
if require not in user_args or (require in user_args and user_args[require] is None):
wf_sub_parser.error("the argument " + src_arg + " require argument " + require + " to be defined")
else:
print("\033[93mWarning: unrecognized to_be_required list: " + rule + "\033[0m")
# Rule: To be required if:
elif rule.startswith("to_be_required_if"):
match = re.match(r"to_be_required_if\[([^\]]+)\]=(.+)", rule)
if match:
conditions = match.group(1).split(",")
requires = match.group(2).split(",")
condition_raised = None
for condition in conditions:
if (condition[0] == "!" and user_args[src_arg] != condition[1:]) or (condition[0] != "!" and
str(user_args[src_arg]) == str(condition)):
condition_raised = condition
break
if condition_raised is not None:
for require in requires:
if require not in user_args or (require in user_args and user_args[require] is None):
if not condition_raised.startswith("!"):
wf_sub_parser.error("the argument " + src_arg + " is set to " + condition_raised +
", so it require argument " + require + " to be defined")
else:
wf_sub_parser.error("the argument " + src_arg + " is not set to " + condition_raised[1:] +
", so it require argument " + require + " to be defined")
else:
print("\033[93mWarning: unrecognized rule: " + rule + "\033[0m")
def parse_parameters_rules(wf_class, wf_manager):
from jflow.parameter import InputFile, InputFileList, MultiParameterList
# Get users arguments:
arg_parser = JflowArgumentParser()
wf_instance = wf_manager.get_workflow_by_class(wf_class)
arg_subparsers = arg_parser.add_subparsers(title='Available sub commands')
arg_sub_parser = arg_subparsers.add_parser(wf_instance.name, help=wf_instance.description, fromfile_prefix_chars='@')
arg_sub_parser.convert_arg_line_to_args = wf_instance.__class__.config_parser
parameters = wf_instance.get_parameters()
for parameter in parameters:
arg_sub_parser.add_argument(parameter.flag, **parameter.export_to_argparse(True))
user_params = vars(arg_parser.parse_args())
# Get rules:
rules = {}
all_files = [] # Store all given files, used later
parameters_used = {} # Parameters given by the user
parameters_dict = {} # All parameters of the workflow
for parameter in parameters:
parameters_dict[parameter.name] = parameter
# Get sub-parameters of multiparameter lists:
if isinstance(parameter, MultiParameterList):
parameters_used[parameter.name] = {}
# Get parameters given by the user:
for rows in user_params[parameter.name]:
for item in rows:
p_item = item[0].replace("-","_")
parameter_name = parameter.name + ">" + p_item # Name of the parameter to store in parameters_used
if parameter_name not in parameters_used:
parameters_used[parameter_name] = []
parameters_used[parameter_name].append(item[1])
# Get all parameters and check rules for the ones given by the user:
for sub_param in parameter.sub_parameters:
parameter_name = parameter.name + ">" + sub_param.name
parameters_dict[parameter_name] = sub_param
if parameter_name in parameters_used:
if sub_param.rules is not None:
rules[parameter_name] = sub_param.rules.split(";")
if isinstance(sub_param, InputFile):
all_files += parameters_used[parameter_name]
# Other parameters:
elif parameter.name in user_params and user_params[parameter.name] is not None:
parameters_used[parameter.name] = user_params[parameter.name]
if parameter.rules is not None:
rules[parameter.name] = parameter.rules.split(";")
if isinstance(parameter, InputFile):
all_files.append(user_params[parameter.name])
elif isinstance(parameter, InputFileList):
all_files += user_params[parameter.name]
# Check rules:
for src_arg, arg_rules in rules.items():
for arg_rule in arg_rules:
_check_rule(arg_rule, src_arg, parameters_used, parameters_dict, all_files, arg_sub_parser)
if __name__ == '__main__':
# Create a workflow manager to get access to our workflows
......@@ -117,6 +288,7 @@ if __name__ == '__main__':
sub_parser = subparsers.add_parser(instance.name, help=instance.description, fromfile_prefix_chars='@')
sub_parser.convert_arg_line_to_args = instance.__class__.config_parser
[parameters_groups, parameters_order] = instance.get_parameters_per_groups()
print(parameters_order)
for group in parameters_order:
if group == "default":
for param in parameters_groups[group]:
......@@ -137,12 +309,13 @@ if __name__ == '__main__':
pgroup.add_argument(param.flag, **param.export_to_argparse())
sub_parser.set_defaults(cmd_object=instance.__class__.__name__)
args = vars(parser.parse_args())
if not "cmd_object" in args:
print(parser.format_help())
parser.exit(0, "")
if args["cmd_object"] in wf_classes:
parse_parameters_rules(args["cmd_object"], wfmanager)
wfmanager.run_workflow(args["cmd_object"], args)
elif args["cmd_object"] == "rerun":
wfmanager.rerun_workflow(args["workflow_id"])
......
......@@ -335,7 +335,7 @@ class AbstractParameter(object):
def __init__(self, name, help, default=None, type=str, choices=None, required=False,
flag=None, action="store", sub_parameters=None, group="default", display_name=None,
cmd_format="", argpos=-1):
cmd_format="", argpos=-1, rules=None):
self.name = name
self.help = help
......@@ -355,6 +355,7 @@ class AbstractParameter(object):
self.choices = choices
self.argpos = argpos
self.cmd_format = cmd_format
self.rules = rules
# Set parameter type
if type == "date":
......@@ -375,7 +376,7 @@ class AbstractParameter(object):
else:
self.default = default
def export_to_argparse(self):
def export_to_argparse(self, disable_default=False):
if self.type == bool and str(self.default).lower() in (False, "false", "f", "0"):
return {"help": self.help, "required": self.required, "dest": self.name,
"default": False, "action": "store_true"}
......@@ -384,11 +385,11 @@ class AbstractParameter(object):
"default": True, "action": "store_false"}
elif self.nargs != None:
return {"type": self.get_test_function(), "help": self.help, "required": self.required,
"dest": self.name, "default": self.default,
"dest": self.name, "default": self.default if not disable_default else None,
"action": self.action, "choices": self.choices, "nargs": self.nargs}
else:
return {"type": self.get_test_function(), "help": self.help, "required": self.required,
"dest": self.name, "default": self.default,
"dest": self.name, "default": self.default if not disable_default else None,
"action": self.action, "choices": self.choices}
def get_type(self):
......@@ -544,7 +545,8 @@ def none_decorator(fn):
class BoolParameter(int, AbstractParameter):
def __new__(self, name, help, default=False, type=bool, choices=None, required=False,
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1):
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1,
rules=None):
bool_default = True
if default == None or default in [False, 0]:
......@@ -562,9 +564,10 @@ class BoolParameter(int, AbstractParameter):
return val
def __init__(self, name, help, default=None, type=bool, choices=None, required=False,
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1):
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1,
rules = None):
AbstractParameter.__init__(self, name, help, flag=flag, default=bool(default), type=type, choices=choices, required=required,
action="store", sub_parameters=sub_parameters, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos)
action="store", sub_parameters=sub_parameters, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos, rules=rules)
def __getnewargs__(self):
return (self.name, self.help, self.default, self.type, self.choices, self.required, self.flag,
......@@ -599,7 +602,8 @@ class BoolParameter(int, AbstractParameter):
class IntParameter(int, AbstractParameter):
def __new__(self, name, help, default=None, type=int, choices=None, required=False,
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1):
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1,
rules=None):
int_default = 0 if default == None else int(default)
val = int.__new__(self, int_default)
val.is_None = False if default != None else True
......@@ -611,9 +615,10 @@ class IntParameter(int, AbstractParameter):
return val
def __init__(self, name, help, default=None, type=int, choices=None, required=False,
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1):
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1,
rules=None):
AbstractParameter.__init__( self, name, help, flag=flag, default=default, type=type, choices=choices, required=required,
action="store", sub_parameters=sub_parameters, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos)
action="store", sub_parameters=sub_parameters, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos, rules=rules)
def __getnewargs__(self):
return (self.name, self.help, self.default, self.type, self.choices, self.required, self.flag,
......@@ -648,7 +653,8 @@ class IntParameter(int, AbstractParameter):
class FloatParameter(float, AbstractParameter):
def __new__(self, name, help, default=None, type=float, choices=None, required=False,
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1):
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1,
rules=None):
float_default = 0.0 if default == None else float(default)
val = float.__new__(self, float_default)
val.is_None = False if default != None else True
......@@ -660,9 +666,10 @@ class FloatParameter(float, AbstractParameter):
return val
def __init__(self, name, help, default=None, type=float, choices=None, required=False,
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1):
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1,
rules=None):
AbstractParameter.__init__(self, name, help, flag=flag, default=default, type=type, choices=choices, required=required,
action="store", sub_parameters=sub_parameters, group=group, display_name=display_name,cmd_format=cmd_format, argpos=argpos )
action="store", sub_parameters=sub_parameters, group=group, display_name=display_name,cmd_format=cmd_format, argpos=argpos, rules=rules )
def __getnewargs__(self):
return (self.name, self.help, self.default, self.type, self.choices, self.required, self.flag,
......@@ -697,7 +704,8 @@ class FloatParameter(float, AbstractParameter):
class StrParameter(str, AbstractParameter):
def __new__(self, name, help, default=None, type=str, choices=None, required=False,
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1):
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1,
rules=None):
str_default = "" if default == None else str(default)
val = str.__new__(self, str_default)
val.is_None = False if default != None else True
......@@ -709,9 +717,10 @@ class StrParameter(str, AbstractParameter):
return val
def __init__(self, name, help, default=None, type=str, choices=None, required=False,
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1):
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1,
rules=None):
AbstractParameter.__init__(self, name, help, flag=flag, default=default, type=type, choices=choices, required=required,
action="store", sub_parameters=sub_parameters, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos)
action="store", sub_parameters=sub_parameters, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos, rules=rules)
def __getnewargs__(self):
return (self.name, self.help, self.default, self.type, self.choices, self.required, self.flag,
......@@ -746,14 +755,17 @@ class StrParameter(str, AbstractParameter):
class PasswordParameter(StrParameter):
def __new__(self, name, help, default=None, type="password", choices=None, required=False,
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1):
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1,
rules=None):
return StrParameter.__new__(self, name, help, flag=flag, default=default, type=type, choices=choices,
required=required, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos)
required=required, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos,
rules=rules)
def __init__(self, name, help, default=None, type="password", choices=None, required=False,
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1):
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1,
rules=None):
StrParameter.__init__(self, name, help, flag=flag, default=default, type=type, choices=choices, required=required,
sub_parameters=sub_parameters, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos)
sub_parameters=sub_parameters, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos, rules=rules)
@staticmethod
def __rc4(data, key):
......@@ -795,7 +807,8 @@ class PasswordParameter(StrParameter):
class DateParameter(datetime.datetime, AbstractParameter):
def __new__(self, name, help, default=None, type=date, choices=None, required=False,
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1):
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1,
rules=None):
date_default = datetime.datetime.today()
if default != None and issubclass(default.__class__, datetime.datetime):
date_default = default
......@@ -811,12 +824,13 @@ class DateParameter(datetime.datetime, AbstractParameter):
return val
def __init__(self, name, help, default=None, type=date, choices=None, required=False,
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1):
flag=None, sub_parameters=None, group="default", display_name=None, cmd_format="", argpos=-1,
rules=None):
if default != None and not issubclass(default.__class__, datetime.datetime):
date_default = date(default)
default = datetime.datetime(date_default.year, date_default.month, date_default.day)
AbstractParameter.__init__(self, name, help, flag=flag, default=default, type=type, choices=choices, required=required,
action="store", sub_parameters=sub_parameters, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos)
action="store", sub_parameters=sub_parameters, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos, rules=rules)
def __getnewargs__(self):
return (self.name, self.help, self.default, self.type, self.choices, self.required, self.flag,
......@@ -861,15 +875,17 @@ def input_directory_get_files_fn(input):
class InputDirectory(StrParameter, LinkTraceback):
def __new__(self, name, help, default="", choices=None, required=False, flag=None,
group="default", display_name=None, get_files_fn=None, cmd_format="", argpos=-1):
group="default", display_name=None, get_files_fn=None, cmd_format="", argpos=-1, rules=None):
return StrParameter.__new__(self, name, help, flag=flag, default=default, type="inputdirectory", choices=choices,
required=required, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos)
required=required, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos,
rules=rules)
def __init__(self, name, help, default="", choices=None, required=False, flag=None,
group="default", display_name=None, get_files_fn=None, cmd_format="", argpos=-1):
group="default", display_name=None, get_files_fn=None, cmd_format="", argpos=-1, rules=None):
LinkTraceback.__init__(self)
StrParameter.__init__(self, name, help, flag=flag, default=default, type="inputdirectory", choices=choices,
required=required, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos)
required=required, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos,
rules=rules)
if hasattr(get_files_fn, "__call__"):
self.get_files_fn = get_files_fn
else:
......@@ -877,7 +893,7 @@ class InputDirectory(StrParameter, LinkTraceback):
def __getnewargs__(self):
return (self.name, self.help, self.default, self.choices, self.required, self.flag,
self.group, self.display_name, self.get_files_fn, self.cmd_format, self.argpos)
self.group, self.display_name, self.get_files_fn, self.cmd_format, self.argpos, self.rules)
def prepare(self, input):
if input == None:
......@@ -949,7 +965,8 @@ class AbstractOutputFile(AbstractIOFile):
class InputFile(StrParameter, AbstractInputFile):
def __new__(self, name, help, file_format="any", default="", type="localfile", choices=None,
required=False, flag=None, group="default", display_name=None, size_limit="0", cmd_format="", argpos=-1):
required=False, flag=None, group="default", display_name=None, size_limit="0", cmd_format="", argpos=-1,
rules=None):
if hasattr(type, '__call__'):
type2test = type.__name__
else: type2test = type
......@@ -959,19 +976,22 @@ class InputFile(StrParameter, AbstractInputFile):
+ "', '".join(INPUTFILE_TYPES)+"'")
return StrParameter.__new__(self, name, help, flag=flag, default=default, type=type, choices=choices,
required=required, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos)
required=required, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos,
rules=rules)
def __init__(self, name, help, file_format="any", default="", type="localfile", choices=None,
required=False, flag=None, group="default", display_name=None, size_limit="0", cmd_format="", argpos=-1):
required=False, flag=None, group="default", display_name=None, size_limit="0", cmd_format="", argpos=-1,
rules=None):
AbstractInputFile.__init__(self, file_format, size_limit)
if issubclass(default.__class__, list):
raise Exception( "The parameter '" + name + "' cannot be set with a list." )
StrParameter.__init__(self, name, help, flag=flag, default=default, type=type, choices=choices,
required=required, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos)
required=required, group=group, display_name=display_name, cmd_format=cmd_format, argpos=argpos,
rules=rules)
def __getnewargs__(self):
return (self.name, self.help, self.file_format, self.default, self.type, self.choices, self.required,
self.flag, self.group, self.display_name, self.size_limit, self.cmd_format, self.argpos)
self.flag, self.group, self.display_name, self.size_limit, self.cmd_format, self.argpos, self.rules)
def get_type(self):
return self.type.__name__+AbstractInputFile.SIZE_LIMIT_SPLITER+self.size_limit
......@@ -1044,19 +1064,19 @@ class ParameterList(list, AbstractParameter):
def __init__(self, name, help, default=None, type=str, choices=None, required=False,
flag=None, sub_parameters=None, group="default", display_name=None,
cmd_format="", argpos=-1):
cmd_format="", argpos=-1, rules=None):
if default == None: default = []
AbstractParameter.__init__(self, name, help, flag=flag, default=default, type=type, choices=choices, required=required,
action="append", sub_parameters=sub_parameters, group=group, display_name=display_name,
cmd_format=cmd_format, argpos=argpos)
cmd_format=cmd_format, argpos=argpos, rules=rules)
liste = []
if isinstance( default, list ):
for val in default :
liste.append(ParameterFactory.factory( name, help, default=val, type=type, choices=choices,
required=required, flag=flag, group=group, display_name=display_name ))
required=required, flag=flag, group=group, display_name=display_name, rules=rules ))
else :
liste.append(ParameterFactory.factory( name, help, default=default, type=type, choices=choices,
required=required, flag=flag, group=group, display_name=display_name ))
required=required, flag=flag, group=group, display_name=display_name, rules=rules ))
return list.__init__(self, liste)
def append(self, item):
......@@ -1070,7 +1090,7 @@ class InputFileList(ParameterList, AbstractInputFile):
def __init__(self, name, help, file_format="any", default=None, type="localfile", choices=None,
required=False, flag=None, group="default", display_name=None, size_limit="0",
cmd_format="", argpos=-1):
cmd_format="", argpos=-1, rules=None):
if default == None: default = []
if hasattr(type, '__call__'):
......@@ -1088,7 +1108,7 @@ class InputFileList(ParameterList, AbstractInputFile):
AbstractInputFile.__init__(self, file_format, size_limit)
ParameterList.__init__(self, name, help, flag=flag, default=default, type=type, choices=choices,
required=required, group=group, display_name=display_name,
cmd_format=cmd_format, argpos=argpos)
cmd_format=cmd_format, argpos=argpos, rules=rules)
if default.__class__.__name__ == "str":
return list.__init__(self, [default])
......
......@@ -172,9 +172,9 @@ class Workflow(threading.Thread):
return self.__group
def add_input_directory(self, name, help, default=None, required=False, flag=None,
group="default", display_name=None, get_files_fn=None, add_to=None):
group="default", display_name=None, get_files_fn=None, add_to=None, rules=None):
new_param = InputDirectory(name, help, flag=flag, default=default, required=required,
group=group, display_name=display_name, get_files_fn=get_files_fn)
group=group, display_name=display_name, get_files_fn=get_files_fn, rules=rules)
new_param.linkTrace_nameid = name
# if this input should be added to a particular parameter
if add_to:
......@@ -187,12 +187,14 @@ class Workflow(threading.Thread):
self.__setattr__(name, new_param)
def add_input_file(self, name, help, file_format="any", default=None, type="inputfile",
required=False, flag=None, group="default", display_name=None, size_limit="0", add_to=None):
required=False, flag=None, group="default", display_name=None, size_limit="0", add_to=None,
rules=None):
# check if the size provided is correct
try: int(get_nb_octet(size_limit))
except: size_limit="0"
new_param = InputFile(name, help, flag=flag, file_format=file_format, default=default,
type=type, required=required, group=group, display_name=display_name, size_limit=size_limit)
type=type, required=required, group=group, display_name=display_name, size_limit=size_limit,
rules=rules)
new_param.linkTrace_nameid = name
# if this input should be added to a particular parameter
if add_to:
......@@ -205,7 +207,8 @@ class Workflow(threading.Thread):
self.__setattr__(name, new_param)
def add_input_file_list(self, name, help, file_format="any", default=None, type="inputfile",
required=False, flag=None, group="default", display_name=None, size_limit="0", add_to=None):
required=False, flag=None, group="default", display_name=None, size_limit="0", add_to=None,
rules=None):
# check if the size provided is correct
if default == None: default = []
try: int(get_nb_octet(size_limit))
......@@ -217,7 +220,8 @@ class Workflow(threading.Thread):
else:
inputs = [IOFile(default, file_format, name, None)]
new_param = InputFileList(name, help, flag=flag, file_format=file_format, default=inputs,
type=type, required=required, group=group, display_name=display_name, size_limit=size_limit)
type=type, required=required, group=group, display_name=display_name, size_limit=size_limit,
rules=rules)
new_param.linkTrace_nameid = name
# if this input should be added to a particular parameter
if add_to:
......@@ -240,9 +244,9 @@ class Workflow(threading.Thread):
self.__setattr__(name, new_param)
def add_parameter(self, name, help, default=None, type=str, choices=None,
required=False, flag=None, group="default", display_name=None, add_to=None):
required=False, flag=None, group="default", display_name=None, add_to=None, rules=None):
new_param = ParameterFactory.factory(name, help, flag=flag, default=default, type=type, choices=choices,
required=required, group=group, display_name=display_name)
required=required, group=group, display_name=display_name, rules=rules)
# if this input should be added to a particular parameter
if add_to:
try:
......@@ -254,10 +258,10 @@ class Workflow(threading.Thread):
self.__setattr__(name, new_param)
def add_parameter_list(self, name, help, default=None, type=str, choices=None,
required=False, flag=None, group="default", display_name=None, add_to=None):
required=False, flag=None, group="default", display_name=None, add_to=None, rules=None):
if default == None: default = []
new_param = ParameterList(name, help, flag=flag, default=default, type=type, choices=choices,
required=required, group=group, display_name=display_name)
required=required, group=group, display_name=display_name, rules=rules)
# if this input should be added to a particular parameter
if add_to:
try:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment