From 16a74eb6bdcbc0a306a721440bbba5151808fc6e Mon Sep 17 00:00:00 2001
From: Stanislav Bohm <stanislav.bohm@vsb.cz>
Date: Wed, 9 Nov 2016 10:43:08 +0100
Subject: [PATCH] ENH: Labelling of py_task

---
 python/loom/client/tasks.py | 11 +++++++++--
 tests/client/py_test.py     |  6 +++---
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/python/loom/client/tasks.py b/python/loom/client/tasks.py
index de55f69..8a3a4a9 100644
--- a/python/loom/client/tasks.py
+++ b/python/loom/client/tasks.py
@@ -168,8 +168,15 @@ def py_call(obj, inputs=(), request=cpu1):
     return task
 
 
-def py_task():
+def py_task(label=None):
     def make_py_call(fn):
+        def py_task_builder(*args):
+            task = py_call(fn, args)
+            if label is not None:
+                task.label = label
+            else:
+                task.label = fn.__name__
+            return task
         assert callable(fn)
-        return lambda *args: py_call(fn, args)
+        return py_task_builder
     return make_py_call
diff --git a/tests/client/py_test.py b/tests/client/py_test.py
index 9a4319d..967f0b2 100644
--- a/tests/client/py_test.py
+++ b/tests/client/py_test.py
@@ -21,7 +21,7 @@ def test_py_call(loom_env):
     d = tasks.const("12345")
     p = tasks.py_call(f, (c, d))
     q = tasks.py_call(g)
-    result1, result2 = loom_env.submit((p, q), "report")
+    result1, result2 = loom_env.submit((p, q))
 
     assert result1 == b"ABC, 3, 12345, 5"
     assert result2 == b"Test"
@@ -33,7 +33,7 @@ def test_py_task(loom_env):
     def t1():
         return "ABC"
 
-    @tasks.py_task()
+    @tasks.py_task(label="Merging task")
     def t2(a, b):
         return a.read() + b.read()
 
@@ -41,7 +41,7 @@ def test_py_task(loom_env):
     a = tasks.const("1234")
     b = t1()
     c = t2(a, b)
-    result = loom_env.submit(c)
+    result = loom_env.submit(c, "report")
     assert result == b"1234ABC"
 
 
-- 
GitLab