MCPcopy
hub / github.com/dask/dask / Task

Class Task

dask/_task_spec.py:636–838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…