microsoft/qlib · error · ValueError
The default URI is not set in qlib.config.C
Error message
The default URI is not set in qlib.config.C
What it means
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.
Source
Thrown at qlib/workflow/expm.py:288
"""
Delete an experiment.
Parameters
----------
experiment_id : str
the experiment id.
experiment_name : str
the experiment name.
"""
raise NotImplementedError(f"Please implement the `delete_exp` method.")
@property
def default_uri(self):
"""
Get the default tracking URI from qlib.config.C
"""
if "kwargs" not in C.exp_manager or "uri" not in C.exp_manager["kwargs"]:
raise ValueError("The default URI is not set in qlib.config.C")
return C.exp_manager["kwargs"]["uri"]
@default_uri.setter
def default_uri(self, value):
C.exp_manager.setdefault("kwargs", {})["uri"] = value
@property
def uri(self):
"""
Get the default tracking URI or current URI.
Returns
-------
The tracking URI string.
"""
return self._active_exp_uri or self.default_uri
def list_experiments(self):View on GitHub (pinned to 79633dd950)
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.
Example fix
# before from qlib.workflow import R # qlib.init() never called R.get_uri() # ValueError: default URI not set # after import qlib qlib.init() R.get_uri() # 'file:.../mlruns'
Defensive patterns
Strategy: validation
Validate before calling
from qlib.config import C
assert C.get('exp_manager', {}).get('kwargs', {}).get('uri'), 'run qlib.init() or set C.exp_manager["kwargs"]["uri"] first'
uri = R.get_uri() Try / catch
try:
uri = R.get_uri()
except ValueError:
qlib.init() # ensure default manager + uri exist
uri = R.get_uri() Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- inner_order_indicators is necessary in un-atomic executor
- This type of input {rtype} is not supported
- Get Unexpected arguments {kwargs}
- weight_position is {}, weight_position is not in the range o
- {limit[0]} is not supported
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/c85b12736b11dcff.
Report an issue: GitHub.