{"record":{"id":"c85b12736b11dcff","repo":"microsoft/qlib","slug":"the-default-uri-is-not-set-in-qlib-config-c","errorCode":null,"errorMessage":"The default URI is not set in qlib.config.C","messagePattern":"The default URI is not set in qlib\\.config\\.C","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/workflow/expm.py","lineNumber":288,"sourceCode":"        \"\"\"\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.\n\n        Returns\n        -------\n        The tracking URI string.\n        \"\"\"\n        return self._active_exp_uri or self.default_uri\n\n    def list_experiments(self):","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/workflow/expm.py#L270-L306","documentation":"ExpManager.default_uri reads C['exp_manager']['kwargs']['uri'] from qlib's global config and raises this ValueError when either 'kwargs' or 'uri' is absent. Without a URI there is no tracking store, so the manager refuses to proceed rather than silently defaulting.","triggerScenarios":"Calling R.get_uri() or any experiment API before qlib.init(); overwriting C['exp_manager'] with a dict lacking kwargs.uri (e.g. C.exp_manager = {'class': 'MLflowExpManager'}); malformed YAML config passed to qrun/qlib.init missing the uri field.","commonSituations":"Forgetting qlib.init() in a notebook cell before using R; custom config dicts that drop the 'kwargs' level; code that mutates C.exp_manager directly instead of using set_exp_uri/default_uri setter.","solutions":["Call qlib.init() (or qlib.init(exp_manager={'class': 'MLflowExpManager', 'kwargs': {'uri': 'file:./mlruns'}})) before any R usage.","Set the URI explicitly: R.set_exp_uri('file:./mlruns') or the default_uri setter, which writes C.exp_manager['kwargs']['uri'].","Inspect qlib.config.C['exp_manager'] and repair the structure if a custom config replaced it."],"exampleFix":"# before\nfrom qlib.workflow import R  # qlib.init() never called\nR.get_uri()  # ValueError: default URI not set\n\n# after\nimport qlib\nqlib.init()\nR.get_uri()  # 'file:.../mlruns'","handlingStrategy":"validation","validationCode":"from qlib.config import C\nassert C.get('exp_manager', {}).get('kwargs', {}).get('uri'), 'run qlib.init() or set C.exp_manager[\"kwargs\"][\"uri\"] first'\nuri = R.get_uri()","typeGuard":null,"tryCatchPattern":"try:\n    uri = R.get_uri()\nexcept ValueError:\n    qlib.init()  # ensure default manager + uri exist\n    uri = R.get_uri()","preventionTips":["Call qlib.init() before any use of R or experiment APIs.","Set URIs through R.set_exp_uri / the default_uri setter instead of editing C by hand.","Keep exp_manager config shape {'class': ..., 'kwargs': {'uri': ...}} intact in custom configs."],"tags":["qlib","configuration","uri","init","value-error"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}