nirs4all.pipeline.resolver module
Prediction Resolver - Unified resolution of prediction sources.
This module provides the PredictionResolver class which normalizes any prediction source (dict, folder, Run, artifact_id, bundle) to the components needed for prediction replay:
Minimal pipeline (subset of steps)
Artifact map (artifacts keyed by step index)
Execution trace (for deterministic replay)
Fold strategy (for CV ensemble averaging)
The resolver is controller-agnostic: it doesn’t know about specific controller types, but provides the artifacts and trace needed by any controller to replay a prediction.
- Supported Source Types:
prediction dict: Most common, from a previous run’s Predictions object
folder path: Path to a pipeline directory containing manifest.yaml
Run object: Best prediction from a Run
artifact_id: Direct artifact reference (e.g., “0001:4:all”)
bundle: Exported prediction bundle (.n4a file)
trace_id: Execution trace reference (e.g., “trace:xyz789”)
Example
>>> resolver = PredictionResolver(workspace_path)
>>> resolved = resolver.resolve(best_prediction)
>>> # Use resolved.minimal_pipeline, resolved.artifact_provider
>>> y_pred = execute_prediction(resolved, new_data)
- class nirs4all.pipeline.resolver.FoldStrategy(value)[source]
Bases:
StrEnumStrategy for combining fold predictions in CV ensembles.
- Variables:
AVERAGE – Simple average of fold predictions
WEIGHTED_AVERAGE – Weighted average using fold weights
SINGLE – Use a single fold’s prediction
- AVERAGE = 'average'
- SINGLE = 'single'
- WEIGHTED_AVERAGE = 'weighted_average'
- class nirs4all.pipeline.resolver.SourceType(value)[source]
Bases:
StrEnumType of prediction source.
- Variables:
PREDICTION – Dictionary from Predictions object
FOLDER – Path to pipeline folder
RUN – Run object (best prediction from run)
ARTIFACT_ID – Direct artifact reference string
BUNDLE – Exported .n4a bundle file
TRACE_ID – Execution trace reference
MODEL_FILE – Direct model file (.joblib, .pkl, .h5, .pt, etc.)
UNKNOWN – Unrecognized source type
- ARTIFACT_ID = 'artifact_id'
- BUNDLE = 'bundle'
- FOLDER = 'folder'
- MODEL_FILE = 'model_file'
- PREDICTION = 'prediction'
- PREDICTION_ID = 'prediction_id'
- RUN = 'run'
- TRACE_ID = 'trace_id'
- UNKNOWN = 'unknown'