microsoft/qlib · error · NotImplementedError

Please implement the `update_online_pred` method.

Error message

Please implement the `update_online_pred` method.

What it means

OnlineTool.update_online_pred is an abstract method of the OnlineTool base class. It should advance the predictions of all online models up to to_date (None = latest). The base class raises NotImplementedError; the error fires when a prediction refresh is requested through a tool lacking the override — typically from OnlineManager routines calling update_online_pred after task training.

Source

Thrown at qlib/workflow/online/utils.py:84

    def online_models(self) -> list:
        """
        Get current `online` models

        Returns:
            list: a list of `online` models.
        """
        raise NotImplementedError(f"Please implement the `online_models` method.")

    def update_online_pred(self, to_date=None):
        """
        Update the predictions of `online` models to to_date.

        Args:
            to_date (pd.Timestamp): the pred before this date will be updated. None for updating to the latest.

        """
        raise NotImplementedError(f"Please implement the `update_online_pred` method.")


class OnlineToolR(OnlineTool):
    """
    The implementation of OnlineTool based on (R)ecorder.
    """

    def __init__(self, default_exp_name: str = None):
        """
        Init OnlineToolR.

        Args:
            default_exp_name (str): the default experiment name.
        """
        super().__init__()
        self.default_exp_name = default_exp_name

    def set_online_tag(self, tag, recorder: Union[Recorder, List]):

View on GitHub (pinned to 79633dd950)

Solutions

  1. Use OnlineToolR.update_online_pred, which builds PredUpdater for each online recorder (skipping recorders whose pred.pkl fails to load)
  2. If your tool genuinely needs no prediction updates, override update_online_pred(self, to_date=None) with a no-op (log an info line) instead of leaving the abstract method
  3. Wire the concrete tool into your strategy/OnlineManager before running routines

Example fix

# before
class MyTool(OnlineTool):
    ...
    # update_online_pred missing

# after
class MyTool(OnlineTool):
    ...
    def update_online_pred(self, to_date=None):
        # delegate to the recorder-based implementation
        OnlineToolR(default_exp_name=self.exp).update_online_pred(to_date=to_date)
Defensive patterns

Strategy: type-guard

Validate before calling

from qlib.workflow.online.utils import OnlineTool

def assert_update_pred_implemented(tool):
    if type(tool).update_online_pred is OnlineTool.update_online_pred:
        raise TypeError(f'{type(tool).__name__} must implement update_online_pred')

Type guard

from qlib.workflow.online.utils import OnlineTool

def can_update_pred(tool) -> bool:
    return type(tool).update_online_pred is not OnlineTool.update_online_pred

Try / catch

try:
    tool.update_online_pred(to_date=to_date)
except NotImplementedError as e:
    logger.warning('prediction update skipped: %s', e)

Prevention

When it happens

Trigger: Calling tool.update_online_pred(to_date=...) on OnlineTool() or an incomplete subclass; an OnlineManager routine reaching the 'update online predictions' stage with the default abstract tool; custom OnlineTool implementations missing this method.

Common situations: Running online workflows end-to-end for the first time with a custom strategy but the default tool; disabling prediction updates by subclassing without realizing the base method raises; version upgrades adding new abstract hooks.

Related errors


AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15). Data as JSON: /api/errors/50ed4a0c823a6ed8. Report an issue: GitHub.