nirs4all.pipeline.dagml.native_archive_replay module

Methods-only PREDICT replay from a validated native Package V2 Core container.

This is intentionally a composition boundary, not a second package or model reader: Core validates the selected native closure and returns the exact Package V2 root bytes; DAG-ML parses and validates the package and owns replay; the official pls4all binding imports N4MM only for the invocation. Every reader takes the one retained Core handle of its public call (source) or opens the path itself. No legacy PipelineRunner is consulted.

class nirs4all.pipeline.dagml.native_archive_replay.NativeArchiveConformalInterval(coverage: float, lower: ndarray, upper: ndarray, qhat: float | ndarray, calibration_fingerprint: str)[source]

Bases: object

One finite native conformal interval view returned by DAG-ML replay.

The values are decoded from the exact interval block emitted by DAG-ML; this adapter neither calibrates nor recomputes endpoint arithmetic.

calibration_fingerprint: str
coverage: float
lower: ndarray
qhat: float | ndarray
upper: ndarray
class nirs4all.pipeline.dagml.native_archive_replay.NativeArchivePrediction(values: ndarray, sample_ids: tuple[str, ...], intervals: dict[float, NativeArchiveConformalInterval], conformal_guarantee_status: dict[str, Any] | None, conformal_presentation: dict[str, Any] | None = None)[source]

Bases: object

One identity-aligned native Archive V2 PREDICT result.

conformal_guarantee_status: dict[str, Any] | None
conformal_presentation: dict[str, Any] | None = None
intervals: dict[float, NativeArchiveConformalInterval]
sample_ids: tuple[str, ...]
values: ndarray
exception nirs4all.pipeline.dagml.native_archive_replay.NativeArchiveReplayError[source]

Bases: RuntimeError

The native Archive V2 → Methods PREDICT boundary could not be executed.

nirs4all.pipeline.dagml.native_archive_replay.contract_bytes(value: Any, label: str) → bytes[source]

Exact JSON bytes of a native DAG-ML contract (outcome or package).

Accepts the typed DAG-ML object (its strict json()), the JSON text or bytes, or a finite JSON mapping. The owner builders parse and re-validate these bytes; nothing is reinterpreted here.

nirs4all.pipeline.dagml.native_archive_replay.predict_methods_archive_v2_raw(archive_path: str | Path, X: Any, *, sample_ids: Any, methods_library_path: str | Path | None = None, groups: Any = None, metadata: Any = None, outcome_id: str = 'outcome:nirs4all.archive_predict', run_id: str = 'run:nirs4all.archive_predict', source: Any = None) → ndarray[source]

Predict a fresh raw-array cohort from a Core Archive V2 Methods package.

This is the first public composition that creates a current cohort replay request. It requires explicit stable identities, signs the request through DAG-ML and delegates N4MM import/prediction to pls4all. It never invokes a legacy pipeline or fabricates target content.

nirs4all.pipeline.dagml.native_archive_replay.predict_methods_archive_v2_raw_result(archive_path: str | Path, X: Any, *, sample_ids: Any, methods_library_path: str | Path | None = None, groups: Any = None, metadata: Any = None, outcome_id: str = 'outcome:nirs4all.archive_predict', run_id: str = 'run:nirs4all.archive_predict', source: Any = None) → NativeArchivePrediction[source]

Replay a native archive and retain its exact conformal result blocks.

This is the public result-bearing form of predict_methods_archive_v2_raw(). It exposes only interval blocks already materialized and validated by DAG-ML; it never recalibrates.

nirs4all.pipeline.dagml.native_archive_replay.project_methods_archive_v2_conformal_presentation(archive_path: str | Path, X: Any, *, sample_ids: Any, methods_library_path: str | Path | None = None, groups: Any = None, metadata: Any = None, outcome_id: str = 'outcome:nirs4all.archive_conformal_presentation', run_id: str = 'run:nirs4all.archive_conformal_presentation', source: Any = None) → dict[str, Any][source]

Project DAG-ML’s exact scalar conformal replay presentation.

This is a transport boundary: DAG-ML validates the Package V2 calibration, replay closure, quantiles, and interval arithmetic before producing the presentation. This adapter only verifies that the returned scalar view is the current prediction block and preserves its exact public identities. It intentionally does not recalibrate or reconstruct interval endpoints.

nirs4all.pipeline.dagml.native_archive_replay.replay_methods_archive_v2(archive_path: str | Path, request: Any, data_envelopes: Any, resolver: MaterializationResolver, *, outcome_id: str, run_id: str, fallback: Callable[[dict[str, Any]], dict[str, Any]] | None = None, source: Any = None) → dict[str, Any][source]

Replay a portable Methods Package V2 stored in a Core Archive V2.

request and data_envelopes remain strict DAG-ML contracts supplied by the caller. In particular, a fresh target-free cohort is represented by a signed current envelope, never by a reused training relation or fabricated target hash. Archive contents are validated before this function sees any Package bytes; Package/replay validation runs before a host data callback.

nirs4all.pipeline.dagml.native_archive_replay.validate_methods_archive_v2(archive_path: str | Path, *, source: Any = None) → None[source]

Preflight one native Package V2 container without loading a Methods runtime or any cohort.

Core owns container and selected-closure integrity and returns only the exact Package V2 root bytes. DAG-ML then validates the Package V2 contract; this adapter adds the public raw-Methods closure check. Keeping that sequence at session open time ensures malformed archives fail before callers provide feature rows or native N4MM hydration is attempted.

nirs4all.pipeline.dagml.native_archive_replay.write_methods_archive_v2(archive_path: str | Path, *, archive_id: str, outcome: Any, package: Any) → dict[str, str][source]

Persist one native Methods Package V2 as a new Core native-package container.

Core builds the native scientific closure through DAG-ML and writes the V1 container; this boundary accepts no arbitrary members, retrofits no host sidecars and calculates no member hashes in nirs4all. archive_id becomes the Core container id. The destination must not exist (Core never replaces); a caller that overwrites stages a new path and replaces it itself.

Returns:

archive_id (the container id) and archive_sha256 (the full-file hash).