带有MLOps的AutoML导致出现错误-消息:无法找到提供的model_path

问题描述

我尝试使用一个简单的数据集使用Azure的automl功能训练一个模型,该模型在手动或通过笔记本进行操作时效果很好,但在Azure Devops管道中不起作用。创建了一个天蓝色的devops管道,并具有与ML工作区所需的服务连接。

在下面的python代码中,要求的文件已上传,但在运行以下命令进行注册时却找不到模型,而在下面说明的代码中将其上传:

我正在尝试通过az cli命令而不是通过python训练模型。任何建议。引用https://github.com/SaschaDittmann/MLOps-Lab作为参考,但更改为automl,因为此git repo不适用于auto ml,但其余步骤相同。

az ml模型寄存器-g $(azureml.resourceGroup)-w $(azureml.workspaceName)-n $(model.Name)-f元数据/run.json --asset-path输出/models/abc.pkl -d“测试” --tag“数据” =“测试” --model-framework ScikitLearn -t元数据/model.json

以上命令总是给我:- {'Azure-cli-ml版本':'1.12.0','错误':ModelPathNotFoundException: 消息:无法找到提供的model_path输出/models/abc.pkl

## local_run是automl的另一个运行ID,而run.getContext()是当前的运行ID。

automl_config = AutoMLConfig(task = 'classification',primary_metric = 'accuracy',X = X_train,y = y_train,n_cross_validations = 2,**automl_settings)

local_run = exp.submit(automl_config,show_output = True)

local_run = list(exp.get_runs())[0]

children = list(local_run.get_children())
metricslist = {}
for run in children:
    properties = run.get_properties()
    metrics = {k: v for k,v in run.get_metrics().items() if isinstance(v,float)}
    metricslist[int(properties['iteration'])] = metrics

rundata = pd.DataFrame(metricslist).sort_index(1)

best_run,fitted_model = local_run.get_output()
model_path = os.path.join(outputs_folder,model_filename)
#dump(fitted_model,model_path)

# upload the model file explicitly into artifacts

print("Uploading the model into run artifacts   RUN ***** ...")
run.upload_file(name="./outputs/models/" +`enter code here` model_filename,path_or_stream=model_path1)
run.upload_file("outputs/models/abc.pkl",path_or_stream=model_path1)
print("Uploaded the model {} to experiment {}".format(model_filename,run.experiment.name))
dirpath = os.getcwd()
print(dirpath)
print("Following files are uploaded ")
print(run.get_file_names())


print("Uploading the model into run artifacts  NEW **** ...")
local_run.upload_file(name="./outputs/models/" + model_filename,path_or_stream=model_path1)
local_run.upload_file("outputs/models/abc.pkl",local_run.experiment.name))
dirpath = os.getcwd()
print(dirpath)
print("Following files are uploaded ")
print(local_run.get_file_names())

run.complete()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...