nirs4all.pipeline.dagml.rt module

Runtime envelopes for the dag-ml backend — RtResult / RtRunRequest / RtError (B-018 / L10).

These are the thin, pure-projection wrappers the runtime API (LOCK-RT, DEC-RT-001) puts over surfaces that ALREADY exist on the dag-ml backend — they add zero new dag-ml fields and never recompute a score. The four inputs all live next to this module in pipeline/dagml/:

  • the native results triple (manifest.json + score_set.json + predictions.parquet) written / read by nirs4all.pipeline.dagml.native_results;

  • the raw native ScoreSet stashed on a dag-ml RunResult (RunResult._dagml_score_set, nirs4all.pipeline.dagml.result._scores_to_run_result());

  • the dag-ml error taxonomy (DagMlUnsupported / DagMlUnavailable) the run() fallback catches.

Anchored on the dag-ml ScoreSet (score_set.schema.json): RtResult.reports is the VERBATIM score_set.reports[] — the partition / level / fold_id / variant_id / target join key both the Studio ChainSummary pivot and the Web RunResult nest are deterministic group-bys of. The wire schema lives in nirs4all-ecosystem/docs/contracts/runtime/*.v1.schema.json (it $ref``s the dag-ml contracts; the cause vocabulary is owned by ``CAP-004). This module is the Python projection; nothing here mutates RunResult, the .n4a bundle, or the native results format (all 0.9.x-stable).

class nirs4all.pipeline.dagml.rt.RtResult(schema_version: int, run_id: str | None, plan_id: str | None, selection: dict[str, ~typing.Any] | None, reports: list[dict[str, ~typing.Any]], predictions: list[dict[str, ~typing.Any]], manifest: dict[str, ~typing.Any], artifacts: list[dict[str, ~typing.Any]] | None = None, diagnostics: list[~nirs4all.pipeline.dagml.rt.RtError] = <factory>)[source]

Bases: object

The unified runtime result envelope (RT-002) — a pure projection of the dag-ml native triple.

Anchored on the dag-ml ScoreSet: reports is VERBATIM score_set.reports[]. The Studio ChainSummary (pivot group_by(run_id, variant)) and the Web RunResult (nest group_by(kind)) are both deterministic VIEWS of this envelope — neither is the contract. Constructed by from_native_dir() (wrapping read_native_results()) or from_run_result() (reading RunResult._dagml_score_set + projecting the in-memory predictions); both are pure projections with no recompute. manifest mirrors the native manifest.json header; diagnostics carries any RtError (e.g. “ran legacy because <cause>”).

artifacts: list[dict[str, Any]] | None = None
diagnostics: list[RtError]
classmethod from_native_dir(run_dir: str | Path, *, diagnostics: list[RtError] | None = None) → RtResult[source]

Project a native results directory (manifest + score_set + predictions) into an RtResult.

Wraps read_native_results() (which hash-validates the ScoreSet and verify-then-loads any model artifacts), then projects — reports are the verbatim ScoreSet reports, predictions are the round-tripped blocks, manifest mirrors the native header, artifacts are the recorded ArtifactRefs. No recompute.

classmethod from_run_result(result: RunResult) → RtResult[source]

Project a RunResult into an RtResult (pure; works for both engines).

For a dag-ml result the ScoreSet is read from result._dagml_score_set (reports verbatim, engine="dag-ml"). For a LEGACY result (no native ScoreSet — e.g. the transparent fallback) the envelope is sparse (reports=[], engine from per_dataset) but still carries the predictions projection and any attached RtError diagnostics, so a caller always sees a uniform “ran <engine> because <cause>” envelope. No recompute — scores come from the ScoreSet rows.

manifest: dict[str, Any]
plan_id: str | None
predictions: list[dict[str, Any]]
reports: list[dict[str, Any]]
run_id: str | None
schema_version: int
selection: dict[str, Any] | None
to_dict() → dict[str, Any][source]

The wire dict (matches rt_result.v1.schema.json). diagnostics serialize via RtError.to_dict.

class nirs4all.pipeline.dagml.rt.RtRunRequest(pipeline_dsl: Any, dataset_ref: Any, cv: dict[str, ~typing.Any]=<factory>, execution_backend: str = 'local-python', options: dict[str, ~typing.Any]=<factory>)[source]

Bases: object

The unified runtime run request envelope (RT-002) — the run verb’s input shape.

{ pipeline_dsl, dataset_ref, cv, execution_backend, options } — the union of the run_via_dagml field set, the ExecutionDriverCapability execution_backend taxonomy (local-python | wasm-local | cluster), and the NET-NEW options.allow_fallback strict-mode flag. A thin descriptor the Studio/Web runtimes fill and serialize; nirs4all’s run() still executes the pipeline (V1 does not re-route execution through this envelope). execution_backend (the environment) stays orthogonal to the ML engine (which rides in options).

cv: dict[str, Any]
dataset_ref: Any
execution_backend: str = 'local-python'
options: dict[str, Any]
pipeline_dsl: Any
to_dict() → dict[str, Any][source]

The wire dict (matches rt_run_request.v1.schema.json).