Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SeldonMessage with jsonData #595

Merged
merged 4 commits into from
May 31, 2019

Conversation

gsunner
Copy link
Member

@gsunner gsunner commented May 28, 2019

fixes #434

Whats implemented

  • SeldonMessage updated to use a 'jsonData' field, similar in use to 'strData' etc..
  • Python wrapper support for 'jsonData' field
    • Predict function in model will receive data as a 'dict' when the 'jsonData' is used.
    • When returning a 'dict' from the predict call in model, the data is returned via the 'jsonData' field.

Whats not implemented

  • 'seldon_client' support in the Python wrapper
  • Support for all other language wrappers

@gsunner gsunner changed the title WIP - update SeldonMessage with jsonData Update SeldonMessage with jsonData May 28, 2019
@yu-iskw
Copy link

yu-iskw commented May 28, 2019

@gsunner Thank you for the PR. I would like to know the details about the spec.

When returning a 'dict' from the predict call in model, the data is returned via the 'jsonData' field.

Especially, if I would like to express predictions as a list of dict, what data type should predict return?

#565

## inputs
{"data": [
  {"feature1": 0.1, "feature2": 0.2},
  {"feature1": 0.3, "feature2": 0.4},
]}

## outputs
{
  "predictions": [
    {"class": 3, "probability": 0.8},
    {"class": 1, "probability": 0.95},
  ],
  "meta": {
    "tags": {
      "version": "1.0.0"
    }
  }
}

@gsunner
Copy link
Member Author

gsunner commented May 29, 2019

@yu-iskw I will try to explain how you can achieve what you need.

The input is a json object value to the "jsonData" field.
The output is a python 'dict', so put your list of predictions as a value in a dict with the key "predictions"

Here is an example how you can achieve this.

## inputs
## Predict call example input payload
{
    "jsonData": {
        "data": [
            {
                "feature1": 0.1,
                "feature2": 0.2
            },
            {
                "feature1": 0.3,
                "feature2": 0.4
            }
        ]
    }
}
## outputs
## Predict call example output
{
    "jsonData": {
        "predictions": [
            {
                "class": 3,
                "probability": 0.8
            },
            {
                "class": 1,
                "probability": 0.95
            }
        ]
    },
    "meta": {
        "metrics": [],
        "puid": "4ul51sgl3a411a0p2chr00lg5m",
        "requestPath": {
            "classifier": "gsunner/simple-model-json-value-test:v0"
        },
        "routing": {},
        "tags": {}
    }
}

Copy link
Contributor

@ukclivecox ukclivecox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing one prediction.proto to change in loadtester

git ls-tree -r master --name-only | grep prediction.proto
proto/prediction.proto
python/seldon_core/proto/prediction.proto
util/loadtester/scripts/proto/prediction.proto

@yu-iskw
Copy link

yu-iskw commented May 29, 2019

@gsunner Thank you for the example. I completely understand.

Copy link
Member

@jklaise jklaise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a test, otherwise looks good. Will need to open a separate issue to update SeldonClient once this is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alllow arbitrary JSON as a payload
5 participants