microsoft/qlib · error · NotImplementedError
Please implement the `get_online_tag` method.
Error message
Please implement the `get_online_tag` method.
What it means
OnlineTool.get_online_tag is an abstract method of the OnlineTool base class. It must return the current online/offline tag string for a given model recorder; the base class intentionally raises NotImplementedError. The error means get_online_tag was invoked on the base class or an incomplete subclass.
Source
Thrown at qlib/workflow/online/utils.py:54
Set `tag` to the model to sign whether online.
Args:
tag (str): the tags in `ONLINE_TAG`, `OFFLINE_TAG`
recorder (Union[list,object]): the model's recorder
"""
raise NotImplementedError(f"Please implement the `set_online_tag` method.")
def get_online_tag(self, recorder: object) -> str:
"""
Given a model recorder and return its online tag.
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.View on GitHub (pinned to 79633dd950)
Solutions
- Use OnlineToolR, which implements get_online_tag by reading the tag parameter from the recorder via R.get_recorder
- Implement get_online_tag(self, recorder) -> str in your subclass, returning ONLINE_TAG or OFFLINE_TAG
- Audit that every abstract method of OnlineTool (set_online_tag, get_online_tag, reset_online_tag, online_models, update_online_pred) has an override
Example fix
# before
class MyTool(OnlineTool):
def set_online_tag(self, tag, recorder):
...
# get_online_tag missing
# after
class MyTool(OnlineTool):
def set_online_tag(self, tag, recorder):
...
def get_online_tag(self, recorder) -> str:
rec = R.get_recorder(recorder_id=rec.id)
return rec.list_tags()[ONLINE_TAG] Defensive patterns
Strategy: type-guard
Validate before calling
from qlib.workflow.online.utils import OnlineTool
def assert_get_tag_implemented(tool):
if type(tool).get_online_tag is OnlineTool.get_online_tag:
raise TypeError(f'{type(tool).__name__} must implement get_online_tag') Type guard
from qlib.workflow.online.utils import OnlineTool
def has_get_online_tag(tool) -> bool:
return type(tool).get_online_tag is not OnlineTool.get_online_tag Try / catch
try:
tag = tool.get_online_tag(rec)
except NotImplementedError:
tag = 'offline' # treat unknown as offline, or re-raise for strict flows Prevention
- Complete every OnlineTool override in one pass; partial tools fail late
- Write one subclass-wide unit test calling each abstract hook once
- Prefer OnlineToolR unless a custom backend is truly required
When it happens
Trigger: Calling OnlineTool().get_online_tag(recorder); running a custom OnlineTool subclass through OnlineManager flows that read tags (e.g. online_models implementations that delegate to get_online_tag); forgetting the override when porting OnlineToolR to another backend.
Common situations: Custom OnlineTool implementations for bespoke model registries; mixing base-class and recorder-based tool instances in one strategy; refactoring OnlineToolR and dropping a method.
Related errors
- Please implement the `set_online_tag` method.
- Please implement the `reset_online_tag` method.
- Please implement the `online_models` method.
- Please implement the `update_online_pred` method.
- Please implement the `get_all_stock` method
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/4733a2e806829586.
Report an issue: GitHub.