Commit 33743417 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

add input directory

parent f18d34dc
......@@ -152,10 +152,12 @@ if __name__ == '__main__':
gr = workflow.get_execution_graph()
inputs, components = [], []
for node in gr.nodes():
if Workflow.INPUT_GRAPH_LABEL in gr.node_attributes(node):
if Workflow.INPUTFILE_GRAPH_LABEL in gr.node_attributes(node):
inputs.append(gr.node_attributes(node)[1])
elif Workflow.INPUTFILES_GRAPH_LABEL in gr.node_attributes(node):
inputs.append(gr.node_attributes(node)[1])
elif Workflow.INPUTDIRECTORY_GRAPH_LABEL in gr.node_attributes(node):
inputs.append(gr.node_attributes(node)[1])
elif Workflow.INPUTS_GRAPH_LABEL in gr.node_attributes(node):
inputs.append(gr.node_attributes(node)[1])
elif Workflow.COMPONENT_GRAPH_LABEL in gr.node_attributes(node):
components.append(gr.node_attributes(node)[1])
print "inputs: ", inputs
......
......@@ -411,10 +411,12 @@ class JFlowServer (object):
status = self.jsonify_workflow_status(workflow)
nodes = []
for node in g.nodes():
if Workflow.INPUT_GRAPH_LABEL in g.node_attributes(node):
nodes.append({"name": node, "display_name": g.node_attributes(node)[1], "type": "input"})
elif Workflow.INPUTS_GRAPH_LABEL in g.node_attributes(node):
nodes.append({"name": node, "display_name": g.node_attributes(node)[1], "type": "inputs"})
if Workflow.INPUTFILE_GRAPH_LABEL in g.node_attributes(node):
nodes.append({"name": node, "display_name": g.node_attributes(node)[1], "type": "inputfile"})
elif Workflow.INPUTFILES_GRAPH_LABEL in g.node_attributes(node):
nodes.append({"name": node, "display_name": g.node_attributes(node)[1], "type": "inputfiles"})
elif Workflow.INPUTDIRECTORY_GRAPH_LABEL in g.node_attributes(node):
nodes.append({"name": node, "display_name": g.node_attributes(node)[1], "type": "inputdirectory"})
elif Workflow.COMPONENT_GRAPH_LABEL in g.node_attributes(node):
nodes.append({"name": node, "display_name": g.node_attributes(node)[1], "type": "component"})
status["nodes"] = nodes
......
......@@ -68,6 +68,24 @@ class Component(object):
outputs[os.path.basename(attribute_value)] = attribute_value
return outputs
def add_input_directory(self, name, help, default=None, required=False, flag=None, group="default",
display_name=None, add_to=None, cmd_format="", argpos=-1):
new_param = InputDirectory(name, help, flag=flag, default=default, required=required, group=group,
display_name=display_name, cmd_format=cmd_format, argpos=argpos)
# store where the parameter is coming from
new_param.linkTrace_nameid = self.get_nameid()
if issubclass( default.__class__, LinkTraceback ):
new_param.parent_linkTrace_nameid = [default.linkTrace_nameid]
# if this input should be added to a particular parameter
if add_to:
try:
self.__getattribute__(add_to).add_sub_parameter(new_param)
except: pass
# otherwise, add it to the class itself
else:
self.params_order.append(name)
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, add_to=None,
cmd_format="", argpos=-1):
......
......@@ -41,6 +41,12 @@ from workflows.formats import *
INPUTFILE_TYPES = ["inputfile", "localfile", "urlfile", "browsefile"]
INPUTFILES_TYPES = ["inputfiles", "localfile", "urlfile", "browsefile", "regexpfiles"]
def inputdirectory(directory):
if os.path.isdir(directory):
return directory
else:
raise argparse.ArgumentTypeError("'" + directory + "' is not a valid directory!")
def browsefile(file):
# browsefile are not available from command line, considere it as a localfile
# from the gui, this will not been tested this way
......@@ -50,7 +56,7 @@ def localfile(file):
if os.path.isfile(file):
return file
else:
raise argparse.ArgumentTypeError("File '" + file + "' does not exists! Please provide a valid file path!")
raise argparse.ArgumentTypeError("'" + file + "' is not a valid file!")
def urlfile(file):
uri_object = urlparse(file)
......@@ -738,6 +744,18 @@ class DateParameter(datetime.datetime, AbstractParameter):
return (DateParameter, (self.name, self.help, self.default, date, self.choices, self.required,
self.flag, self.sub_parameters, self.group, self.display_name), None, None, None)
class InputDirectory(StrParameter, LinkTraceback):
def __new__(self, name, help, default="", choices=None, required=False, flag=None,
group="default", display_name=None, cmd_format="", argpos=-1):
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)
def __init__(self, name, help, default="", choices=None, required=False, flag=None,
group="default", display_name=None, cmd_format="", argpos=-1):
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)
class AbstractInputFile(AbstractIOFile):
"""
......
......@@ -98,8 +98,9 @@ class Workflow(threading.Thread):
STATUS_ABORTED = "aborted"
STATUS_RESETED = "reseted"
INPUT_GRAPH_LABEL = "input"
INPUTS_GRAPH_LABEL = "inputs"
INPUTFILE_GRAPH_LABEL = "inputfile"
INPUTFILES_GRAPH_LABEL = "inputfiles"
INPUTDIRECTORY_GRAPH_LABEL = "inputdirectory"
COMPONENT_GRAPH_LABEL = "component"
......@@ -154,8 +155,24 @@ class Workflow(threading.Thread):
if self.stderr is None:
self.stderr = self._set_stderr()
self._serialize()
self.comp_pckg = self._import_components()
def add_input_directory(self, name, help, default=None, required=False, flag=None,
group="default", display_name=None, add_to=None):
new_param = InputDirectory(name, help, flag=flag, default=default,
required=required, group=group, display_name=display_name)
new_param.linkTrace_nameid = name
# if this input should be added to a particular parameter
if add_to:
try:
self.__getattribute__(add_to).add_sub_parameter(new_param)
except: pass
# otherwise, add it to the class itself
else:
self.params_order.append(name)
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):
# check if the size provided is correct
......@@ -304,6 +321,12 @@ class Workflow(threading.Thread):
type=parameter.type, choices=parameter.choices, required=parameter.required, flag=parameter.flag,
group=parameter.group, display_name=parameter.display_name )
new_param.linkTrace_nameid = parameter.linkTrace_nameid
elif parameter.__class__ == InputDirectory:
if value == "" : value = None # from GUI
new_param = InputDirectory( parameter.name, parameter.help, default=value, choices=parameter.choices,
required=parameter.required, flag=parameter.flag, group=parameter.group,
display_name=parameter.display_name )
new_param.linkTrace_nameid = parameter.linkTrace_nameid
else:
raise Exception( "Unknown class '" + parameter.__class__.__name__ + "' for parameter.")
return new_param
......@@ -345,12 +368,17 @@ class Workflow(threading.Thread):
for ioparameter in self.__dict__.values():
if issubclass(ioparameter.__class__, InputFile):
gr.add_node(ioparameter.name)
gr.add_node_attribute(ioparameter.name, self.INPUT_GRAPH_LABEL)
gr.add_node_attribute(ioparameter.name, self.INPUTFILE_GRAPH_LABEL)
gr.add_node_attribute(ioparameter.name, ioparameter.display_name)
all_nodes[ioparameter.name] = None
elif issubclass(ioparameter.__class__, InputFileList):
gr.add_node(ioparameter.name)
gr.add_node_attribute(ioparameter.name, self.INPUTS_GRAPH_LABEL)
gr.add_node_attribute(ioparameter.name, self.INPUTFILES_GRAPH_LABEL)
gr.add_node_attribute(ioparameter.name, ioparameter.display_name)
all_nodes[ioparameter.name] = None
elif issubclass(ioparameter.__class__, InputDirectory):
gr.add_node(ioparameter.name)
gr.add_node_attribute(ioparameter.name, self.INPUTDIRECTORY_GRAPH_LABEL)
gr.add_node_attribute(ioparameter.name, ioparameter.display_name)
all_nodes[ioparameter.name] = None
for cpt in self.components:
......@@ -360,7 +388,7 @@ class Workflow(threading.Thread):
all_nodes[cpt.get_nameid()] = None
for cpt in self.components:
for ioparameter in cpt.__dict__.values():
if issubclass( ioparameter.__class__, InputFile ) or issubclass( ioparameter.__class__, InputFileList):
if issubclass( ioparameter.__class__, InputFile ) or issubclass( ioparameter.__class__, InputFileList) or issubclass( ioparameter.__class__, InputDirectory):
for parent in ioparameter.parent_linkTrace_nameid:
try: gr.add_edge((parent, ioparameter.linkTrace_nameid))
except: pass
......
......@@ -13576,7 +13576,7 @@ var cytoscape;
context.lineWidth = tmpLineWidth;
context.font = tmpFont;
}
else if(node._private.data.type == 'input') {
else if(node._private.data.type == 'inputfile') {
var tmpLineWidth = context.lineWidth;
context.beginPath();
context.lineWidth = 2;
......@@ -13627,7 +13627,7 @@ var cytoscape;
context.shadowOffsetY = 0;
context.shadowBlur = 0;
}
else if(node._private.data.type == 'inputs') {
else if(node._private.data.type == 'inputfiles') {
var tmpLineWidth = context.lineWidth;
context.beginPath();
context.lineWidth = 2;
......
......@@ -188,7 +188,7 @@
}
}
for (var i in data.nodes) {
if(data.nodes[i].type == "input" || data.nodes[i].type == "inputs") {
if(data.nodes[i].type == "inputfile" || data.nodes[i].type == "inputfiles" || data.nodes[i].type == "inputdirectory") {
nodes.push({ data: {
id: data.nodes[i].name,
name: data.nodes[i].display_name,
......
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