Commit 7604ea07 authored by Jerome Mariette's avatar Jerome Mariette

add choices availibilitt for parameters

parent 3cdeb73c
......@@ -42,7 +42,7 @@ if __name__ == '__main__':
sub_parser.add_argument(param.flag, type=param.type, help=param.help,
required=param.required, dest=param.name,
metavar=param.metavar, default=param.default,
action=param.action)
action=param.action, choices=param.choices)
sub_parser.set_defaults(cmd_object=instance)
args = vars(parser.parse_args())
......
......@@ -71,9 +71,11 @@ class WorkflowConfigReader(object):
except: required = False
try: action = params[param]["action"]
except: action = "store"
try: choices = params[param]["choices"].split("|")
except: choices = None
oparam = Parameter(name=name, flag=flag, help=help, default=default,
type=type, required=required, metavar=metavar,
action=action)
action=action, choices=choices)
parameters.append(oparam)
except:
pass
......
......@@ -22,12 +22,14 @@ description = add a brand new project
#
# Parameter section
# param.name: the parameter display name
# .option: the parameter argument
# .name: the parameter argument
# .flag: the command line flag to use the argument
# .help: a brief description of what the parameter does
# .default: the value produced if the parameter is not provided
# .type: the parameter type that should be tested (str|int|file|long|bool|...)
# .choices: a container of the allowable values for the parameter
# .required: whether or not the command-line option may be omitted
# .default [None]: the value produced if the parameter is not provided
# .type [str]: the parameter type that should be tested (str|int|file|long|bool|...)
# .choices [None]: a container of the allowable values for the parameter
# .required [False]: whether or not the command-line option may be omitted
# .action [store]: the basic type of action to be taken when this argument is encountered at the command line.
#
[parameters]
name.name = project_name
......
......@@ -16,6 +16,8 @@
#
import datetime
import os
import sys
from jflow.workflow import Workflow
from ng6.project import Project
......@@ -28,14 +30,20 @@ class AddRun (Workflow):
"""
Run the workflow
"""
# First check if files provided exists
files_to_save = []
for file in self.args["data_file"]:
if os.path.isfile(file):
files_to_save.append(file)
else:
sys.exit(2, "error: %s file does not exists\n" % (file))
# Build the project and the run
my_project = Project.get_from_id(self.args["project_id"])
run_date = self.args["run_date"].split("/")
my_run = Run(self.args["run_name"], datetime.date(int(run_date[2]), int(run_date[1]), int(run_date[0])),
self.args["species"], self.args["data_nature"], self.args["type"], self.args["run_description"],
self.args["sequencer"])
print self.args["data_file"]
# archive the files
my_run.archive_files(files_to_save, self.args["archive_mode"])
# Then add the run to the project
my_project.add_run(my_run)
......@@ -22,20 +22,28 @@ description = add a brand new run to a project
#
# Parameter section
# param.name: the parameter display name
# .option: the parameter argument
# .name: the parameter argument
# .flag: the command line flag to use the argument
# .help: a brief description of what the parameter does
# .default: the value produced if the parameter is not provided
# .type: the parameter type that should be tested (str|int|file|long|bool|...)
# .choices: a container of the allowable values for the parameter
# .required: whether or not the command-line option may be omitted
# .default [None]: the value produced if the parameter is not provided
# .type [str]: the parameter type that should be tested (str|int|file|long|bool|...)
# .choices [None]: a container of the allowable values for the parameter
# .required [False]: whether or not the command-line option may be omitted
# .action [store]: the basic type of action to be taken when this argument is encountered at the command line.
#
[parameters]
data_file.name = data_file
data_file.flag = --data-file
data_file.help = Which data files are linked to the run (if multiple, the option should be called as many times as files to add)
data_file.help = Which data files are linked to the run (if multiple, the option should be called as many times as there is file to add)
data_file.required = True
data_file.action = append
archive_mode.name = archive_mode
archive_mode.flag = --archive-mode
archive_mode.help = How should data be compressed once archived (none|gz|bz2)
archive_mode.default = none
archive_mode.choices = none|gz|bz2
project_id.name = project_id
project_id.flag = --project-id
project_id.help = The project id the run belongs to
......
......@@ -22,12 +22,14 @@ description = illumina quality check without reference genome
#
# Parameter section
# param.name: the parameter display name
# .option: the parameter argument
# .name: the parameter argument
# .flag: the command line flag to use the argument
# .help: a brief description of what the parameter does
# .default: the value produced if the parameter is not provided
# .type: the parameter type that should be tested (str|int|file|long|bool|...)
# .choices: a container of the allowable values for the parameter
# .required: whether or not the command-line option may be omitted
# .default [None]: the value produced if the parameter is not provided
# .type [str]: the parameter type that should be tested (str|int|file|long|bool|...)
# .choices [None]: a container of the allowable values for the parameter
# .required [False]: whether or not the command-line option may be omitted
# .action [store]: the basic type of action to be taken when this argument is encountered at the command line.
#
[parameters]
project_id.name = project_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