MCPcopy Create free account
hub / github.com/dask/dask / Task

Class Task

dask/_task_spec.py:627–826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

625
626
627class Task(GraphNode):
628 func: Callable
629 args: tuple
630 kwargs: dict
631 _data_producer: bool
632 _token: str | None
633 _is_coro: bool | None
634 _repr: str | None
635
636 __slots__ = tuple(__annotations__)
637
638 def __init__(
639 self,
640 key: Any,
641 func: Callable,
642 /,
643 *args: Any,
644 _data_producer: bool = False,
645 **kwargs: Any,
646 ):
647 self.key = key
648 self.func = func
649 if isinstance(func, Task):
650 raise TypeError("Cannot nest tasks")
651
652 self.args = args
653 self.kwargs = kwargs
654 _dependencies: set[KeyType] | None = None
655 for a in itertools.chain(args, kwargs.values()):
656 if isinstance(a, TaskRef):
657 if _dependencies is None:
658 _dependencies = {a.key}
659 else:
660 _dependencies.add(a.key)
661 elif isinstance(a, GraphNode) and a.dependencies:
662 if _dependencies is None:
663 _dependencies = set(a.dependencies)
664 else:
665 _dependencies.update(a.dependencies)
666 if _dependencies:
667 self._dependencies = frozenset(_dependencies)
668 else:
669 self._dependencies = _no_deps
670 self._is_coro = None
671 self._token = None
672 self._repr = None
673 self._data_producer = _data_producer
674
675 @property
676 def data_producer(self) -> bool:
677 return self._data_producer
678
679 def has_subgraph(self) -> bool:
680 return self.func == _execute_subgraph
681
682 def copy(self):
683 return type(self)(
684 self.key,

Callers 15

__init__Method · 0.90
sanitize_dskFunction · 0.90
hlgMethod · 0.90
__dask_graph__Method · 0.90
unpack_collectionsFunction · 0.90
call_functionFunction · 0.90
_unpackFunction · 0.90
unpack_collectionsFunction · 0.90
blockwiseFunction · 0.90
cloneMethod · 0.90
_make_blockwise_graphFunction · 0.90
lazify_taskFunction · 0.90

Calls

no outgoing calls

Tested by 15

test_lazify_taskFunction · 0.72
test_reprFunction · 0.72
test_task_eqFunction · 0.72
test_task_executableFunction · 0.72
test_reference_remoteFunction · 0.72
test_task_nestedFunction · 0.72
test_pickleFunction · 0.72
test_pickle_sizeFunction · 0.72