UnseekableStreamError: Need to rewind the stream bytearray Error when calling sagemaker endpoint


#1

Anyone seen this error before? I deployed a similar endpoint yesterday and it worked find. I get the error when passing a .jpg to a SageMaker endpoint API.

Blockquote


AttributeError Traceback (most recent call last)
~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/botocore/awsrequest.py in reset_stream(self)
425 logger.debug(“Rewinding stream: %s”, self.body)
–> 426 self.body.seek(0)
427 except Exception as e:

AttributeError: ‘bytearray’ object has no attribute ‘seek’

During handling of the above exception, another exception occurred:

UnseekableStreamError Traceback (most recent call last)
in ()
8 response = runtime.invoke_endpoint(EndpointName=endpoint_name,
9 ContentType=‘application/x-image’,
—> 10 Body=payload)
11 result = response[‘Body’].read()
12 # result will be in json format and convert it to ndarray

~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/botocore/client.py in _api_call(self, *args, **kwargs)
312 “%s() only accepts keyword arguments.” % py_operation_name)
313 # The “self” in this scope is referring to the BaseClient.
–> 314 return self._make_api_call(operation_name, kwargs)
315
316 _api_call.name = str(py_operation_name)

~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params)
597 else:
598 http, parsed_response = self._endpoint.make_request(
–> 599 operation_model, request_dict)
600
601 self.meta.events.emit(

~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/botocore/endpoint.py in make_request(self, operation_model, request_dict)
146 logger.debug(“Making request for %s (verify_ssl=%s) with params: %s”,
147 operation_model, self.verify, request_dict)
–> 148 return self._send_request(request_dict, operation_model)
149
150 def create_request(self, params, operation_model=None):

~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/botocore/endpoint.py in _send_request(self, request_dict, operation_model)
181 # This will ensure that we resend the entire contents of the
182 # body.
–> 183 request.reset_stream()
184 # Create a new request when retried (including a new signature).
185 request = self.create_request(

~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/botocore/awsrequest.py in reset_stream(self)
427 except Exception as e:
428 logger.debug(“Unable to rewind stream: %s”, e)
–> 429 raise UnseekableStreamError(stream_object=self.body)
430
431 def prepare_body(self, data, files, json=None):

UnseekableStreamError: Need to rewind the stream bytearray

Blockquote