MCPcopy
hub / github.com/dask/dask / _layer

Method _layer

dask/dataframe/dask_expr/_expr.py:3154–3175  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3152 return f"delayed-container-{self.deterministic_token}"
3153
3154 def _layer(self) -> dict:
3155 from dask.delayed import Delayed
3156
3157 if isinstance(self.operands[0], TaskRef):
3158 tasks = [
3159 Alias((self._name, ix), fut.key) for ix, fut in enumerate(self.operands)
3160 ]
3161 dsk = {t.key: t for t in tasks}
3162 elif isinstance(self.operands[0], Delayed):
3163 expr = collections_to_expr(self.operands).optimize()
3164 keys = expr.__dask_keys__()
3165 dsk = expr.__dask_graph__()
3166 # Many APIs in dask-expr are not honoring __dask_keys__ but are instead
3167 # assuming they can just construct the keys themselves by walking the
3168 # partitions. Therefore we'll have to remap the key names and can't just
3169 # expose __dask_keys__()
3170 for ix, actual_key in enumerate(keys):
3171 dsk[(self._name, ix)] = Alias((self._name, ix), actual_key[0])
3172 else:
3173 raise TypeError("Expected a Delayed or Future object")
3174
3175 return dsk
3176
3177 def _divisions(self):
3178 return (None,) * (len(self.operands) + 1)

Callers

nothing calls this directly

Calls 5

AliasClass · 0.90
collections_to_exprFunction · 0.90
optimizeMethod · 0.45
__dask_keys__Method · 0.45
__dask_graph__Method · 0.45

Tested by

no test coverage detected