microsoft/qlib · error · NotImplementedError
Please implement the `_get_exp` method
Error message
Please implement the `_get_exp` method
What it means
_get_exp is the protected retrieval hook of ExpManager: concrete managers resolve experiment_id/experiment_name to an Experiment or raise ValueError. The base body raises NotImplementedError, so this error indicates the lookup ran on an abstract or incompletely implemented manager rather than MLflowExpManager.
Source
Thrown at qlib/workflow/expm.py:267
Get specific experiment by name or id. If it does not exist, raise ValueError.
Parameters
----------
experiment_id :
The id of experiment
experiment_name :
The name of experiment
Returns
-------
Experiment:
The searched experiment
Raises
------
ValueError
"""
raise NotImplementedError(f"Please implement the `_get_exp` method")
def delete_exp(self, experiment_id=None, experiment_name=None):
"""
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.CView on GitHub (pinned to 79633dd950)
Solutions
- Ensure qlib.init uses MLflowExpManager (default) so _get_exp resolves via client.get_experiment.
- Implement _get_exp(self, experiment_id=None, experiment_name=None) in your subclass returning your Experiment type or raising ValueError.
- Use the public R.get_exp / exp_manager.get_exp API and implement every private hook they depend on.
Example fix
# before
class MyManager(ExpManager):
pass
exp = MyManager().get_exp(experiment_name='e') # base _get_exp -> NotImplementedError
# after
class MyManager(ExpManager):
def _get_exp(self, experiment_id=None, experiment_name=None):
exp = self.client.get_experiment_by_name(experiment_name) if experiment_name else self.client.get_experiment(experiment_id)
if exp is None:
raise ValueError('No valid experiment has been found')
return MyExperiment(exp.experiment_id, exp.name, self.uri) Defensive patterns
Strategy: type-guard
Validate before calling
from qlib.workflow.expm import ExpManager assert R.exp_manager.__class__._get_exp is not ExpManager._get_exp, 'experiment lookup not implemented'
Type guard
def manager_can_get_exp(mgr) -> bool:
from qlib.workflow.expm import ExpManager
return mgr.__class__._get_exp is not ExpManager._get_exp Prevention
- Implement private hooks (_get_exp, _start_exp, _end_exp) in any custom manager, since public methods delegate to them.
- Use R.get_exp instead of touching _get_exp directly.
When it happens
Trigger: R.get_exp(...) delegating to a manager subclass that overrides get_exp but not _get_exp; directly invoking exp_manager._get_exp(...) in custom code or tests.
Common situations: Writing a custom manager backend and missing the private hook despite implementing the public API; scaffolding generated by copying only part of MLflowExpManager.
Related errors
- Please implement the `_get_recorder` method
- Please implement the `start_exp` method.
- Please implement the `end_exp` method.
- Please implement the `create_exp` method.
- Please implement the `search_records` method.
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/86aa9c82d8e690c1.
Report an issue: GitHub.