microsoft/qlib · error · NotImplementedError
Please implement the `load_obj` method
Error message
Please implement the `load_obj` method
What it means
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.
Source
Thrown at qlib/utils/objm.py:50
obj_name_l : list of <obj, name>
"""
raise NotImplementedError(f"Please implement the `save_objs` method")
def load_obj(self, name: str) -> object:
"""
load object by name
Parameters
----------
name : str
the name of the object
Returns
-------
object:
loaded object
"""
raise NotImplementedError(f"Please implement the `load_obj` method")
def exists(self, name: str) -> bool:
"""
if the object named `name` exists
Parameters
----------
name : str
name of the objecT
Returns
-------
bool:
If the object exists
"""
raise NotImplementedError(f"Please implement the `exists` method")
def list(self) -> list:View on GitHub (pinned to 79633dd950)
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.
Example fix
// before
obj = ObjManager().load_obj('model_v1') # NotImplementedError
// after
obj = FileManager(path='./objs').load_obj('model_v1') Defensive patterns
Strategy: type-guard
Validate before calling
from qlib.utils.objm import ObjManager assert type(mgr).load_obj is not ObjManager.load_obj, 'manager cannot load objects'
Type guard
def can_load(mgr) -> bool:
return type(mgr).load_obj is not ObjManager.load_obj Try / catch
try:
obj = mgr.load_obj(name)
except NotImplementedError:
obj = FileManager(path='./objs').load_obj(name) Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Please implement `save_obj`
- Please implement the `save_objs` method
- Please implement the `exists` method
- Please implement the `list` method
- Please implement the `remove` method
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/03cc21cdad3cbb3d.
Report an issue: GitHub.