python - 错误: "Your deployment does not have an associated swagger.json" - ACI deployment on Stream Analytics Job

标签 python azure numpy azure-stream-analytics azure-container-instances

最新更新:在流分析作业的公共(public)审核链接的当前版本中,不支持 ACI 容器部署。因此,我将关闭这个问题,直至另行通知。有关更多信息,请关注下面发布的 GitHub 线程。

注意:当部署值为 ACI 容器而不是 AKS 群集时,就会出现问题。通过 Kubernetes 集群,Azure ML 服务功能已成功创建。虽然我想使用 ACI 容器而不是 AKS 集群来测试我的功能。

我正在尝试在流分析作业服务中创建 Azure ML 服务功能。为此,我在 Azure 容器实例(也称为 ACI)中使用已部署的机器学习模型。但是,我收到此错误:

enter image description here

link GitHub 上的问题和 related Microsoft document

尽管存在以下三个因素,但仍然存在此错误:

因素 1:当我使用(ACI 容器的)评分 URL 在本地(在 Jupyter Notebook 中)对某些值进行评分时,评分会成功。
因素2:我已经推断出我的score.py 文件中输入数据的模式。
因素 3:我将 infer-schema[numpy-support] 模块作为环境文件的依赖项。

我做错了什么?

ACI 容器实例使用授权(主) key 进行部署,另外我还推断了我的 Score.py 文件中输入和输出示例的架构。但是,Stream 作业无法识别 swagger 文件。由于我在 Score.py 文件上推断出模式,我 read swagger.json 文件会自动生成。

我的 Score.py 文件的示例:

import json
import numpy as np
import os
import itertools
import joblib
from sklearn.ensemble import RandomForestRegressor

from azureml.core.model import Model

from inference_schema.schema_decorators import input_schema, output_schema
from inference_schema.parameter_types.numpy_parameter_type import NumpyParameterType

def init():

    global model

    # retrieve the path to the model file using the model name
    model_path = Model.get_model_path('<model_name>')
    model = joblib.load(model_path)

input_sample = np.array([["0", 0, 0, 0, 0, 0]])
output_sample = np.array([0])

@input_schema('raw_data', NumpyParameterType(input_sample))
@output_schema(NumpyParameterType(output_sample))

def run(raw_data):
    try:

        data = np.array(raw_data)
        result=[]

        for array in data:

            prediction_result=model[array[0]].predict(array[1:].reshape(1,-1))
            result.append(prediction_result.tolist())

        result=list(itertools.chain.from_iterable(result))

        # you can return any data type as long as it is JSON-serializable
        return result

    except Exception as e:
        error = str(e)
        return error

我的 env.yml 文件示例:

name: project_environment
dependencies:
  - python=3.7.3
  - pip:
    - azureml-defaults
    - inference-schema[numpy-support]
    - joblib
    - numpy
    - scikit-learn==0.20.3

如果您对此问题提出任何评论来解决它,我将不胜感激。

主要发现:

我比较了 AKS 群集和 ACI 容器实例的 swagger.json 文件。 而这两个swagger文件的区别就在于关键的“路径”。 在 AKS 中,swagger.json 中的路径为: "paths": { "/api/v1/service/aks-service/":.... 等 在 ACI 中,swagger.json 中的路径为: "paths": { "/":....etc

AKS 集群的 Swagger.json 的一部分:

enter image description here

ACI 集群的 Swagger.json 部分:

enter image description here

我认为这可能是问题的根源。也许流分析作业功能无法识别路径“/”来自动生成 ACI 容器的函数签名。

最佳答案

我们首先从支持 AKS 开始,因为这是实时评分的推荐方法。由于此功能处于公共(public)预览阶段,我们正在最终确定 ACI 上部署的模型的一些性能基准,以便它可以可靠地用于开发/测试目的。我们应该会在接下来的几周内提供对 ACI 部署的支持。

关于python - 错误: "Your deployment does not have an associated swagger.json" - ACI deployment on Stream Analytics Job,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61158877/

相关文章:

ios - Azure 电子邮件登录注册 b2c iOS swift

python - 给定一个邻接矩阵,如何用matplotlib画图?

python - 在 python 中绘制二元 3D 矩阵

python - TensorFlow dynamic_rnn 回归量 : ValueError dimension mismatch

c# - Azure 存储表 : Is it okay to fire-and-forget async methods?

windows - 无法通过远程桌面进入 Windows Azure VM

python - 创建列的内存高效方法,该列指示来自一组列的值的唯一组合

python - 按两个重复值拆分数据框

python - 列表被覆盖?

python - 使用按钮创建新选项卡单击 Tkinter