Rename Preprocessor to PreprocessorProtocol

This commit is contained in:
mbsantiago 2025-04-19 12:25:41 +01:00
parent ae6063918c
commit 07f065cf93
3 changed files with 9 additions and 5 deletions

View File

@ -1,4 +1,4 @@
from typing import Dict, NamedTuple from typing import Dict, NamedTuple, Protocol
import numpy as np import numpy as np
@ -15,3 +15,7 @@ class BatDetect2Prediction(NamedTuple):
detection_score: float detection_score: float
class_scores: Dict[str, float] class_scores: Dict[str, float]
features: np.ndarray features: np.ndarray
class PostprocessorProtocol(Protocol):
pass

View File

@ -58,7 +58,7 @@ from batdetect2.preprocess.spectrogram import (
) )
from batdetect2.preprocess.types import ( from batdetect2.preprocess.types import (
AudioLoader, AudioLoader,
Preprocessor, PreprocessorProtocol,
SpectrogramBuilder, SpectrogramBuilder,
) )
@ -110,7 +110,7 @@ class PreprocessingConfig(BaseConfig):
spectrogram: SpectrogramConfig = Field(default_factory=SpectrogramConfig) spectrogram: SpectrogramConfig = Field(default_factory=SpectrogramConfig)
class StandardPreprocessor(Preprocessor): class StandardPreprocessor(PreprocessorProtocol):
"""Standard implementation of the `Preprocessor` protocol. """Standard implementation of the `Preprocessor` protocol.
Orchestrates the audio loading and spectrogram generation pipeline using Orchestrates the audio loading and spectrogram generation pipeline using
@ -402,7 +402,7 @@ def load_preprocessing_config(
def build_preprocessor( def build_preprocessor(
config: Optional[PreprocessingConfig] = None, config: Optional[PreprocessingConfig] = None,
) -> Preprocessor: ) -> PreprocessorProtocol:
"""Factory function to build the standard preprocessor from configuration. """Factory function to build the standard preprocessor from configuration.
Creates instances of the required `AudioLoader` and `SpectrogramBuilder` Creates instances of the required `AudioLoader` and `SpectrogramBuilder`

View File

@ -158,7 +158,7 @@ class SpectrogramBuilder(Protocol):
... ...
class Preprocessor(Protocol): class PreprocessorProtocol(Protocol):
"""Defines a high-level interface for the complete preprocessing pipeline. """Defines a high-level interface for the complete preprocessing pipeline.
A Preprocessor combines audio loading and spectrogram generation steps. A Preprocessor combines audio loading and spectrogram generation steps.