microsoft/qlib · error · ValueError
No valid experiment has been found, please make sure the inp
Error message
No valid experiment has been found, please make sure the input experiment id is correct.
What it means
Raised by MLflowExpManager._get_exp when MlflowClient.get_experiment(experiment_id) fails or returns a DELETED experiment; the MlflowException is chained into this ValueError. The id does not map to a live experiment in the tracking store reachable at the current URI.
Source
Thrown at qlib/workflow/expm.py:383
def _get_exp(self, experiment_id=None, experiment_name=None):
"""
Method for getting or creating an experiment. It will try to first get a valid experiment, if exception occurs, it will
raise errors.
"""
assert (
experiment_id is not None or experiment_name is not None
), "Please input at least one of experiment/recorder id or name before retrieving experiment/recorder."
if experiment_id is not None:
try:
# NOTE: the mlflow's experiment_id must be str type...
# https://www.mlflow.org/docs/latest/python_api/mlflow.tracking.html#mlflow.tracking.MlflowClient.get_experiment
exp = self.client.get_experiment(experiment_id)
if exp.lifecycle_stage.upper() == "DELETED":
raise MlflowException("No valid experiment has been found.")
experiment = MLflowExperiment(exp.experiment_id, exp.name, self.uri)
return experiment
except MlflowException as e:
raise ValueError(
"No valid experiment has been found, please make sure the input experiment id is correct."
) from e
elif experiment_name is not None:
try:
exp = self.client.get_experiment_by_name(experiment_name)
if exp is None or exp.lifecycle_stage.upper() == "DELETED":
raise MlflowException("No valid experiment has been found.")
experiment = MLflowExperiment(exp.experiment_id, experiment_name, self.uri)
return experiment
except MlflowException as e:
raise ValueError(
"No valid experiment has been found, please make sure the input experiment name is correct."
) from e
def search_records(self, experiment_ids=None, **kwargs):
filter_string = "" if kwargs.get("filter_string") is None else kwargs.get("filter_string")
run_view_type = 1 if kwargs.get("run_view_type") is None else kwargs.get("run_view_type")
max_results = 100000 if kwargs.get("max_results") is None else kwargs.get("max_results")View on GitHub (pinned to 79633dd950)
Solutions
- Check what exists: R.list_experiments() shows live name->experiment mappings with ids.
- Confirm the tracking URI (R.get_uri()) matches the store where the experiment was created.
- Pass experiment_id as a string; if you have a name, use experiment_name instead.
- If soft-deleted in MLflow, restore the experiment before querying it.
Example fix
# before exp = R.get_exp(experiment_id=3) # ValueError: no valid experiment # after exps = R.list_experiments() exp = R.get_exp(experiment_name=next(iter(exps))) # verified name lookup
Defensive patterns
Strategy: validation
Validate before calling
exps = R.list_experiments() # {name: Experiment}
if str(experiment_id) not in {str(e.id) for e in exps.values()}:
raise KeyError(f'experiment {experiment_id} not live; live ids: {[e.id for e in exps.values()]}')
exp = R.get_exp(experiment_id=str(experiment_id)) Type guard
def experiment_id_live(mgr, exp_id) -> bool:
e = mgr.client.get_experiment(str(exp_id))
return e is not None and e.lifecycle_stage.upper() != 'DELETED' Try / catch
try:
exp = R.get_exp(experiment_id=str(exp_id))
except ValueError:
exps = R.list_experiments()
exp = next(iter(exps.values())) # recover via a live experiment Prevention
- Take experiment ids from R.list_experiments()/get_exp() output, not from memory or logs.
- Pass ids as strings; MLflow treats experiment_id as str.
- Keep the tracking URI fixed, and remember delete_exp soft-deletes (id stays but unusable).
When it happens
Trigger: R.get_exp(experiment_id='7') where experiment 7 does not exist, was soft-deleted by delete_exp, or lives under a different tracking URI; passing an experiment NAME string where the numeric id is expected; reading the id as int instead of str (MLflow requires str).
Common situations: URI switched between file stores after experiments were created; retrying an id captured before R.delete_exp(); parsing experiment ids from logs with type coercion to int.
Related errors
- No valid recorder has been found, please make sure the input
- No valid recorder has been found, please make sure the input
- Error: {e}. Something went wrong when deleting recorder. Ple
- This type of input {rtype} is not supported
- Get Unexpected arguments {kwargs}
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/6ad329d36f708db2.
Report an issue: GitHub.