{"record":{"id":"3d16efb0a4c4edba","repo":"microsoft/qlib","slug":"please-implement-the-load-object-method","errorCode":null,"errorMessage":"Please implement the `load_object` method.","messagePattern":"Please implement the `load_object` method\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/workflow/recorder.py","lineNumber":103,"sourceCode":"        artifact_path=None : str\r\n            the relative path for the artifact to be stored in the URI.\r\n        \"\"\"\r\n        raise NotImplementedError(f\"Please implement the `save_objects` method.\")\r\n\r\n    def load_object(self, name):\r\n        \"\"\"\r\n        Load objects such as prediction file or model checkpoints.\r\n\r\n        Parameters\r\n        ----------\r\n        name : str\r\n            name of the file to be loaded.\r\n\r\n        Returns\r\n        -------\r\n        The saved object.\r\n        \"\"\"\r\n        raise NotImplementedError(f\"Please implement the `load_object` method.\")\r\n\r\n    def start_run(self):\r\n        \"\"\"\r\n        Start running or resuming the Recorder. The return value can be used as a context manager within a `with` block;\r\n        otherwise, you must call end_run() to terminate the current run. (See `ActiveRun` class in mlflow)\r\n\r\n        Returns\r\n        -------\r\n        An active running object (e.g. mlflow.ActiveRun object).\r\n        \"\"\"\r\n        raise NotImplementedError(f\"Please implement the `start_run` method.\")\r\n\r\n    def end_run(self):\r\n        \"\"\"\r\n        End an active Recorder.\r\n        \"\"\"\r\n        raise NotImplementedError(f\"Please implement the `end_run` method.\")\r\n\r","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/workflow/recorder.py#L85-L121","documentation":"Recorder.load_object is the abstract method that loads a previously saved artifact (e.g. pred.pkl, model checkpoint) from the recorder's artifact store; MLflowRecorder implements it via mlflow's download/load. The base class raises NotImplementedError, so the error indicates load_object was invoked on the abstract Recorder or on a custom subclass that never implemented it.","triggerScenarios":"Calling recorder.load_object('pred.pkl') on a base Recorder instance; a custom Recorder backend missing the override; helper code (RecordTemp.load, collectors, PredUpdater) receiving an abstract recorder because the recorder factory fell back to the base class.","commonSituations":"Writing a custom tracking backend; test fixtures stubbing Recorder without load_object; accessing recorders before any MLflow run exists so the resolved object is the abstract default.","solutions":["Obtain recorders through the working API (R.get_recorder / active run) so you get an MLflowRecorder whose load_object works","Implement load_object(self, name) in your Recorder subclass returning the deserialized object from the artifact URI","Ensure the object was actually saved first — loading before save_objects would also fail, but with this error if the recorder is abstract"],"exampleFix":"# before\nrec = Recorder(...)         # abstract\npred = rec.load_object('pred.pkl')  # NotImplementedError\n\n# after\nwith R.start('my_exp'):\n    rec = R.get_recorder()\n    pred = rec.load_object('pred.pkl')","handlingStrategy":"type-guard","validationCode":"from qlib.workflow.recorder import Recorder\n\ndef assert_loadable(rec):\n    if type(rec).load_object is Recorder.load_object:\n        raise TypeError(f'{type(rec).__name__} does not implement load_object')","typeGuard":"from qlib.workflow.recorder import Recorder\n\ndef can_load_objects(rec) -> bool:\n    return type(rec).load_object is not Recorder.load_object","tryCatchPattern":"try:\n    obj = rec.load_object('pred.pkl')\nexcept NotImplementedError as e:\n    raise TypeError(f'abstract recorder cannot load artifacts: {e}') from e","preventionTips":["Pull recorders from active runs via R.get_recorder, never construct Recorder","Verify the artifact exists first: name in rec.list_artifacts() before load_object","Implement all abstract Recorder methods when adding a custom backend"],"tags":["qlib","recorder","abstract-method","not-implemented"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}