{"record":{"id":"4733a2e806829586","repo":"microsoft/qlib","slug":"please-implement-the-get-online-tag-method","errorCode":null,"errorMessage":"Please implement the `get_online_tag` method.","messagePattern":"Please implement the `get_online_tag` method\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/workflow/online/utils.py","lineNumber":54,"sourceCode":"        Set `tag` to the model to sign whether online.\n\n        Args:\n            tag (str): the tags in `ONLINE_TAG`, `OFFLINE_TAG`\n            recorder (Union[list,object]): the model's recorder\n        \"\"\"\n        raise NotImplementedError(f\"Please implement the `set_online_tag` method.\")\n\n    def get_online_tag(self, recorder: object) -> str:\n        \"\"\"\n        Given a model recorder and return its online tag.\n\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.","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/workflow/online/utils.py#L36-L72","documentation":"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.","triggerScenarios":"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.","commonSituations":"Custom OnlineTool implementations for bespoke model registries; mixing base-class and recorder-based tool instances in one strategy; refactoring OnlineToolR and dropping a method.","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"],"exampleFix":"# before\nclass MyTool(OnlineTool):\n    def set_online_tag(self, tag, recorder):\n        ...\n    # get_online_tag missing\n\n# after\nclass MyTool(OnlineTool):\n    def set_online_tag(self, tag, recorder):\n        ...\n    def get_online_tag(self, recorder) -> str:\n        rec = R.get_recorder(recorder_id=rec.id)\n        return rec.list_tags()[ONLINE_TAG]","handlingStrategy":"type-guard","validationCode":"from qlib.workflow.online.utils import OnlineTool\n\ndef assert_get_tag_implemented(tool):\n    if type(tool).get_online_tag is OnlineTool.get_online_tag:\n        raise TypeError(f'{type(tool).__name__} must implement get_online_tag')","typeGuard":"from qlib.workflow.online.utils import OnlineTool\n\ndef has_get_online_tag(tool) -> bool:\n    return type(tool).get_online_tag is not OnlineTool.get_online_tag","tryCatchPattern":"try:\n    tag = tool.get_online_tag(rec)\nexcept NotImplementedError:\n    tag = 'offline'  # treat unknown as offline, or re-raise for strict flows","preventionTips":["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"],"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"}