MLFlowStorageCallback#

class openstef_models.integrations.mlflow.MLFlowStorageCallback(*, storage: ~openstef_models.integrations.mlflow.mlflow_storage.MLFlowStorage = <factory>, model_reuse_enable: bool = True, model_reuse_max_age: ~datetime.timedelta = datetime.timedelta(days=7), model_selection_enable: bool = True, model_selection_metric: tuple[~typing.Union[~openstef_core.types.Quantile, ~typing.Literal['global']], str, ~openstef_beam.evaluation.metric_providers.MetricDirection] = (0.5, 'R2', 'higher_is_better'), model_selection_old_model_penalty: float = 1.2, store_feature_importance_plot: bool = True)[source]

Bases: BaseConfig, ForecastingCallback

MLFlow callback for logging forecasting workflow events.

Model-agnostic: delegates to polymorphic methods on the model and fit result for child hyperparams, child data, metrics, and feature importances.

Parameters:
  • storage (MLFlowStorage)

  • model_reuse_enable (bool)

  • model_reuse_max_age (timedelta)

  • model_selection_enable (bool)

  • model_selection_metric (tuple[Union[Quantile, Literal['global']], str, MetricDirection])

  • model_selection_old_model_penalty (float)

  • store_feature_importance_plot (bool)

storage: MLFlowStorage
model_reuse_enable: bool
model_reuse_max_age: timedelta
model_selection_enable: bool
model_selection_metric: tuple[Union[Quantile, Literal['global']], str, MetricDirection]
model_selection_old_model_penalty: float
store_feature_importance_plot: bool
model_post_init(context: Any) → None[source]

Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.

Parameters:

context (Any)

Return type:

None

Overrides:

BaseModel.model_post_init

on_fit_start(context: WorkflowContext[CustomForecastingWorkflow], data: VersionedTimeSeriesDataset | TimeSeriesDataset) → None[source]

Called before model fitting begins.

Use this hook for pre-training validation, data preprocessing, or setting up training monitoring.

Parameters:
Return type:

None

Overrides:

PredictorCallback.on_fit_start

on_fit_end(context: WorkflowContext[CustomForecastingWorkflow], result: ModelFitResult) → None[source]

Called after model fitting completes successfully.

Use this hook for post-training validation, model evaluation, saving training metrics, or triggering downstream processes.

Parameters:
  • context (WorkflowContext[CustomForecastingWorkflow]) – The workflow context that completed fitting.

  • result (ModelFitResult) – Result of the fitting process.

Return type:

None

Overrides:

PredictorCallback.on_fit_end

on_predict_start(context: WorkflowContext[CustomForecastingWorkflow], data: VersionedTimeSeriesDataset | TimeSeriesDataset)[source]

Called before prediction generation begins.

Use this hook for input data validation, prediction setup, or logging prediction requests.

Parameters:
Overrides:

PredictorCallback.on_predict_start

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': False, 'extra': 'ignore', 'protected_namespaces': ()}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].