microsoft/qlib · error · ValueError

Error: {e}. Something went wrong when deleting experiment. P

Error message

Error: {e}. Something went wrong when deleting experiment. Please check if the name/id of the experiment is correct.

What it means

Raised by ExpManager.delete_exp when the underlying MLflow delete_experiment call fails. The message embeds the original MlflowException text; typical root causes are an experiment id that does not exist, a name lookup returning None (re-raised internally as MlflowException), or backend errors during the delete call.

Source

Thrown at qlib/workflow/expm.py:418

        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")
        order_by = kwargs.get("order_by")
        return self.client.search_runs(experiment_ids, filter_string, run_view_type, max_results, order_by)

    def delete_exp(self, experiment_id=None, experiment_name=None):
        assert (
            experiment_id is not None or experiment_name is not None
        ), "Please input a valid experiment id or name before deleting."
        try:
            if experiment_id is not None:
                self.client.delete_experiment(experiment_id)
            else:
                experiment = self.client.get_experiment_by_name(experiment_name)
                if experiment is None:
                    raise MlflowException("No valid experiment has been found.")
                self.client.delete_experiment(experiment.experiment_id)
        except MlflowException as e:
            raise ValueError(
                f"Error: {e}. Something went wrong when deleting experiment. Please check if the name/id of the experiment is correct."
            ) from e

    def list_experiments(self):
        # retrieve all the existing experiments
        mlflow_version = int(mlflow.__version__.split(".", maxsplit=1)[0])
        if mlflow_version >= 2:
            exps = self.client.search_experiments(view_type=ViewType.ACTIVE_ONLY)
        else:
            exps = self.client.list_experiments(view_type=ViewType.ACTIVE_ONLY)  # pylint: disable=E1101
        experiments = dict()
        for exp in exps:
            experiment = MLflowExperiment(exp.experiment_id, exp.name, self.uri)
            experiments[exp.name] = experiment
        return experiments

View on GitHub (pinned to 79633dd950)

Solutions

  1. Confirm the experiment exists before deleting: use list_experiments() to get the exact id/name and retry with those values
  2. Check the tracking URI is the one where the experiment lives before calling delete_exp
  3. Treat 'not found' as success in cleanup code: catch ValueError, inspect e.__cause__, and ignore RESOURCE_DOES_NOT_EXIST-style MlflowExceptions
  4. If the experiment is already soft-deleted, skip the call or use client.restore_experiment first if you want to force-delete

Example fix

# before
R.delete_exp(experiment_name='alpha158')  # ValueError on wrong name

# after
exps = R.list_experiments()
if 'alpha158' in exps:
    R.delete_exp(experiment_id=exps['alpha158'].id)
else:
    print('already gone')
Defensive patterns

Strategy: try-catch

Validate before calling

from qlib.workflow import R

def delete_exp_safe(name: str):
    exps = R.list_experiments()
    if name not in exps:
        return False  # nothing to delete
    R.delete_exp(experiment_id=exps[name].id)
    return True

Try / catch

try:
    R.delete_exp(experiment_name=name)
except ValueError as e:
    msg = str(getattr(e.__cause__, 'message', e.__cause__) or e)
    if 'not exist' in msg.lower() or 'not found' in msg.lower():
        pass  # already gone; idempotent cleanup
    else:
        raise

Prevention

When it happens

Trigger: Calling delete_exp(experiment_id=<wrong-id>) where the id is unknown to the MLflow backend; calling delete_exp(experiment_name=<name that does not exist>); MLflow server rejecting the delete (permissions, network, malformed id); deleting an already-deleted experiment.

Common situations: Cleanup scripts that hard-code stale experiment ids; re-running an idempotent teardown after the experiment was already removed; tracking URI mismatch so the delete targets the wrong backend where the experiment never existed.

Related errors


AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15). Data as JSON: /api/errors/7b5db1bd74f28acc. Report an issue: GitHub.