Skip to content
Advertisement

How can I remove the wrapper around the input when using Inference Schema

When using Inference Schema to autogenerate the swagger doc for my AzureML endpoint (as detailed here and here), I see that it creates a wrapper around my input_sample. Is there a way to not wrap the input inside this “data” wrapper?

Here is what my score.py looks like:

input_sample = {
                "id": 123,
                "language": "en"
                "items": [{
                    "item": 1,
                    "desc": "desc"
                }]
            }
output_sample = [{'prediction': 'true', 'predictionConfidence': 0.8279970776764844}]

@input_schema('data', StandardPythonParameterType(input_sample))
@output_schema(StandardPythonParameterType(output_sample))
def run(data):
"""
    {
        data: { --> DON'T WANT this "data" wrapper
                "id": 123,
                "language": "en"
                "items": [{
                    "item": 1,
                    "desc": "desc"
                }]
            }
    }
    """
    try:
        id = data['id']
        ...
        

Advertisement

Answer

InferenceSchema used with Azure Machine Learning deployments, then the code for this package was recently published at https://github.com/Azure/InferenceSchema under an MIT license. So you could possibly use that to create a version specific to your needs.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement