{"record":{"id":"c521cbb35ab319b8","repo":"microsoft/qlib","slug":"please-implement-the-delete-recorder-method","errorCode":null,"errorMessage":"Please implement the `delete_recorder` method.","messagePattern":"Please implement the `delete_recorder` method\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/workflow/exp.py","lineNumber":112,"sourceCode":"        Returns\r\n        -------\r\n        A pandas.DataFrame of records, where each metric, parameter, and tag\r\n        are expanded into their own columns named metrics.*, params.*, and tags.*\r\n        respectively. For records that don't have a particular metric, parameter, or tag, their\r\n        value will be (NumPy) Nan, None, or None respectively.\r\n        \"\"\"\r\n        raise NotImplementedError(f\"Please implement the `search_records` method.\")\r\n\r\n    def delete_recorder(self, recorder_id):\r\n        \"\"\"\r\n        Create a recorder for each experiment.\r\n\r\n        Parameters\r\n        ----------\r\n        recorder_id : str\r\n            the id of the recorder to be deleted.\r\n        \"\"\"\r\n        raise NotImplementedError(f\"Please implement the `delete_recorder` method.\")\r\n\r\n    def get_recorder(self, recorder_id=None, recorder_name=None, create: bool = True, start: bool = False) -> Recorder:\r\n        \"\"\"\r\n        Retrieve a Recorder for user. When user specify recorder id and name, the method will try to return the\r\n        specific recorder. When user does not provide recorder id or name, the method will try to return the current\r\n        active recorder. The `create` argument determines whether the method will automatically create a new recorder\r\n        according to user's specification if the recorder hasn't been created before.\r\n\r\n        * If `create` is True:\r\n\r\n            * If `active recorder` exists:\r\n\r\n                * no id or name specified, return the active recorder.\r\n                * if id or name is specified, return the specified recorder. If no such exp found, create a new recorder with given id or name. If `start` is set to be True, the recorder is set to be active.\r\n\r\n            * If `active recorder` not exists:\r\n\r\n                * no id or name specified, create a new recorder.\r","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/workflow/exp.py#L94-L130","documentation":"Experiment.delete_recorder is an abstract stub in the Experiment interface; it must remove the recorder with the given recorder_id. The NotImplementedError fires when the base class (or an incomplete subclass) is used, meaning the deletion never reached a real tracking backend.","triggerScenarios":"exp.delete_recorder(recorder_id) on a directly built Experiment; custom backend subclass without a delete_recorder override; R.delete_recorder(...) routed through such a subclass.","commonSituations":"Cleanup scripts that iterate experiments calling delete on each; writing a minimal custom backend for logging only and later needing deletion; subclasses copied from examples that omit delete methods.","solutions":["Run deletion through the MLflow-backed experiment obtained from R.get_exp().","Implement delete_recorder(self, recorder_id) in your subclass, calling the backend's delete API.","Alternatively delete the run directly in the backend (e.g. mlflow client delete_run) if you bypass qlib."],"exampleFix":"# before\nExperiment('1', 'e').delete_recorder('run_id')  # NotImplementedError\n\n# after\nexp = R.get_exp(experiment_name='my_exp')\nexp.delete_recorder('run_id')  # MLflowExperiment implementation","handlingStrategy":"type-guard","validationCode":"from qlib.workflow.exp import Experiment\nassert exp.__class__.delete_recorder is not Experiment.delete_recorder, 'deletion unsupported by backend'","typeGuard":"def can_delete_recorders(exp) -> bool:\n    from qlib.workflow.exp import Experiment\n    return exp.__class__.delete_recorder is not Experiment.delete_recorder","tryCatchPattern":null,"preventionTips":["Run deletions only on experiments from R.get_exp().","Make cleanup scripts check the capability before calling delete."],"tags":["qlib","abstract-method","not-implemented","recorder","cleanup"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}