-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rhoai-4386 model serving and ui updates for 2.8 (#25)
* rhoai-4386 model serving and ui updates for 2.8 * rhoai-4386 more updates based on downstream testing * rhoai-4386 addressed review comments * peer review comments incorporated * 4386 update pipeline screen captures * 4386 add note about Elyra * rhoai-4386 sme review updates * updates to include multi-model notebooks and update screen captures * fix typo and upload pipeline file
- Loading branch information
1 parent
1c261be
commit b9b5daf
Showing
58 changed files
with
347 additions
and
250 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "55c8afde-9b18-4b6a-9ee5-33924bdb4f16", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# REST Inference" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "2c004acc-13cd-4917-8480-592c7c2d623b", | ||
"metadata": {}, | ||
"source": [ | ||
"## Setup\n", | ||
"\n", | ||
"Change that following variable settings match your deployed model's *Inference endpoint*. for example: \n", | ||
"\n", | ||
"```\n", | ||
"deployed_model_name = \"fraud\"\n", | ||
"infer_endpoint = \"https://fraud-predictor-userx-workshop.apps.clusterx.sandboxx.opentlc.com\"\n", | ||
"```" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "0de65d02-84a6-4cff-882e-551cdd42b486", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"deployed_model_name = \"fraud\"\n", | ||
"infer_endpoint = \"https://fraud-predictor-<project-name>.<cluster>.com\"\n", | ||
"infer_url = f\"{infer_endpoint}/v2/models/{deployed_model_name}/infer\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "d94f9ece-e9cf-44e2-a8a2-73160186aee8", | ||
"metadata": {}, | ||
"source": [ | ||
"## Request Function\n", | ||
"\n", | ||
"Build and submit the REST request. \n", | ||
"\n", | ||
"Note: You submit the data in the same format that you used for an ONNX inference." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "54b9386f-683a-4880-b780-c40bec3ab9f8", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import requests\n", | ||
"\n", | ||
"\n", | ||
"def rest_request(data):\n", | ||
" json_data = {\n", | ||
" \"inputs\": [\n", | ||
" {\n", | ||
" \"name\": \"dense_input\",\n", | ||
" \"shape\": [1, 5],\n", | ||
" \"datatype\": \"FP32\",\n", | ||
" \"data\": data\n", | ||
" }\n", | ||
" ]\n", | ||
" }\n", | ||
"\n", | ||
" response = requests.post(infer_url, json=json_data, verify=False)\n", | ||
" response_dict = response.json()\n", | ||
" return response_dict['outputs'][0]['data']" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "45ad16ac-23da-48bd-9796-f8e4cacae981", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data = [0.3111400080477545, 1.9459399775518593, 1.0, 0.0, 0.0]\n", | ||
"prediction = rest_request(data)\n", | ||
"prediction" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "1d66e0f7-4d4e-4879-bdf1-36b712432fd9", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"threshhold = 0.995\n", | ||
"\n", | ||
"if (prediction[0] > threshhold):\n", | ||
" print('fraud')\n", | ||
"else:\n", | ||
" print('not fraud')" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3.9", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.18" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.