nirs4all.pipeline.dagml.identity module

Stable sample identity for the nirs4all → dag-ml(-data) bridge.

SpectroDataset’s only identity is the integer sample column. It equals the positional row at load time and is renumbered 0..N-1 on every re-parse, so it is the correct in-memory join key but an unacceptable cross-run wire id — dag-ml is identity-keyed and refuses row-position joins. This module mints a content-derived stable wire id per sample and keeps the bidirectional map the resolver uses to answer a dag-ml view (which speaks wire ids) with the right SpectroDataset rows.

Wire ids use . separators: dag-ml-data ids validate as [A-Za-z0-9_.-] (≤128 bytes) and reject : (that is dag-ml’s graph-id style, not a data id).

The two grains diverge for augmented rows: an augmented child gets its own observation_id (feature-level, one per stored row) while its sample_id stays the origin’s grouping key, so the origin-boundary check sees the child grouped with its base. For a base row the grains coincide (origin == sample). mint_identity covers augmented rows when run on a dataset that already holds them. Repetitions are the same divergence (several stored rows share one sample_id) and reuse this machinery.

class nirs4all.pipeline.dagml.identity.SampleIdentity(sample_int: int, origin_int: int, observation_id: str, sample_id: str, augmented: bool)[source]

Bases: object

One sample’s identity grains.

observation_id is feature-level (one per stored row); sample_id is target-level (origin-keyed, deduped over repetitions). For the baseline they are equal because origin == sample and there are no repetitions.

augmented: bool
observation_id: str
origin_int: int
sample_id: str
sample_int: int
nirs4all.pipeline.dagml.identity.validate_data_id(wire: str) → str[source]

Return wire if it is a legal dag-ml-data id, else raise ValueError.