{"record":{"id":"25697dc2b96b4788","repo":"microsoft/qlib","slug":"please-implement-the-delete-exp-method","errorCode":null,"errorMessage":"Please implement the `delete_exp` method.","messagePattern":"Please implement the `delete_exp` method\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/workflow/expm.py","lineNumber":280,"sourceCode":"\n        Raises\n        ------\n        ValueError\n        \"\"\"\n        raise NotImplementedError(f\"Please implement the `_get_exp` method\")\n\n    def delete_exp(self, experiment_id=None, experiment_name=None):\n        \"\"\"\n        Delete an experiment.\n\n        Parameters\n        ----------\n        experiment_id  : str\n            the experiment id.\n        experiment_name  : str\n            the experiment name.\n        \"\"\"\n        raise NotImplementedError(f\"Please implement the `delete_exp` method.\")\n\n    @property\n    def default_uri(self):\n        \"\"\"\n        Get the default tracking URI from qlib.config.C\n        \"\"\"\n        if \"kwargs\" not in C.exp_manager or \"uri\" not in C.exp_manager[\"kwargs\"]:\n            raise ValueError(\"The default URI is not set in qlib.config.C\")\n        return C.exp_manager[\"kwargs\"][\"uri\"]\n\n    @default_uri.setter\n    def default_uri(self, value):\n        C.exp_manager.setdefault(\"kwargs\", {})[\"uri\"] = value\n\n    @property\n    def uri(self):\n        \"\"\"\n        Get the default tracking URI or current URI.","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/workflow/expm.py#L262-L298","documentation":"ExpManager.delete_exp is abstract: concrete managers delete the experiment identified by experiment_id or experiment_name. The base stub raises NotImplementedError, meaning no backend (normally MLflowExpManager, which calls client.delete_experiment) executed the deletion.","triggerScenarios":"R.delete_exp(experiment_name='x') or exp_manager.delete_exp(...) where the configured manager class is the base or an incomplete subclass.","commonSituations":"Housekeeping scripts pruning old experiments while a custom manager backend is configured; subclass implementations that cover listing but not deletion.","solutions":["Restore the default MLflowExpManager so deletion reaches MLflow's delete_experiment.","Implement delete_exp(self, experiment_id=None, experiment_name=None) in your subclass.","Or delete directly through the backend API (mlflow.tracking.MlflowClient.delete_experiment) as a stopgap."],"exampleFix":"# before\nExpManager().delete_exp(experiment_name='old')  # NotImplementedError\n\n# after\nR.delete_exp(experiment_name='old')  # with default MLflowExpManager","handlingStrategy":"type-guard","validationCode":"from qlib.workflow.expm import ExpManager\nassert R.exp_manager.__class__.delete_exp is not ExpManager.delete_exp, 'deletion unsupported'","typeGuard":"def manager_can_delete(mgr) -> bool:\n    from qlib.workflow.expm import ExpManager\n    return mgr.__class__.delete_exp is not ExpManager.delete_exp","tryCatchPattern":null,"preventionTips":["Delete experiments via R.delete_exp with the default MLflow manager.","Note MLflow deletion is soft: ids remain but lifecycle_stage becomes DELETED."],"tags":["qlib","abstract-method","not-implemented","exp-manager","cleanup"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}