Commit 92315371 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Improve code

parent 48338329
......@@ -57,23 +57,12 @@ class JflowArgumentParser (argparse.ArgumentParser):
return new_arg_strings
def parse_parameters_rules(wf_instance):
# Get users arguments:
arg_parser = JflowArgumentParser()
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())
def parse_parameters_rules(wf_instance, user_params):
# Check rules:
try:
wf_instance.check_parameters_rules(user_params)
except Exception as e:
arg_sub_parser.error(e)
sub_parser.error(e)
if __name__ == '__main__':
......@@ -165,7 +154,7 @@ if __name__ == '__main__':
if args["cmd_object"] in wf_classes:
workflow = wfmanager.get_workflow_by_class(args["cmd_object"])
parse_parameters_rules(workflow)
parse_parameters_rules(workflow, args)
wfmanager.run_workflow(args["cmd_object"], args)
elif args["cmd_object"] == "rerun":
wfmanager.rerun_workflow(args["workflow_id"])
......
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