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

Function clone_key

dask/base.py:1287–1306  ·  view source on GitHub ↗

Clone a key from a Dask collection, producing a new key with the same prefix and indices and a token which is a deterministic function of the previous key and seed. Examples -------- >>> clone_key("x", 123) # doctest: +SKIP 'x-c4fb64ccca807af85082413d7ef01721' >>> clone_key

(key: KeyOrStrT, seed: Hashable)

Source from the content-addressed store, hash-verified

1285
1286
1287def clone_key(key: KeyOrStrT, seed: Hashable) -> KeyOrStrT:
1288 """Clone a key from a Dask collection, producing a new key with the same prefix and
1289 indices and a token which is a deterministic function of the previous key and seed.
1290
1291 Examples
1292 --------
1293 >>> clone_key("x", 123) # doctest: +SKIP
1294 'x-c4fb64ccca807af85082413d7ef01721'
1295 >>> clone_key("inc-cbb1eca3bafafbb3e8b2419c4eebb387", 123) # doctest: +SKIP
1296 'inc-bc629c23014a4472e18b575fdaf29ee7'
1297 >>> clone_key(("sum-cbb1eca3bafafbb3e8b2419c4eebb387", 4, 3), 123) # doctest: +SKIP
1298 ('sum-c053f3774e09bd0f7de6044dbc40e71d', 4, 3)
1299 """
1300 if isinstance(key, tuple) and key and isinstance(key[0], str):
1301 return (clone_key(key[0], seed),) + key[1:]
1302 if isinstance(key, str):
1303 prefix = key_split(key)
1304 token = tokenize(key, seed)
1305 return f"{prefix}-{token}"
1306 raise TypeError(f"Expected str or a tuple starting with str; got {key!r}")

Callers 7

clone_valueMethod · 0.90
cloneMethod · 0.90
_bind_oneFunction · 0.90
cloneMethod · 0.90
test_clone_keyFunction · 0.90
test_bindFunction · 0.90

Calls 2

key_splitFunction · 0.90
tokenizeFunction · 0.90

Tested by 3

test_clone_keyFunction · 0.72
test_bindFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…