identity

module of dascore.workflow source

What a patch is, and what was done to it.

Two ids answer two different questions, and they move independently:

patch_id says which data. It survives every operation which does not change what the data is of – filtering, decimating, transposing, changing units – and changes only when data from more than one source is combined.

processing_id says what was done. It advances on every operation, by folding the operation’s fingerprint into the id the input carried, so that two patches which took the same route from the same source arrive at the same id and two which did not, do not.

Neither is a random number after the first: they are digests of what came before, so the same data processed the same way gives the same processing_id on another machine, in another process, next year. That holds for patch_id too once a patch read from a file derives its id from the source; until then one is minted for each patch built in memory, and is stable only within the process which built it.

Examples

from dascore.workflow.identity import advance, fold_patch_ids

# What was done: the operation folds into what came before.
first = advance("", "0123456789abcdef")
assert advance(first, "0123456789abcdef") != first

# Which data: combining two sources makes a new answer.
assert fold_patch_ids(["a", "b"]) != fold_patch_ids(["b", "a"])

Functions

Name Description
advance Return the processing id an operation leads to.
fold_ids Return the ids a patch combined from several inherits.
fold_patch_ids Return the patch id of a patch combined from several.
fold_processing_ids Return the processing id which several inputs agree on.
ids_enabled Whether this process is keeping track of what a patch is.
new_patch_id Return an id for data which names no source.
patch_id_of Return which data some attrs say they are, or nothing if they cannot.
processing_id_of Return what some attrs say was done, or nothing if they cannot.
source_patch_id Return the id of data read from a file.
stamp_combination Return the ids a patch made from several members carries.
with_patch_id Return attrs which name which data they belong to.