Azure环境下调用MLflow search_runs时出现BAD_REQUEST错误
问题解决:MLflow search_runs在Azure环境中报BAD_REQUEST错误
错误原因
Azure ML原生的Experiment ID(短格式,如5b649b3c-3b8f-497a-bb4f)和MLflow要求的完整UUID格式不匹配,导致search_runs接口无法识别输入的ID。
解决方案
方案1:直接使用实验名称查询
无需获取Azure ML的Experiment ID,直接传入实验名称即可,MLflow在Azure环境中可直接识别:
import mlflow from azureml.core import Experiment, Workspace experiment_name = 'housing-lin-mlflow' experiment = Experiment(ws, experiment_name) # 改用experiment_names参数传入实验名称 runs = mlflow.search_runs(experiment_names=[experiment_name])
方案2:获取MLflow维护的完整实验ID
通过MlflowClient获取MLflow自身管理的实验ID(完整UUID格式),再传入search_runs:
import mlflow from mlflow import MlflowClient from azureml.core import Experiment, Workspace experiment_name = 'housing-lin-mlflow' client = MlflowClient() # 获取MLflow对应的实验对象 mlflow_experiment = client.get_experiment_by_name(experiment_name) # 使用MLflow的完整实验ID查询 runs = mlflow.search_runs(experiment_ids=[mlflow_experiment.experiment_id])
验证说明
两种方案均适配MLflow 1.28.0版本,可正常获取Azure Studio中已成功运行的任务记录。
内容的提问来源于stack exchange,提问作者300
相关产品推荐
相关产品推荐

