amazon-sagemaker-examples icon indicating copy to clipboard operation
amazon-sagemaker-examples copied to clipboard

[Bug Report] output_fn expects incorrect content type

Open jbarz1 opened this issue 3 years ago • 0 comments

Link to the notebook

https://github.com/aws/amazon-sagemaker-examples/blob/main/introduction_to_amazon_algorithms/xgboost_abalone/xgboost_inferenece_script_mode.ipynb

Describe the bug output_fn function fails

Traceback (most recent call last):
  File "/miniconda3/lib/python3.8/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/miniconda3/lib/python3.8/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/miniconda3/lib/python3.8/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/miniconda3/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/miniconda3/lib/python3.8/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/miniconda3/lib/python3.8/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/miniconda3/lib/python3.8/site-packages/sagemaker_containers/_transformer.py", line 199, in transform
    result = self._transform_fn(
  File "/miniconda3/lib/python3.8/site-packages/sagemaker_containers/_transformer.py", line 234, in _default_transform_fn
    result = self._output_fn(prediction, accept)
  File "/miniconda3/lib/python3.8/site-packages/sagemaker_containers/_functions.py", line 95, in wrapper
    six.reraise(error_class, error_class(e), sys.exc_info()[2])
  File "/miniconda3/lib/python3.8/site-packages/six.py", line 718, in reraise
    raise value.with_traceback(tb)
  File "/miniconda3/lib/python3.8/site-packages/sagemaker_containers/_functions.py", line 93, in wrapper
    return fn(*args, **kwargs)
  File "/opt/ml/code/inference.py", line 54, in output_fn
    raise ValueError("Content type {} is not supported.".format(content_type))

reason is this line

https://github.com/aws/amazon-sagemaker-examples/blob/main/introduction_to_amazon_algorithms/xgboost_abalone/inference.py#L60

Even the transform function alternative in the notebook doesn't do this check

https://github.com/aws/amazon-sagemaker-examples/blob/main/introduction_to_amazon_algorithms/xgboost_abalone/xgboost_inferenece_script_mode.ipynb?short_path=b1cf1d9#L267

So I think this csv check should be removed from output_fn

To reproduce Just run the notebook

Logs If applicable, add logs to help explain your problem. You may also attach an .ipynb file to this issue if it includes relevant logs or output.

jbarz1 avatar Jun 16 '22 17:06 jbarz1