MCPcopy Index your code
hub / github.com/dask/dask / cull_layers

Method cull_layers

dask/highlevelgraph.py:794–816  ·  view source on GitHub ↗

Return a new HighLevelGraph with only the given layers and their dependencies. Internally, layers are not modified. This is a variant of :meth:`HighLevelGraph.cull` which is much faster and does not risk creating a collision between two layers with the same name and

(self, layers: Iterable[str])

Source from the content-addressed store, hash-verified

792 return HighLevelGraph(ret_layers, ret_dependencies)
793
794 def cull_layers(self, layers: Iterable[str]) -> HighLevelGraph:
795 """Return a new HighLevelGraph with only the given layers and their
796 dependencies. Internally, layers are not modified.
797
798 This is a variant of :meth:`HighLevelGraph.cull` which is much faster and does
799 not risk creating a collision between two layers with the same name and
800 different content when two culled graphs are merged later on.
801
802 Returns
803 -------
804 hlg: HighLevelGraph
805 Culled high level graph
806 """
807 to_visit = set(layers)
808 ret_layers = {}
809 ret_dependencies = {}
810 while to_visit:
811 k = to_visit.pop()
812 ret_layers[k] = self.layers[k]
813 ret_dependencies[k] = self.dependencies[k]
814 to_visit |= ret_dependencies[k] - ret_dependencies.keys()
815
816 return HighLevelGraph(ret_layers, ret_dependencies)
817
818 def validate(self) -> None:
819 # Check dependencies

Callers 1

test_cull_layersFunction · 0.95

Calls 4

setClass · 0.85
HighLevelGraphClass · 0.85
popMethod · 0.80
keysMethod · 0.45

Tested by 1

test_cull_layersFunction · 0.76