{"record":{"id":"03cc21cdad3cbb3d","repo":"microsoft/qlib","slug":"please-implement-the-load-obj-method","errorCode":null,"errorMessage":"Please implement the `load_obj` method","messagePattern":"Please implement the `load_obj` method","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/utils/objm.py","lineNumber":50,"sourceCode":"        obj_name_l : list of <obj, name>\n        \"\"\"\n        raise NotImplementedError(f\"Please implement the `save_objs` method\")\n\n    def load_obj(self, name: str) -> object:\n        \"\"\"\n        load object by name\n\n        Parameters\n        ----------\n        name : str\n            the name of the object\n\n        Returns\n        -------\n        object:\n            loaded object\n        \"\"\"\n        raise NotImplementedError(f\"Please implement the `load_obj` method\")\n\n    def exists(self, name: str) -> bool:\n        \"\"\"\n        if the object named `name` exists\n\n        Parameters\n        ----------\n        name : str\n            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:","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/utils/objm.py#L32-L68","documentation":"load_obj(name) is the read primitive of the abstract ObjManager interface; the base stub raises NotImplementedError. It fires when objects are loaded through the abstract base class or through a subclass that never implemented loading — a common failure for custom managers written write-only.","triggerScenarios":"ObjManager().load_obj('name'), or a custom manager implementing save_obj/save_objs but not load_obj; qlib internals calling obj_manager.load_obj(...) on an incompletely-configured manager.","commonSituations":"Restoring trained models/artifacts in a later session via a custom manager class; qlib workflow recorder code paths that fetch cached datasets/processors; upgrading qlib where the manager interface gained stricter abstractness.","solutions":["Use FileManager for local-disk persistence; its load_obj unpickles from self.path/name.","Implement load_obj(self, name) -> object in your subclass, returning the deserialized object.","Verify with hasattr/inspect before dispatching: ensure the manager instance overrides load_obj before calling it."],"exampleFix":"// before\nobj = ObjManager().load_obj('model_v1')  # NotImplementedError\n\n// after\nobj = FileManager(path='./objs').load_obj('model_v1')","handlingStrategy":"type-guard","validationCode":"from qlib.utils.objm import ObjManager\nassert type(mgr).load_obj is not ObjManager.load_obj, 'manager cannot load objects'","typeGuard":"def can_load(mgr) -> bool:\n    return type(mgr).load_obj is not ObjManager.load_obj","tryCatchPattern":"try:\n    obj = mgr.load_obj(name)\nexcept NotImplementedError:\n    obj = FileManager(path='./objs').load_obj(name)","preventionTips":["Write load_obj in custom managers first (reads are usually on the critical path) before save methods.","Integration-test save-then-load round trips for every custom ObjManager subclass."],"tags":["qlib","objm","abstract-method","notimplementederror","deserialization"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}