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

Method _layer

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

Source from the content-addressed store, hash-verified

3129 return "delayed-container-" + self.deterministic_token
3130
3131 def _layer(self) -> dict:
3132 from dask.delayed import Delayed
3133
3134 if isinstance(self.operands[0], TaskRef):
3135 tasks = [
3136 Alias((self._name, ix), fut.key) for ix, fut in enumerate(self.operands)
3137 ]
3138 dsk = {t.key: t for t in tasks}
3139 elif isinstance(self.operands[0], Delayed):
3140 expr = collections_to_expr(self.operands).optimize()
3141 keys = expr.__dask_keys__()
3142 dsk = expr.__dask_graph__()
3143 # Many APIs in dask-expr are not honoring __dask_keys__ but are instead
3144 # assuming they can just construct the keys themselves by walking the
3145 # partitions. Therefore we'll have to remap the key names and can't just
3146 # expose __dask_keys__()
3147 for ix, actual_key in enumerate(keys):
3148 dsk[(self._name, ix)] = Alias((self._name, ix), actual_key[0])
3149 else:
3150 raise TypeError("Expected a Delayed or Future object")
3151
3152 return dsk
3153
3154 def _divisions(self):
3155 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