MCPcopy
hub / github.com/dask/dask / substitute

Method substitute

dask/_task_spec.py:882–902  ·  view source on GitHub ↗
(
        self, subs: dict[KeyType, KeyType | GraphNode], key: KeyType | None = None
    )

Source from the content-addressed store, hash-verified

880 return f"{type(self).__name__}({self.args})"
881
882 def substitute(
883 self, subs: dict[KeyType, KeyType | GraphNode], key: KeyType | None = None
884 ) -> NestedContainer:
885 subs_filtered = {
886 # subs can be as large as the whole graph; do not iterate over it!
887 k: v
888 for k in (self.dependencies & subs.keys())
889 if (v := subs[k]) != k
890 }
891 if not subs_filtered:
892 return self
893 return type(self)(
894 *(
895 (
896 a.substitute(subs_filtered)
897 if isinstance(a, (GraphNode, TaskRef))
898 else a
899 )
900 for a in self.args
901 )
902 )
903
904 def __dask_tokenize__(self):
905 from dask.tokenize import tokenize

Callers

nothing calls this directly

Calls 2

keysMethod · 0.45
substituteMethod · 0.45

Tested by

no test coverage detected