Commit be9b000f authored by Stanislav Bohm's avatar Stanislav Bohm

ENH: Python decorator tasks.py_task

parent 903e1fe5
......@@ -166,3 +166,10 @@ def py_call(obj, inputs=(), request=cpu1):
task.inputs = inputs
task.config = cloudpickle.dumps(obj)
return task
def py_task():
def make_py_call(fn):
assert callable(fn)
return lambda *args: py_call(fn, args)
return make_py_call
......@@ -27,6 +27,24 @@ def test_py_call(loom_env):
assert result2 == b"Test"
def test_py_task(loom_env):
@tasks.py_task()
def t1():
return "ABC"
@tasks.py_task()
def t2(a, b):
return a.read() + b.read()
loom_env.start(1)
a = tasks.const("1234")
b = t1()
c = t2(a, b)
result = loom_env.submit(c)
assert result == b"1234ABC"
def test_py_redirect1(loom_env):
def f(a, b):
......
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