Commit 7800cfad authored by Jerome Mariette's avatar Jerome Mariette
Browse files

handle from gui custom types

parent 6333adcf
......@@ -22,6 +22,7 @@ from functools import wraps
import time
import os
import argparse
from argparse import ArgumentTypeError
try:
import _preamble
......@@ -31,6 +32,7 @@ except ImportError:
from jflow.workflows_manager import WorkflowsManager
from jflow.config_reader import JFlowConfigReader
from jflow.workflow import Workflow
from workflows.types import *
import jflow.utils as utils
from cctools.util import time_format
......@@ -161,6 +163,20 @@ class JFlowServer (object):
status.append(self.jsonify_workflow_status(workflow))
return status
@cherrypy.expose
@jsonify
def validate_field(self, **kwargs):
try:
value_key = None
for key in kwargs.keys():
if key != "type" and key != "callback" and key != "_":
value_key = key
break
eval(kwargs["type"])(kwargs[value_key])
return True
except Exception, e:
return str(e)
if __name__ == '__main__':
......
......@@ -163,9 +163,21 @@
required: $this.workflow.parameters[i].required,
date: true
}
} else {
} else if ($this.workflow.parameters[i].type == "str") {
rules[$this.workflow.parameters[i].name] = {
required: $this.workflow.parameters[i].required
}
// if it is not a known type, check from the custom ones, using the validate_field address
} else {
rules[$this.workflow.parameters[i].name] = {
required: $this.workflow.parameters[i].required,
remote: {
url: $this.options.serverURL + '/validate_field?callback=?',
type: "post",
data: {
type: $this.workflow.parameters[i].type
}
}
}
}
}
......@@ -205,7 +217,7 @@
template: ['<form id="workflow_form" class="form-horizontal">',
'<fieldset>',
' {{each(index, param) workflow.parameters}}',
// it the parameter has ne already been settled
// it the parameter has not already been settled
' {{if Object.keys(parameters).indexOf(param.name) == -1 }}',
' <div class="control-group">',
' <label class="control-label">${param.display_name}</label>',
......
......@@ -25,7 +25,7 @@ description = align reads against a reference genome
# .flag: the command line flag to use the argument
# .help: a brief description of what the parameter does
# .default [None]: the value produced if the parameter is not provided
# .type [str]: the parameter type that should be tested (str|int|date|file|bool|... all types defined in the types.py package)
# .type [str]: the parameter type that should be tested (str|int|date|localfile|bool|... all types defined in the types.py package)
# .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 (store|append)
......@@ -37,14 +37,17 @@ read_1.name = Read 1
read_1.flag = --read-1
read_1.help = Which read1 files should be used
read_1.required = True
read_1.type = localfile
read_1.action = append
read_2.name = Read 2
read_2.flag = --read-2
read_2.help = Which read2 files should be used (if single end, leave empty)
read_2.type = localfile
read_2.action = append
reference_genome.name = Reference genome
reference_genome.flag = --reference-genome
reference_genome.help = Which genome should the read being align on
reference_genome.type = localfile
reference_genome.required = True
Supports Markdown
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