{"record":{"id":"2d5c55bc640a8aae","repo":"microsoft/qlib","slug":"please-implement-the-remove-method","errorCode":null,"errorMessage":"Please implement the `remove` method","messagePattern":"Please implement the `remove` method","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/utils/objm.py","lineNumber":88,"sourceCode":"        list the objects\n\n        Returns\n        -------\n        list:\n            the list of returned objects\n        \"\"\"\n        raise NotImplementedError(f\"Please implement the `list` method\")\n\n    def remove(self, fname=None):\n        \"\"\"remove.\n\n        Parameters\n        ----------\n        fname :\n            if file name is provided. specific file is removed\n            otherwise, The all the objects will be removed.\n        \"\"\"\n        raise NotImplementedError(f\"Please implement the `remove` method\")\n\n\nclass FileManager(ObjManager):\n    \"\"\"\n    Use file system to manage objects\n    \"\"\"\n\n    def __init__(self, path=None):\n        if path is None:\n            self.path = Path(self.create_path())\n        else:\n            self.path = Path(path).resolve()\n\n    def create_path(self) -> str:\n        try:\n            return tempfile.mkdtemp(prefix=str(C[\"file_manager_path\"]) + os.sep)\n        except AttributeError as attribute_e:\n            raise NotImplementedError(","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/utils/objm.py#L70-L106","documentation":"remove(fname=None) is the deletion method of the abstract ObjManager interface: with fname it deletes one object, without it deletes everything. The base stub raises NotImplementedError, so any delete on the abstract base or a subclass without a remove override fails immediately.","triggerScenarios":"ObjManager().remove('model_v1') or ObjManager().remove() (purge-all); calling mgr.remove(...) on a custom manager that never implemented deletion.","commonSituations":"Cache-cleanup jobs at the end of experiments; CI steps purging artifact directories; custom cloud-storage managers where deletion was deemed unnecessary until a retention policy arrived.","solutions":["Use FileManager, whose remove() deletes one file or clears its directory.","Implement remove(self, fname=None) in your subclass mapping to your backend's delete API.","Careful with the no-argument form: it purges ALL objects — prefer passing fname for targeted deletion."],"exampleFix":"// before\nObjManager().remove('model_v1')  # NotImplementedError\n\n// after\nFileManager(path='./objs').remove('model_v1')","handlingStrategy":"try-catch","validationCode":"from qlib.utils.objm import ObjManager\nif type(mgr).remove is ObjManager.remove:\n    raise RuntimeError('manager cannot remove objects; implement remove()')","typeGuard":"def supports_remove(mgr) -> bool:\n    return type(mgr).remove is not ObjManager.remove","tryCatchPattern":"try:\n    mgr.remove(fname)\nexcept NotImplementedError:\n    (Path(backup_dir) / fname).unlink(missing_ok=True)","preventionTips":["Implement remove() (single and purge-all forms) in custom managers; retention policies always arrive later.","Guard purge-all (fname=None) behind an explicit confirmation flag in your code."],"tags":["qlib","objm","abstract-method","notimplementederror","cleanup"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}