Provenance
Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.
- class Provenance(produced_by: str, spec_fingerprint: str, inputs: ~typing.Tuple[~habit.contracts.provenance.Provenance, ...] = (), software: ~typing.Mapping[str, str] = <factory>, random_seed: int | None = None, created_at: str | None = None, notes: ~typing.Mapping[str, ~typing.Any] = <factory>)[source]
Bases:
objectImmutable record answering “how was this object produced?”.
- produced_by
Registered component name that created this object, e.g.
"supervoxelizer.slic".- Type:
- spec_fingerprint
Stable hash of the algorithm specification used, so two runs can be compared for scientific equivalence.
- Type:
- inputs
Provenance of every object consumed to produce this one. This forms a directed acyclic graph back to the raw images.
- Type:
Tuple[habit.contracts.provenance.Provenance, …]
- software
Version fingerprint of HABIT and the scientifically relevant dependencies (e.g. PyRadiomics, SimpleITK, scikit-learn).
- random_seed
Seed in effect for this scientific result, or
Nonewhen no seeded step contributed. Deterministic derivations inherit the parent’s seed viaderive()unless cleared explicitly.- Type:
int | None
- notes
Free-form annotations that must never be required for reproduction; they exist for human readers only.
- Type:
Mapping[str, Any]
- derive(*, produced_by: str, spec_fingerprint: str, random_seed: int | None | object = <object object>) Provenance[source]
Create the provenance of an object derived from this one.
Operator authors never write provenance by hand; base classes call this so that the propagation rule stays uniform across the codebase. The software fingerprint is inherited from
self(the environment does not change mid-pipeline) and the timestamp is stamped here.The random seed follows the same inheritance rule unless overridden: a deterministic step that does not mention seeding must not erase the seed that defined the scientific result upstream (for example, attaching cohort-level feature preprocessing to a fitted
HabitatModel). Passrandom_seed=explicitly to record a new seed, orrandom_seed=Noneto clear it.- Parameters:
produced_by – Registered name of the component doing the derivation.
spec_fingerprint – Fingerprint of that component’s specification.
random_seed – Seed used by the derivation. Omitted (default) keeps
self.random_seed;Noneclears; anintreplaces.
- Returns:
A new
Provenancewhoseinputscontainsself.
- classmethod source(produced_by: str) Provenance[source]
Create the root provenance of an object that has no HABIT inputs.
Used for objects entering the pipeline from the outside world (raw images, user-constructed arrays) so that every derived record still terminates at a well-defined root.
- Parameters:
produced_by – Description of the external origin, e.g.
"directory_source"or"user_array".- Returns:
A provenance record with no inputs and the current software fingerprint.