MLServer icon indicating copy to clipboard operation
MLServer copied to clipboard

Schema validation for custom runtimes

Open michaeltinsley opened this issue 1 year ago • 0 comments

There is currently no inbuilt way to validate an input against its defined schema.

For example, this schema defines an input array named array with shape [-1, 1, 28, 28], however it will accept anything even an empty payload.

{
  "name": "mnist-classification",
  "implementation": "runtime.MNISTRuntime",
  "parameters": {
    "uri": "../data/model_weights/mnist_model.ckpt"
  },
  "inputs": [
    {
      "name": "array",
      "datatype": "FP32",
      "shape": [
        -1,
        1,
        28,
        28
      ],
      "parameters": {
        "content_type": "np"
      }
    }
  ],
  "outputs": [
    {
      "name": "output",
      "datatype": "INT32",
      "shape": [
        -1,
        1
      ],
      "parameters": {
        "content_type": "np"
      }
    }
  ]
}

The user can manually validate, but this adds a lot of boilerplate code and seems like it'd be defining the schema twice - once in the model-setting.json and once in the code.

I may have missed something - still getting my head around the codecs etc.

michaeltinsley avatar Mar 22 '23 16:03 michaeltinsley