Source code for nirs4all.pipeline.execution.result

"""Result types for pipeline execution."""
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple

from nirs4all.data.dataset import SpectroDataset
from nirs4all.data.predictions import Predictions
from nirs4all.pipeline.config.context import ExecutionContext


[docs] @dataclass class ArtifactMeta: """Metadata about a persisted artifact. Attributes: name: Artifact identifier (e.g., 'model', 'scaler') content_hash: Content-based hash for deduplication path: Relative path from artifacts directory format: Artifact format (e.g., 'joblib', 'h5', 'safetensors') format_version: Version of the library used (e.g., 'sklearn==1.3.0') nirs4all_version: Version of nirs4all used (e.g., '0.4.1') metadata: Additional artifact metadata """ name: str content_hash: str path: str format: str format_version: str = "" nirs4all_version: str = "" metadata: Dict[str, Any] = field(default_factory=dict)
[docs] @dataclass class StepOutput: """Standardized output from a controller execution. Attributes: artifacts: Internal binaries (models, transformers) to be persisted for reproducibility. List of tuples: (object, name, format_hint). outputs: User outputs (charts, reports) to be saved as files. List of tuples: (data_object, filename_hint, type_hint). metadata: Metadata to be added to the context or logs. """ artifacts: List[Tuple[Any, str, Optional[str]]] = field(default_factory=list) outputs: List[Tuple[Any, str, str]] = field(default_factory=list) metadata: Dict[str, Any] = field(default_factory=dict)
[docs] @dataclass class StepResult: """Result of executing a single pipeline step. Attributes: updated_context: Updated execution context after step artifacts: List of artifacts persisted during step execution outputs: List of output files saved during step execution predictions: Optional predictions generated by this step """ updated_context: ExecutionContext artifacts: List[Any] = field(default_factory=list) outputs: List[Any] = field(default_factory=list) predictions: Optional[Predictions] = None