nirs4all.api.portable_archive module

Explicit portable Package V2 archive transport and callback replay.

Core owns the archive container; DAG-ML owns package semantics, trust and replay. This surface does not deserialize Python models or reinterpret the separate closed N4MM prediction lane.

nirs4all.api.portable_archive.inspect_portable_predictor_archive_v2(path: str | Path, *, methods_library_path: str | Path | None = None) → dict[str, Any][source]

Inspect saved parameters of the closed native PLS phase profile.

Core validates the container, DAG-ML validates package/RAW bindings, and Methods imports each fitted state and checks its native parameters. No fit or prediction runs. Other controller profiles are explicitly refused.

Returns:

The native profile, archive path, a models list with validated steps and effective REFIT model_params, and training_performed=False.

nirs4all.api.portable_archive.read_portable_predictor_archive_v2(path: str | Path) → Any[source]

Read a typed Package V2 after Core and DAG-ML validate the archive.

Core validates bounded ZIP storage and returns opaque members. DAG-ML then checks the outcome/package links, companion members, full RAW artifact coverage and controller contracts. No callback or model loader runs while reading. The returned package is ready for explicit DAG-ML replay; reading does not grant trust to its controllers.

Parameters:

path – Existing portable Core Archive V2.

Returns:

A validated DAG-ML PortablePredictorPackage.

Raises:
  • ImportError – A required matching Core or DAG-ML facade is absent.

  • ValueError – The archive or native payload semantics are invalid.

nirs4all.api.portable_archive.replay_portable_predictor_archive_v2(path: str | Path, request: Any, data_envelopes: Any, trusted_manifests: Any, op_callback: Callable[[dict[str, Any]], dict[str, Any]], *, outcome_id: str, run_id: str, artifact_callback: Callable[[dict[str, Any]], dict[str, Any] | None]) → Any[source]

Replay an archive on an explicitly signed current cohort, without fit.

The archive is reopened and fully validated before DAG-ML sees callbacks. DAG-ML validates the signed PREDICT request, named current data envelopes and explicitly trusted controller manifests before hydration. Its driver schedules prediction and releases artifact states, including on errors. Controller callbacks must implement that read-only replay contract; this facade supplies no training callback, fallback or Python model load.

Parameters:
  • path – Existing portable Core Archive V2.

  • request – Signed current-cohort DAG-ML PREDICT replay request.

  • data_envelopes – Named, signed current-cohort data envelopes.

  • trusted_manifests – Explicitly trusted controller manifests for replay.

  • op_callback – Trusted controller’s PREDICT operation callback.

  • outcome_id – Explicit replay outcome identity.

  • run_id – Explicit replay run identity.

  • artifact_callback – Trusted controller’s hydration/release callback.

Returns:

The native DAG-ML replay outcome, including aligned predictions.

nirs4all.api.portable_archive.write_portable_predictor_archive_v2(path: str | Path, *, archive_id: str, outcome: Any, package: Any) → dict[str, str][source]

Write captured portable Package V2 artifacts without another fit.

DAG-ML assembles the complete native payloads and Core validates/writes them. RAW methods_role_pipeline artifacts retain their controller trust contract; they are not converted to N4MM or Python sidecars.

Parameters:
  • path – Destination .n4a archive.

  • archive_id – Explicit archive identity.

  • outcome – Captured DAG-ML TrainingOutcome matching the package.

  • package – Captured DAG-ML PortablePredictorPackage V2.

Returns:

Core’s archive identity and SHA-256 reference.