{"record":{"id":"8c9913227eccdac1","repo":"microsoft/qlib","slug":"please-implement-the-list-method","errorCode":null,"errorMessage":"Please implement the `list` method","messagePattern":"Please implement the `list` method","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/utils/objm.py","lineNumber":77,"sourceCode":"            name of the objecT\n\n        Returns\n        -------\n        bool:\n            If the object exists\n        \"\"\"\n        raise NotImplementedError(f\"Please implement the `exists` method\")\n\n    def list(self) -> list:\n        \"\"\"\n        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","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/utils/objm.py#L59-L95","documentation":"list() enumerates all stored object names in the abstract ObjManager interface; the base stub raises NotImplementedError. Only concrete managers can enumerate their backend (FileManager lists files in its directory). The failure indicates the abstract base or an incomplete subclass was asked to enumerate.","triggerScenarios":"ObjManager().list(), or mgr.list() where mgr is a custom ObjManager subclass without a list() override — commonly in cleanup or inventory scripts.","commonSituations":"Maintenance/cleanup scripts that iterate all cached artifacts; dashboards listing available models; custom DB-backed managers implemented with only save/load during initial development.","solutions":["Use FileManager (list() returns the names of files it manages).","Implement list(self) -> list in your subclass returning all names present in the backend.","Interim workaround: track names yourself at save time and iterate that record instead of calling list()."],"exampleFix":"// before\nnames = ObjManager().list()  # NotImplementedError\n\n// after\nnames = FileManager(path='./objs').list()","handlingStrategy":"try-catch","validationCode":"from qlib.utils.objm import ObjManager\nif type(mgr).list is ObjManager.list:\n    names = []  # or raise early with a clear message\nelse:\n    names = mgr.list()","typeGuard":"def supports_list(mgr) -> bool:\n    return type(mgr).list is not ObjManager.list","tryCatchPattern":"try:\n    names = mgr.list()\nexcept NotImplementedError:\n    names = [p.name for p in Path(backup_dir).iterdir()]  # fallback enumeration","preventionTips":["Implement list() in custom managers even if trivial (return sorted stored keys).","Keep your own registry of saved names when backend enumeration is expensive."],"tags":["qlib","objm","abstract-method","notimplementederror","listing"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}