微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决带有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 举报,一经查实,本站将立刻删除。