function
unshard_key
beam_agents.keys.unshard_key
unshard_key(key: 'bytes') -> 'bytes'Docstring
Return the logical key behind a physical shard key.
Strips exactly one trailing #<digits> group, so
unshard_key(shard_key(k, n, payload=p)) == k for every valid input.
Defined only over keys produced by :func:shard_key: a key with no trailing
#<digits> raises ValueError rather than passing through, so a
mis-wired regroup fails loudly instead of silently merging outputs under the
wrong key. The inverse cannot resolve the residual ambiguity — b"user#7"
is both a plausible logical key and shard 7 of b"user" — so it resolves
it in favour of the sharded reading; do not shard keys that already end in
#<digits>.