Commit f8933ac2 authored by Janez K's avatar Janez K
Browse files

stream procesiranje subworkflowov, manjkajo se for loopi

parent 8da73603
...@@ -11,22 +11,13 @@ class Stream(models.Model): ...@@ -11,22 +11,13 @@ class Stream(models.Model):
last_executed = models.DateTimeField(auto_now_add=True) last_executed = models.DateTimeField(auto_now_add=True)
period = models.IntegerField(default=60) period = models.IntegerField(default=60)
def execute(self,workflow=None): def execute(self,workflow=None,outputs={}):
if workflow is None: if workflow is None:
workflow = self.workflow workflow = self.workflow
outputs = {}
inputs = {}
finished = [] finished = []
ready_to_run = [] ready_to_run = []
widgets = workflow.widgets.all() widgets = workflow.widgets.all()
# prepare all outputs and fetch parameter values
for w in widgets:
inputs[w.pk] = {}
for i in w.inputs.all():
if i.parameter:
inputs[w.pk][i.variable]=i.value
#get unfinished #get unfinished
unfinished_list = [] unfinished_list = []
loop = True loop = True
...@@ -34,24 +25,26 @@ class Stream(models.Model): ...@@ -34,24 +25,26 @@ class Stream(models.Model):
for w in unfinished_list: for w in unfinished_list:
# prepare all the inputs for this widget # prepare all the inputs for this widget
input_dict = {} input_dict = {}
output_dict = {}
for i in w.inputs.all():
#gremo pogledat ce obstaja povezava in ce obstaja gremo value prebrat iz outputa
if not i.parameter:
if i.connections.count() > 0:
#preberemo value iz output_dicta
i.value = outputs[i.connections.all()[0].output.pk][1]
else:
i.value = None
if i.multi_id == 0:
input_dict[i.variable]=i.value
else:
if not i.variable in input_dict:
input_dict[i.variable]=[]
if not i.value==None:
input_dict[i.variable].append(i.value)
if w.type == 'regular': if w.type == 'regular':
function_to_call = getattr(workflows.library,w.abstract_widget.action) function_to_call = getattr(workflows.library,w.abstract_widget.action)
for i in w.inputs.all():
#gremo pogledat ce obstaja povezava in ce obstaja gremo value prebrat iz outputa
if not i.parameter:
if i.connections.count() > 0:
#preberemo value iz output_dicta
i.value = outputs[i.connections.all()[0].output.pk][1]
else:
i.value = None
if i.multi_id == 0:
input_dict[i.variable]=i.value
else:
if not i.variable in input_dict:
input_dict[i.variable]=[]
if not i.value==None:
input_dict[i.variable].append(i.value)
if w.abstract_widget.wsdl != '': if w.abstract_widget.wsdl != '':
input_dict['wsdl']=w.abstract_widget.wsdl input_dict['wsdl']=w.abstract_widget.wsdl
input_dict['wsdl_method']=w.abstract_widget.wsdl_method input_dict['wsdl_method']=w.abstract_widget.wsdl_method
...@@ -60,11 +53,17 @@ class Stream(models.Model): ...@@ -60,11 +53,17 @@ class Stream(models.Model):
else: else:
output_dict = function_to_call(input_dict) output_dict = function_to_call(input_dict)
for o in w.outputs.all():
outputs[o.pk]=(o.variable,output_dict[o.variable])
if w.type == 'subprocess': if w.type == 'subprocess':
pass new_outputs = self.execute(workflow=w.workflow_link,outputs=outputs)
for o in w.outputs.all():
value = None
try:
if o.inner_input.connections.count() > 0:
value = new_outputs[o.inner_input.connections.all()[0].output.pk][1]
except:
value = None
output_dict[o.variable]=value
if w.type == 'for_input': if w.type == 'for_input':
pass pass
...@@ -73,10 +72,20 @@ class Stream(models.Model): ...@@ -73,10 +72,20 @@ class Stream(models.Model):
pass pass
if w.type == 'input': if w.type == 'input':
pass for o in w.outputs.all():
value = None
try:
if o.outer_input.connections.count() > 0:
value = outputs[o.outer_input.connections.all()[0].output.pk][1]
except:
value = None
output_dict[o.variable]=value
if w.type == 'output': if w.type == 'output':
pass pass
for o in w.outputs.all():
outputs[o.pk]=(o.variable,output_dict[o.variable])
finished.append(w.pk) finished.append(w.pk)
unfinished_list = [] unfinished_list = []
......
...@@ -429,7 +429,7 @@ class Widget(models.Model): ...@@ -429,7 +429,7 @@ class Widget(models.Model):
else: else:
if self.workflow_link.is_for_loop(): if self.workflow_link.is_for_loop():
self.workflow_link.run_for_loop() self.workflow_link.run_for_loop()
print self.outputs.all()[0].value #print self.outputs.all()[0].value
else: else:
self.workflow_link.run() self.workflow_link.run()
except: except:
......
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