MCPcopy
hub / github.com/dask/dask / task_label

Function task_label

dask/dot.py:12–40  ·  view source on GitHub ↗

Label for a task on a dot graph. Examples -------- >>> from operator import add >>> task_label((add, 1, 2)) 'add' >>> task_label((add, (add, 1, 2), 3)) 'add(...)'

(task)

Source from the content-addressed store, hash-verified

10
11
12def task_label(task):
13 """Label for a task on a dot graph.
14
15 Examples
16 --------
17 >>> from operator import add
18 >>> task_label((add, 1, 2))
19 'add'
20 >>> task_label((add, (add, 1, 2), 3))
21 'add(...)'
22 """
23 if isinstance(task, GraphNode):
24 if isinstance(task, Task) and task.has_subgraph():
25 return f"{task.key}(...)"
26 return task.key
27 func = task[0]
28 if func is apply:
29 func = task[1]
30 if hasattr(func, "funcs"):
31 if len(func.funcs) > 1:
32 return f"{funcname(func.funcs[0])}(...)"
33 else:
34 head = funcname(func.funcs[0])
35 else:
36 head = funcname(func)
37 if any(has_sub_tasks(i) for i in task[1:]):
38 return f"{head}(...)"
39 else:
40 return head
41
42
43def has_sub_tasks(task):

Callers 2

test_task_labelFunction · 0.90

Calls 4

funcnameFunction · 0.90
anyFunction · 0.85
has_sub_tasksFunction · 0.85
has_subgraphMethod · 0.80

Tested by 2

test_task_labelFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…