vipr.plugins.inference.handlers package

Submodules

vipr.plugins.inference.handlers.data_loader module

class vipr.plugins.inference.handlers.data_loader.DataLoaderHandler(**kw: Any)

Bases: DataLoaderInterface, Handler

Base handler for data loaders. Specific implementations should override _load_data method.

load_data(**kwargs) DataSet

Loads data from a specified path.

If the handler class has a __vipr_params_model__ (set by @discover_data_loader), unknown keys are stripped from kwargs before forwarding to _load_data. This prevents extra='forbid' validation errors when the config contains keys intended for other handlers.

Parameters:
  • data_path – Optional path to data file

  • **kwargs – Additional parameters for data loading

Returns:

DataSet containing loaded data with x, y, errors, and metadata

vipr.plugins.inference.handlers.model_builder module

class vipr.plugins.inference.handlers.model_builder.ModelBuilderHandler(**kw: Any)

Bases: ModelBuilderInterface, Handler

Base handler for building executable models from model packages.

classmethod manifest_contract() dict

Optional manifest contract metadata for bundling convenience commands.

Defaults to no extra contract fields.

vipr.plugins.inference.handlers.model_loader module

class vipr.plugins.inference.handlers.model_loader.ModelLoaderHandler(**kw: Any)

Bases: ModelLoaderInterface, Handler

load_model(**kwargs)

Loads a model of the given type.

If the handler class has a __vipr_params_model__ (set by @discover_model_loader), unknown keys are stripped from kwargs before forwarding to _load_model. This prevents extra='forbid' validation errors when the config contains keys intended for other handlers.

Parameters:

**kwargs – Additional parameters for model initialization

Returns:

The loaded model

vipr.plugins.inference.handlers.postprocessor module

Base class for postprocessor handlers in the VIPR framework.

exception vipr.plugins.inference.handlers.postprocessor.PostprocessorError

Bases: VIPRError

Exception raised for postprocessor related errors.

class Meta

Bases: object

label = 'PostprocessorError'
class vipr.plugins.inference.handlers.postprocessor.PostprocessorHandler(**kw: Any)

Bases: PostprocessorInterface, Handler

Base postprocessor handler for processing results after predictions.

class Meta

Bases: object

label = 'postprocessor'
abstract postprocess(data: Any, **kwargs) Any

Postprocess the prediction results.

Parameters:
  • data – Input data to postprocess (typically prediction results)

  • **kwargs – Parameters controlling postprocessing behavior

Returns:

Postprocessed results

Return type:

Any

Raises:

PostprocessorError – If postprocessing fails

vipr.plugins.inference.handlers.predictor module

class vipr.plugins.inference.handlers.predictor.PredictorHandler(**kw: Any)

Bases: PredictorInterface, Handler

Base handler for predictor implementations with unified DataSet interface.

predict(dataset, model: Any, params: dict[str, Any] | None = None) dict[str, Any]

Make predictions using the model with unified DataSet interface.

If the handler class has a __vipr_params_model__ (set by @discover_predictor), unknown keys are stripped from params before forwarding to _predict. This prevents extra='forbid' validation errors when the YAML config contains keys intended for other handlers.

Parameters:
  • dataset – DataSet with batch-first format (batch_size, n_points)

  • model – Model to use for prediction

  • params – Additional parameters for prediction control

Returns:

Dict with prediction results in batch format

Module contents

Inference-specific handler base classes.

class vipr.plugins.inference.handlers.DataLoaderHandler(**kw: Any)

Bases: DataLoaderInterface, Handler

Base handler for data loaders. Specific implementations should override _load_data method.

load_data(**kwargs) DataSet

Loads data from a specified path.

If the handler class has a __vipr_params_model__ (set by @discover_data_loader), unknown keys are stripped from kwargs before forwarding to _load_data. This prevents extra='forbid' validation errors when the config contains keys intended for other handlers.

Parameters:
  • data_path – Optional path to data file

  • **kwargs – Additional parameters for data loading

Returns:

DataSet containing loaded data with x, y, errors, and metadata

class vipr.plugins.inference.handlers.ModelBuilderHandler(**kw: Any)

Bases: ModelBuilderInterface, Handler

Base handler for building executable models from model packages.

classmethod manifest_contract() dict

Optional manifest contract metadata for bundling convenience commands.

Defaults to no extra contract fields.

class vipr.plugins.inference.handlers.ModelLoaderHandler(**kw: Any)

Bases: ModelLoaderInterface, Handler

load_model(**kwargs)

Loads a model of the given type.

If the handler class has a __vipr_params_model__ (set by @discover_model_loader), unknown keys are stripped from kwargs before forwarding to _load_model. This prevents extra='forbid' validation errors when the config contains keys intended for other handlers.

Parameters:

**kwargs – Additional parameters for model initialization

Returns:

The loaded model

class vipr.plugins.inference.handlers.PostprocessorHandler(**kw: Any)

Bases: PostprocessorInterface, Handler

Base postprocessor handler for processing results after predictions.

class Meta

Bases: object

label = 'postprocessor'
abstract postprocess(data: Any, **kwargs) Any

Postprocess the prediction results.

Parameters:
  • data – Input data to postprocess (typically prediction results)

  • **kwargs – Parameters controlling postprocessing behavior

Returns:

Postprocessed results

Return type:

Any

Raises:

PostprocessorError – If postprocessing fails

class vipr.plugins.inference.handlers.PredictorHandler(**kw: Any)

Bases: PredictorInterface, Handler

Base handler for predictor implementations with unified DataSet interface.

predict(dataset, model: Any, params: dict[str, Any] | None = None) dict[str, Any]

Make predictions using the model with unified DataSet interface.

If the handler class has a __vipr_params_model__ (set by @discover_predictor), unknown keys are stripped from params before forwarding to _predict. This prevents extra='forbid' validation errors when the YAML config contains keys intended for other handlers.

Parameters:
  • dataset – DataSet with batch-first format (batch_size, n_points)

  • model – Model to use for prediction

  • params – Additional parameters for prediction control

Returns:

Dict with prediction results in batch format