Created
November 24, 2020 15:28
-
-
Save sophwats/4e30b065cc39aa6555a88599274664c2 to your computer and use it in GitHub Desktop.
interact with model service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEFAULT_BASE_URL = "http://seldon-deployment-example-sklearn-iris-predictor-ml-mon.apps.cluster-d038.d038.example.opentlc.com%s" | |
import requests | |
from urllib.parse import urlencode | |
import json | |
def score_text(text, url = None): | |
url = (url or (DEFAULT_BASE_URL % "/api/v1.0/predictions")) | |
print(url) | |
payload = '{"data": {"ndarray":[[5.964,4.006,2.081,1.031]]}}' | |
print(payload) | |
headers = {'content-type': 'application/json'} | |
response = requests.request("POST", url, data=payload, headers=headers) | |
print(payload) | |
print(response) | |
return json.loads(response.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment