Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Commit 1a265db

Browse files
authored
Swap order of processing json_request to prevent bad jsonlines request. (#224)
* Swap order of processing json_request to prevent bad jsonlines request. * Remove extra space. * Fix dockerfiles by removing no longer needed, errant cleanup. * Remove redundant if condition.
1 parent 1bd309b commit 1a265db

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

docker/1.15/Dockerfile.gpu

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ ENV DEBIAN_FRONTEND=noninteractive
3232
# Fix cuda repo's GPG key. Nvidia is no longer updating the machine-learning repo.
3333
# Need to manually pull and install necessary debs to continue using these versions.
3434
RUN rm /etc/apt/sources.list.d/cuda.list \
35-
&& rm /etc/apt/sources.list.d/nvidia-ml.list \
3635
&& apt-key del 7fa2af80 \
3736
&& apt-get update && apt-get install -y --no-install-recommends wget \
3837
&& wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-keyring_1.0-1_all.deb \

docker/2.1/Dockerfile.gpu

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ ENV DEBIAN_FRONTEND=noninteractive
3030
# Fix cuda repo's GPG key. Nvidia is no longer updating the machine-learning repo.
3131
# Need to manually pull and install necessary debs to continue using these versions.
3232
RUN rm /etc/apt/sources.list.d/cuda.list \
33-
&& rm /etc/apt/sources.list.d/nvidia-ml.list \
3433
&& apt-key del 7fa2af80 \
3534
&& apt-get update && apt-get install -y --no-install-recommends wget \
3635
&& wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-keyring_1.0-1_all.deb \

docker/build_artifacts/sagemaker/tensorflowServing.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ function parse_custom_attributes(r) {
140140
function json_request(r) {
141141
var data = r.requestBody
142142

143-
if (is_json_lines(data)) {
144-
json_lines_request(r, data)
145-
} else if (is_tfs_json(data)) {
143+
if (is_tfs_json(data)) {
146144
tfs_json_request(r, data)
145+
} else if (is_json_lines(data)) {
146+
json_lines_request(r, data)
147147
} else {
148148
generic_json_request(r, data)
149149
}

test/integration/local/test_container.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,21 @@ def test_predict_two_instances():
127127
assert y == {"predictions": [[3.5, 4.0, 5.5], [3.5, 4.0, 5.5]]}
128128

129129

130+
def test_predict_instance_jsonlines_input_error():
131+
"""
132+
Test with input that previously triggered jsonlines code in tensorflowServing.js
133+
Will still produce error - but error should be 'Type: String is not of expected type: float'
134+
"""
135+
x = {"instances": ["]["]}
136+
y = make_request(json.dumps(x))
137+
assert (
138+
"error" in y
139+
and y["error"]
140+
== "Failed to process element: 0 of 'instances' list. Error: Invalid argument:"
141+
+ ' JSON Value: "][" Type: String is not of expected type: float'
142+
)
143+
144+
130145
def test_predict_jsons_json_content_type():
131146
x = "[1.0, 2.0, 5.0]\n[1.0, 2.0, 5.0]"
132147
y = make_request(x)

0 commit comments

Comments
 (0)