MCPcopy
hub / github.com/dask/dask / get_collection_names

Function get_collection_names

dask/base.py:1212–1230  ·  view source on GitHub ↗

Infer the collection names from the dask keys, under the assumption that all keys are either tuples with matching first element, and that element is a string, or there is exactly one key and it is a string. Examples -------- >>> a.__dask_keys__() # doctest: +SKIP ["foo", "b

(collection)

Source from the content-addressed store, hash-verified

1210
1211
1212def get_collection_names(collection) -> set[str]:
1213 """Infer the collection names from the dask keys, under the assumption that all keys
1214 are either tuples with matching first element, and that element is a string, or
1215 there is exactly one key and it is a string.
1216
1217 Examples
1218 --------
1219 >>> a.__dask_keys__() # doctest: +SKIP
1220 ["foo", "bar"]
1221 >>> get_collection_names(a) # doctest: +SKIP
1222 {"foo", "bar"}
1223 >>> b.__dask_keys__() # doctest: +SKIP
1224 [[("foo-123", 0, 0), ("foo-123", 0, 1)], [("foo-123", 1, 0), ("foo-123", 1, 1)]]
1225 >>> get_collection_names(b) # doctest: +SKIP
1226 {"foo-123"}
1227 """
1228 if not is_dask_collection(collection):
1229 raise TypeError(f"Expected Dask collection; got {type(collection)}")
1230 return {get_name_from_key(k) for k in flatten(collection.__dask_keys__())}
1231
1232
1233def get_name_from_key(key: Key) -> str:

Callers 6

_checkpoint_oneFunction · 0.90
_bind_oneFunction · 0.90
block_oneFunction · 0.90
__dask_layers__Method · 0.90
test_custom_collectionFunction · 0.90

Calls 4

flattenFunction · 0.90
is_dask_collectionFunction · 0.85
get_name_from_keyFunction · 0.85
__dask_keys__Method · 0.45

Tested by 3

__dask_layers__Method · 0.72
test_custom_collectionFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…