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

Fixing Alibi Detect Server response cloud event data is json marshalled string #3907

Merged
merged 5 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions components/alibi-detect-server/adserver/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ def post(self):
logging.error("Metrics returned are invalid: " + str(runtime_metrics))

if response.data is not None:
responseStr = json.dumps(response.data)

# Create event from response if reply_url is active
if not self.reply_url == "":
Expand All @@ -264,7 +263,7 @@ def post(self):
revent = (
v1.Event()
.SetContentType("application/json")
.SetData(responseStr)
.SetData(response.data)
.SetEventID(resp_event_id)
.SetSource(self.event_source)
.SetEventType(self.event_type)
Expand Down
16 changes: 6 additions & 10 deletions components/alibi-detect-server/adserver/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,9 @@ def test_basic(self):
},
)
self.assertEqual(response.code, 200)
expectedResponse = json.dumps(DummyModel.getResponse().data)
self.assertEqual(response.body.decode("utf-8"), expectedResponse)
self.assertEqual(
m.request_history[0].json(), json.dumps(DummyModel.getResponse().data)
)
expectedResponse = DummyModel.getResponse().data
self.assertEqual(response.body.decode("utf-8"), json.dumps(expectedResponse))
self.assertEqual(m.request_history[0].json(), expectedResponse)
headers: Dict = m.request_history[0]._request.headers
self.assertEqual(headers["ce-source"], self.eventSource)
self.assertEqual(headers["ce-type"], self.eventType)
Expand Down Expand Up @@ -130,11 +128,9 @@ def test_basic(self):
},
)
self.assertEqual(response.code, 200)
expectedResponse = json.dumps(DummyModel.getResponse().data)
self.assertEqual(response.body.decode("utf-8"), expectedResponse)
self.assertEqual(
m.request_history[0].json(), json.dumps(DummyModel.getResponse().data)
)
expectedResponse = DummyModel.getResponse().data
self.assertEqual(response.body.decode("utf-8"), json.dumps(expectedResponse))
self.assertEqual(m.request_history[0].json(), expectedResponse)
headers: Dict = m.request_history[0]._request.headers
self.assertEqual(headers["ce-source"], self.eventSource)
self.assertEqual(headers["ce-type"], self.eventType)
Expand Down
16 changes: 2 additions & 14 deletions components/drift-detection/cifar10/cifar10_drift.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -519,13 +519,7 @@
"metadata": {},
"outputs": [],
"source": [
"res = !kubectl logs -n cifar10drift $(kubectl get pod -n cifar10drift -l app=hello-display -o jsonpath='{.items[0].metadata.name}')\n",
"data = []\n",
"for i in range(0, len(res)):\n",
" if res[i] == \"Data,\":\n",
" data.append(res[i + 1])\n",
"j = json.loads(json.loads(data[0]))\n",
"print(\"Drift\", j[\"data\"][\"is_drift\"] == 1)"
"!kubectl logs -n cifar10drift $(kubectl get pod -n cifar10drift -l app=hello-display -o jsonpath='{.items[0].metadata.name}')"
]
},
{
Expand Down Expand Up @@ -590,13 +584,7 @@
"metadata": {},
"outputs": [],
"source": [
"res = !kubectl logs -n cifar10drift $(kubectl get pod -n cifar10drift -l app=hello-display -o jsonpath='{.items[0].metadata.name}')\n",
"data = []\n",
"for i in range(0, len(res)):\n",
" if res[i] == \"Data,\":\n",
" data.append(res[i + 1])\n",
"j = json.loads(json.loads(data[-1]))\n",
"print(\"Drift\", j[\"data\"][\"is_drift\"] == 1)"
"!kubectl logs -n cifar10drift $(kubectl get pod -n cifar10drift -l app=hello-display -o jsonpath='{.items[0].metadata.name}')"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,13 +696,7 @@
}
],
"source": [
"res = !kubectl logs -n cifar10drift $(kubectl get pod -n cifar10drift -l app=hello-display -o jsonpath='{.items[0].metadata.name}')\n",
"data = []\n",
"for i in range(0, len(res)):\n",
" if res[i] == \"Data,\":\n",
" data.append(res[i + 1])\n",
"j = json.loads(json.loads(data[0]))\n",
"print(\"Drift\", j[\"data\"][\"is_drift\"] == 1)"
"!kubectl logs -n cifar10drift $(kubectl get pod -n cifar10drift -l app=hello-display -o jsonpath='{.items[0].metadata.name}')"
]
},
{
Expand Down Expand Up @@ -829,13 +823,7 @@
}
],
"source": [
"res = !kubectl logs -n cifar10drift $(kubectl get pod -n cifar10drift -l app=hello-display -o jsonpath='{.items[0].metadata.name}')\n",
"data = []\n",
"for i in range(0, len(res)):\n",
" if res[i] == \"Data,\":\n",
" data.append(res[i + 1])\n",
"j = json.loads(json.loads(data[-1]))\n",
"print(\"Drift\", j[\"data\"][\"is_drift\"] == 1)"
"!kubectl logs -n cifar10drift $(kubectl get pod -n cifar10drift -l app=hello-display -o jsonpath='{.items[0].metadata.name}')"
]
},
{
Expand Down
16 changes: 2 additions & 14 deletions components/outlier-detection/cifar10/cifar10_outlier.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -507,13 +507,7 @@
"metadata": {},
"outputs": [],
"source": [
"res = !kubectl logs -n cifar10 $(kubectl get pod -n cifar10 -l app=hello-display -o jsonpath='{.items[0].metadata.name}')\n",
"data = []\n",
"for i in range(0, len(res)):\n",
" if res[i] == \"Data,\":\n",
" data.append(res[i + 1])\n",
"j = json.loads(json.loads(data[0]))\n",
"print(\"Outlier\", j[\"data\"][\"is_outlier\"] == [1])"
"!kubectl logs -n cifar10 $(kubectl get pod -n cifar10 -l app=hello-display -o jsonpath='{.items[0].metadata.name}')"
]
},
{
Expand Down Expand Up @@ -564,13 +558,7 @@
"metadata": {},
"outputs": [],
"source": [
"res = !kubectl logs -n cifar10 $(kubectl get pod -n cifar10 -l app=hello-display -o jsonpath='{.items[0].metadata.name}')\n",
"data = []\n",
"for i in range(0, len(res)):\n",
" if res[i] == \"Data,\":\n",
" data.append(res[i + 1])\n",
"j = json.loads(json.loads(data[-1]))\n",
"print(\"Outlier\", j[\"data\"][\"is_outlier\"] == [1])"
"!kubectl logs -n cifar10 $(kubectl get pod -n cifar10 -l app=hello-display -o jsonpath='{.items[0].metadata.name}')"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,13 +644,7 @@
}
],
"source": [
"res = !kubectl logs -n cifar10 $(kubectl get pod -n cifar10 -l app=hello-display -o jsonpath='{.items[0].metadata.name}')\n",
"data = []\n",
"for i in range(0, len(res)):\n",
" if res[i] == \"Data,\":\n",
" data.append(res[i + 1])\n",
"j = json.loads(json.loads(data[0]))\n",
"print(\"Outlier\", j[\"data\"][\"is_outlier\"] == [1])"
"!kubectl logs -n cifar10 $(kubectl get pod -n cifar10 -l app=hello-display -o jsonpath='{.items[0].metadata.name}')"
]
},
{
Expand Down Expand Up @@ -732,13 +726,7 @@
}
],
"source": [
"res = !kubectl logs -n cifar10 $(kubectl get pod -n cifar10 -l app=hello-display -o jsonpath='{.items[0].metadata.name}')\n",
"data = []\n",
"for i in range(0, len(res)):\n",
" if res[i] == \"Data,\":\n",
" data.append(res[i + 1])\n",
"j = json.loads(json.loads(data[-1]))\n",
"print(\"Outlier\", j[\"data\"][\"is_outlier\"] == [1])"
"!kubectl logs -n cifar10 $(kubectl get pod -n cifar10 -l app=hello-display -o jsonpath='{.items[0].metadata.name}')"
]
},
{
Expand Down
11 changes: 11 additions & 0 deletions doc/source/reference/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ This page provides with instructions on how to upgrade from previous versions. E
If you were running our Openshift 0.4.2 certified operator and are looking to upgrade to our 1.1 certified operator, you will also need to follow the "upgrading process" steps in the "Upgrading to 0.5.2 from previous versions" section.

Make sure you also [read the CHANGELOG](./changelog.html) to see the detailed features and bug-fixes in each version.

## Upgrading to 1.13

### Seldon Inference Payload Logging Changes

The seldon executor logs the prediction request and respose payload to a configured URL post during the inference at each stage of a inference graph. These request/response pairs are now matched correctly to reflect the component's input/output at each node level as compared to pairing based on the tree structure of the inference graph previously. See [relevant issue](https://github.com/SeldonIO/seldon-core/issues/3873) for more details.

### Alibi Detect Server Event Update

The cloud event data that the alibi detect server sends to a configured replyURL post the outlier/drift detection was a JSON string. This is now updated to reflect the content type as JSON correctly.

## Upgrading to 1.12

### Support for Kubernetes 1.22
Expand Down