{"record":{"id":"50ed4a0c823a6ed8","repo":"microsoft/qlib","slug":"please-implement-the-update-online-pred-method","errorCode":null,"errorMessage":"Please implement the `update_online_pred` method.","messagePattern":"Please implement the `update_online_pred` method\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/workflow/online/utils.py","lineNumber":84,"sourceCode":"\n    def online_models(self) -> list:\n        \"\"\"\n        Get current `online` models\n\n        Returns:\n            list: a list of `online` models.\n        \"\"\"\n        raise NotImplementedError(f\"Please implement the `online_models` method.\")\n\n    def update_online_pred(self, to_date=None):\n        \"\"\"\n        Update the predictions of `online` models to to_date.\n\n        Args:\n            to_date (pd.Timestamp): the pred before this date will be updated. None for updating to the latest.\n\n        \"\"\"\n        raise NotImplementedError(f\"Please implement the `update_online_pred` method.\")\n\n\nclass OnlineToolR(OnlineTool):\n    \"\"\"\n    The implementation of OnlineTool based on (R)ecorder.\n    \"\"\"\n\n    def __init__(self, default_exp_name: str = None):\n        \"\"\"\n        Init OnlineToolR.\n\n        Args:\n            default_exp_name (str): the default experiment name.\n        \"\"\"\n        super().__init__()\n        self.default_exp_name = default_exp_name\n\n    def set_online_tag(self, tag, recorder: Union[Recorder, List]):","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/workflow/online/utils.py#L66-L102","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use OnlineToolR.update_online_pred, which builds PredUpdater for each online recorder (skipping recorders whose pred.pkl fails to load)","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","Wire the concrete tool into your strategy/OnlineManager before running routines"],"exampleFix":"# before\nclass MyTool(OnlineTool):\n    ...\n    # update_online_pred missing\n\n# after\nclass MyTool(OnlineTool):\n    ...\n    def update_online_pred(self, to_date=None):\n        # delegate to the recorder-based implementation\n        OnlineToolR(default_exp_name=self.exp).update_online_pred(to_date=to_date)","handlingStrategy":"type-guard","validationCode":"from qlib.workflow.online.utils import OnlineTool\n\ndef assert_update_pred_implemented(tool):\n    if type(tool).update_online_pred is OnlineTool.update_online_pred:\n        raise TypeError(f'{type(tool).__name__} must implement update_online_pred')","typeGuard":"from qlib.workflow.online.utils import OnlineTool\n\ndef can_update_pred(tool) -> bool:\n    return type(tool).update_online_pred is not OnlineTool.update_online_pred","tryCatchPattern":"try:\n    tool.update_online_pred(to_date=to_date)\nexcept NotImplementedError as e:\n    logger.warning('prediction update skipped: %s', e)","preventionTips":["Wire OnlineToolR into OnlineManager before running routines","If updates are intentionally unsupported, override with an explicit no-op","Smoke-test the full routine (prepare -> update -> collect) after wiring a new tool"],"tags":["qlib","online-tool","abstract-method","not-implemented"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}