Skip to content

Commit

Permalink
added docs to functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lkuma37 committed Aug 3, 2019
1 parent c2d7b72 commit 5f53e8a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ public ResponseEntity<String> predictions_multiform(MultipartHttpServletRequest

}

/**
* It calls the prediction service for the input json.
* It is the base function for all forms of request Content-type
* @param json - Input JSON to predict REST api
* @return The response for prediction service
*/
private ResponseEntity<String> _predictions(String json)
{
SeldonMessage request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"image": "sklearn-iris-multipart-formdata:0.1",
"imagePullPolicy": "IfNotPresent",
"name": "sklearn-iris-classifier",
"command": ["/bin/sh", "-c", "cd /microservice; seldon-core-microservice IrisClassifier REST --service-type MODEL --persistence 0"],
"resources": {
"requests": {
"memory": "1Mi"
Expand Down
12 changes: 12 additions & 0 deletions python/seldon_core/flask_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
import base64

def get_multi_form_data_request() -> Dict:
"""
Parses a request submitted with Content-type:multipart/form-data
all the keys under SeldonMessage are accepted as form input
binData can only be passed as file input
strData can be passed as file or text input
the file input is base64 encoded
Returns
-------
JSON Dict
"""
req_dict = {}
for key in request.form:
if key == 'strData':
Expand Down
12 changes: 12 additions & 0 deletions python/tests/test_model_microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@

from flask import jsonify

"""
Checksum of bytes. Used to check data integrity of binData passed in multipart/form-data request
Parameters
----------
the_bytes
Input bytes
Returns
-------
the checksum
"""
def rs232_checksum(the_bytes):
return b'%02X' % (sum(the_bytes) & 0xFF)

Expand Down

0 comments on commit 5f53e8a

Please sign in to comment.