microsoft/qlib · error · NotImplementedError

Please implement the `reset_online_tag` method.

Error message

Please implement the `reset_online_tag` method.

What it means

OnlineTool.reset_online_tag is an abstract method of the OnlineTool base class. Its contract is to offline all currently-online models and mark the given recorder(s) as 'online'. The base class raises NotImplementedError; the error appears when a reset is attempted on the base class or a subclass missing this override — typically from prepare_online_models, which calls self.tool.reset_online_tag(trained_models).

Source

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

        Args:
            recorder (Object): the model's recorder

        Returns:
            str: the online tag
        """
        raise NotImplementedError(f"Please implement the `get_online_tag` method.")

    def reset_online_tag(self, recorder: Union[list, object]):
        """
        Offline all models and set the recorders to 'online'.

        Args:
            recorder (Union[list,object]):
                the recorder you want to reset to 'online'.

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

    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.

        """

View on GitHub (pinned to 79633dd950)

Solutions

  1. Pass a concrete tool: construct OnlineStrategy subclasses with a working tool (e.g. OnlineToolR) or override prepare_online_models so it does not rely on the base tool
  2. Implement reset_online_tag(self, recorder) in your OnlineTool subclass: mark all current online models offline, then set ONLINE_TAG on the given recorder(s)
  3. Check that OnlineManager/strategy construction is not silently falling back to OnlineTool()

Example fix

# before
strategy = MyStrategy('my_exp')  # defaults to OnlineTool()
strategy.prepare_online_models(models)  # -> NotImplementedError in reset_online_tag

# after
from qlib.workflow.online.utils import OnlineToolR
strategy = MyStrategy('my_exp')
strategy.tool = OnlineToolR(default_exp_name='my_exp')
strategy.prepare_online_models(models)
Defensive patterns

Strategy: type-guard

Validate before calling

from qlib.workflow.online.utils import OnlineTool

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

Type guard

from qlib.workflow.online.utils import OnlineTool

def has_reset_online_tag(tool) -> bool:
    return type(tool).reset_online_tag is not OnlineTool.reset_online_tag

Try / catch

try:
    strategy.prepare_online_models(models)
except NotImplementedError as e:
    raise TypeError('strategy.tool is abstract; assign OnlineToolR first') from e

Prevention

When it happens

Trigger: Running OnlineStrategy.prepare_online_models(trained_models) whose default implementation calls tool.reset_online_tag; instantiating OnlineTool directly; a custom OnlineTool subclass without reset_online_tag.

Common situations: Using the default prepare_online_models of OnlineStrategy with the abstract OnlineTool (OnlineStrategy.__init__ defaults self.tool = OnlineTool()); writing a custom tool and missing this method; replacing OnlineToolR with a stub for testing.

Related errors


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