nirs4all.api.portable_archive module
Explicit portable Package V2 transport and callback replay.
Core owns the container and the selected native closure; DAG-ML owns package
semantics, trust and replay. This surface does not deserialize Python models or
reinterpret the separate closed N4MM prediction lane. Readers take the path or the
one retained Core handle of the caller’s public call (source).
- nirs4all.api.portable_archive.inspect_portable_predictor_archive_v2(path: str | Path, *, methods_library_path: str | Path | None = None, source: Any = 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
modelslist with validatedstepsand effective REFITmodel_params, andtraining_performed=False.
- nirs4all.api.portable_archive.read_portable_predictor_archive_v2(path: str | Path, *, source: Any = None) Any[source]
Read a typed Package V2 after Core validates the selected native closure.
Core validates the container and the selected closure (owner, content type, profile, operation, links and fitted states) and returns the exact root package bytes. DAG-ML parses them into the typed package. 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 native Package V2 container.
source – The caller’s retained
N4aSource; Core then reads through its one verified handle instead of reopeningpath.
- Returns:
A validated DAG-ML
PortablePredictorPackage.- Raises:
ImportError – A required matching Core or DAG-ML facade is absent.
ValueError – The container 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], source: Any = None) Any[source]
Replay an archive on an explicitly signed current cohort, without fit.
The container is read and its selected closure 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.
source – The caller’s retained
N4aSource, when it already openedpath.
- 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.
Core builds the native scientific closure through DAG-ML and writes the new container (an existing destination is refused). RAW
methods_role_pipelineartifacts retain their controller trust contract; they are not converted to N4MM or Python sidecars.- Parameters:
path – New destination
.n4acontainer.archive_id – Explicit container identity.
outcome – Captured DAG-ML
TrainingOutcomematching the package.package – Captured DAG-ML
PortablePredictorPackageV2.
- Returns:
archive_id(the container id) andarchive_sha256(the full-file hash).