{"record":{"id":"5bd6086bda4c6ed4","repo":"microsoft/qlib","slug":"please-don-t-reinitialize-qlib-if-qlibrecorder-is","errorCode":null,"errorMessage":"Please don't reinitialize Qlib if QlibRecorder is already activated. Otherwise, the experiment stored location will be modified.","messagePattern":"Please don't reinitialize Qlib if QlibRecorder is already activated\\. Otherwise, the experiment stored location will be modified\\.","errorType":"exception","errorClass":"RecorderInitializationError","httpStatus":null,"severity":"error","filePath":"qlib/workflow/__init__.py","lineNumber":665,"sourceCode":"\n        Parameters\n        ----------\n        keyword argument:\n            name1=value1, name2=value2, ...\n        \"\"\"\n        self.get_exp(start=True).get_recorder(start=True).set_tags(**kwargs)\n\n\nclass RecorderWrapper(Wrapper):\n    \"\"\"\n    Wrapper class for QlibRecorder, which detects whether users reinitialize qlib when already starting an experiment.\n    \"\"\"\n\n    def register(self, provider):\n        if self._provider is not None:\n            expm = getattr(self._provider, \"exp_manager\")\n            if expm.active_experiment is not None:\n                raise RecorderInitializationError(\n                    \"Please don't reinitialize Qlib if QlibRecorder is already activated. Otherwise, the experiment stored location will be modified.\"\n                )\n        self._provider = provider\n\n\nimport sys\n\nif sys.version_info >= (3, 9):\n    from typing import Annotated\n\n    QlibRecorderWrapper = Annotated[QlibRecorder, RecorderWrapper]\nelse:\n    QlibRecorderWrapper = QlibRecorder\n\n# global record\nR: QlibRecorderWrapper = RecorderWrapper()\n","sourceCodeStart":647,"sourceCodeEnd":682,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/workflow/__init__.py#L647-L682","documentation":"Error \"Please don't reinitialize Qlib if QlibRecorder is already activated. Otherwise, the experiment stored location will be modified.\" thrown in microsoft/qlib.","triggerScenarios":"This error is raised at qlib/workflow/__init__.py:665 when the guard condition fails: \"don't reinitialize Qlib if QlibRecorder is already activated\". It triggers when the code path receives input or a state that violates the precondition checked at this point — e.g. an unimplemented abstract method being called, an unsupported argument type/value, or an invalid configuration. To avoid it, satisfy the documented precondition before this call: implement the required method in your subclass, or pass a supported value of the expected type as described by the message.","commonSituations":"See trigger scenarios.","solutions":["Do not call qlib.init() again after a QlibRecorder has been activated.","Restart your process and initialize qlib only once before starting the recorder."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}