Skip to content

Conversation

algattik
Copy link
Contributor

Implemented best practice recommended in https://docs.microsoft.com/en-us/azure/machine-learning/how-to-deploy-and-where

  • Discover model rather than hard-coding the name in score.py
  • Add OpenAPI (Swagger) endpoint to scoring container

This contribution was developed into a fork by @Anaig .

curl -s http://***.westeurope.azurecontainer.io/swagger.json | jq .
{
  "swagger": "2.0",
  "info": {
    "title": "diabetes-aci",
    "description": "API specification for the Azure Machine Learning service diabetes-aci",
    "version": "1.0"
  },
  "schemes": [
    "https"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "securityDefinitions": {
    "Bearer": {
      "type": "apiKey",
      "name": "Authorization",
      "in": "header",
      "description": "For example: Bearer abc123"
    }
  },
  "paths": {
    "/": {
      "get": {
        "operationId": "ServiceHealthCheck",
        "description": "Simple health check endpoint to ensure the service is up at any given point.",
        "responses": {
          "200": {
            "description": "If service is up and running, this response will be returned with the content 'Healthy'",
            "schema": {
              "type": "string"
            },
            "examples": {
              "application/json": "Healthy"
            }
          },
          "default": {
            "description": "The service failed to execute due to an error.",
            "schema": {
              "$ref": "#/definitions/ErrorResponse"
            }
          }
        }
      }
    },
    "/score": {
      "post": {
        "operationId": "RunMLService",
        "description": "Run web service's model and get the prediction output",
        "security": [
          {
            "Bearer": []
          }
        ],
        "parameters": [
          {
            "name": "serviceInputPayload",
            "in": "body",
            "description": "The input payload for executing the real-time machine learning service.",
            "schema": {
              "$ref": "#/definitions/ServiceInput"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The service processed the input correctly and provided a result prediction, if applicable.",
            "schema": {
              "$ref": "#/definitions/ServiceOutput"
            }
          },
          "default": {
            "description": "The service failed to execute due to an error.",
            "schema": {
              "$ref": "#/definitions/ErrorResponse"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "ServiceInput": {
      "type": "object",
      "properties": {
        "data": {
          "type": "array",
          "items": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64"
            }
          }
        },
        "request_headers": {}
      },
      "example": {
        "data": [
          [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10
          ],
          [
            10,
            9,
            8,
            7,
            6,
            5,
            4,
            3,
            2,
            1
          ]
        ],
        "request_headers": ""
      }
    },
    "ServiceOutput": {
      "type": "array",
      "items": {
        "type": "integer",
        "format": "int64"
      },
      "example": [
        10,
        20
      ]
    },
    "ErrorResponse": {
      "type": "object",
      "properties": {
        "status_code": {
          "type": "integer",
          "format": "int32"
        },
        "message": {
          "type": "string"
        }
      }
    }
  }
}
```

@eedorenko eedorenko self-assigned this Jan 27, 2020
@eedorenko eedorenko merged commit 45afe29 into microsoft:master Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants