tasks.py 1.43 KB
Newer Older
1
from celery.task import task
2 3 4 5 6 7 8
import workflows.library

@task()
def add(a,b):
    import time
    time.sleep(10)
    return a+b
9 10 11 12 13

@task()
def runForLoopIteration(workflow,iteration):
    pass

14 15 16 17
@task()
def executeWidgetFunction(widget,input_dict):
    function_to_call = getattr(workflows.library,widget.abstract_widget.action)
    return function_to_call(input_dict)
18 19

@task()
20 21 22
def executeWidgetProgressBar(widget,input_dict):
    function_to_call = getattr(workflows.library,widget.abstract_widget.action)
    return function_to_call(input_dict,widget)
23 24

@task()
25 26 27 28 29 30 31 32 33
def executeWidgetStreaming(widget,input_dict):
    function_to_call = getattr(workflows.library,widget.abstract_widget.action)
    return function_to_call(input_dict,widget,None)

@task()
def executeWidgetWithRequest(widget,input_dict,output_dict,request):
    function_to_call = getattr(workflows.library,widget.abstract_widget.action)
    return function_to_call(request,input_dict,output_dict)

Janez K's avatar
Janez K committed
34 35 36
@task()
def executeWidgetPostInteract(widget,input_dict,output_dict,request):
    function_to_call = getattr(workflows.library,widget.abstract_widget.post_interact_action)
Janez K's avatar
Janez K committed
37
    return function_to_call(request,input_dict,output_dict)
Janez K's avatar
Janez K committed
38 39 40 41 42

@task()
def runWidget(widget,offline):
    widget.proper_run(offline)

43 44
@task()
def runWidgetAsync(widget):
Janez K's avatar
Janez K committed
45 46 47
    widget.run(True)

@task()
Janez K's avatar
Janez K committed
48
def runTest(return_string):
Janez K's avatar
Janez K committed
49 50
    import time
    time.sleep(3.2)
Janez K's avatar
Janez K committed
51
    return return_string