{"record":{"id":"ea43938455b5376d","repo":"microsoft/qlib","slug":"please-implement-the-reset-online-tag-method","errorCode":null,"errorMessage":"Please implement the `reset_online_tag` method.","messagePattern":"Please implement the `reset_online_tag` method\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/workflow/online/utils.py","lineNumber":65,"sourceCode":"\n        Args:\n            recorder (Object): the model's recorder\n\n        Returns:\n            str: the online tag\n        \"\"\"\n        raise NotImplementedError(f\"Please implement the `get_online_tag` method.\")\n\n    def reset_online_tag(self, recorder: Union[list, object]):\n        \"\"\"\n        Offline all models and set the recorders to 'online'.\n\n        Args:\n            recorder (Union[list,object]):\n                the recorder you want to reset to 'online'.\n\n        \"\"\"\n        raise NotImplementedError(f\"Please implement the `reset_online_tag` method.\")\n\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        \"\"\"","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/workflow/online/utils.py#L47-L83","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["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","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)","Check that OnlineManager/strategy construction is not silently falling back to OnlineTool()"],"exampleFix":"# before\nstrategy = MyStrategy('my_exp')  # defaults to OnlineTool()\nstrategy.prepare_online_models(models)  # -> NotImplementedError in reset_online_tag\n\n# after\nfrom qlib.workflow.online.utils import OnlineToolR\nstrategy = MyStrategy('my_exp')\nstrategy.tool = OnlineToolR(default_exp_name='my_exp')\nstrategy.prepare_online_models(models)","handlingStrategy":"type-guard","validationCode":"from qlib.workflow.online.utils import OnlineTool\n\ndef assert_reset_tag_implemented(tool):\n    if type(tool).reset_online_tag is OnlineTool.reset_online_tag:\n        raise TypeError(f'{type(tool).__name__} must implement reset_online_tag')","typeGuard":"from qlib.workflow.online.utils import OnlineTool\n\ndef has_reset_online_tag(tool) -> bool:\n    return type(tool).reset_online_tag is not OnlineTool.reset_online_tag","tryCatchPattern":"try:\n    strategy.prepare_online_models(models)\nexcept NotImplementedError as e:\n    raise TypeError('strategy.tool is abstract; assign OnlineToolR first') from e","preventionTips":["Assign a concrete tool to strategy.tool right after construction","Do not rely on OnlineStrategy's default OnlineTool() for anything beyond type stubs","Test prepare_online_models once with real recorders before going online"],"tags":["qlib","online-tool","abstract-method","not-implemented"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}