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

Function get_collection_names

dask/base.py:1331–1349  ·  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

1329
1330
1331def get_collection_names(collection) -> set[str]:
1332 """Infer the collection names from the dask keys, under the assumption that all keys
1333 are either tuples with matching first element, and that element is a string, or
1334 there is exactly one key and it is a string.
1335
1336 Examples
1337 --------
1338 >>> a.__dask_keys__() # doctest: +SKIP
1339 ["foo", "bar"]
1340 >>> get_collection_names(a) # doctest: +SKIP
1341 {"foo", "bar"}
1342 >>> b.__dask_keys__() # doctest: +SKIP
1343 [[("foo-123", 0, 0), ("foo-123", 0, 1)], [("foo-123", 1, 0), ("foo-123", 1, 1)]]
1344 >>> get_collection_names(b) # doctest: +SKIP
1345 {"foo-123"}
1346 """
1347 if not is_dask_collection(collection):
1348 raise TypeError(f"Expected Dask collection; got {type(collection)}")
1349 return {get_name_from_key(k) for k in flatten(collection.__dask_keys__())}
1350
1351
1352def 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