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

Remove additional parameters from content_type #51

Merged
merged 2 commits into from
Nov 15, 2019

Conversation

iyerr3
Copy link
Contributor

@iyerr3 iyerr3 commented Nov 14, 2019

Description of changes:

This commit includes following changes:

  1. get_content_type parsed the MIME type to remove optional parameters
    from the CSV type. We apply that parsing rule for all content types
    allowing optional key-value parameters after the primary type string.
  2. Inference handler has been updated to perform case-insensitive
    comparison and allow optional parameters.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

This commit includes following changes:

1. get_content_type parsed the MIME type to remove optional parameters
from the CSV type. We apply that parsing rule for all content types
allowing optional key-value parameters after the primary type string.
2. Inference handler has been updated to perform case-insensitive
comparison and allow optional parameters.
@@ -24,6 +24,8 @@
from sagemaker_xgboost_container import encoder as xgb_encoder
from sagemaker_xgboost_container.algorithm_mode.inference_errors import NoContentInferenceError, \
UnsupportedMediaTypeInferenceError, ModelLoadInferenceError, BadRequestInferenceError
from sagemaker_xgboost_container.data_utils import get_content_type
from sagemaker_xgboost_container.data_utils import CSV, LIBSVM, PARQUET, RECORDIO_PROTOBUF
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use PARQUET during inference, and flake8 complains about this.

@aws-patlin
Copy link
Contributor

Unit tests added, tested with tox and passing.

Copy link
Contributor

@ericangelokim ericangelokim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look ok. Only argument I would make for making the changes is that this should probably belong in a shared library (sagemaker-containers) so that all frameworks can use.

try:
if accept == content_types.CSV or accept == 'csv':
if accept_type == content_types.CSV or accept_type == 'csv':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we parse accept_type similar to the way content_type is now parsed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Primarily because of json not being part of our data_utils types.

@aws-patlin
Copy link
Contributor

Found a slight bug. Confirming the fix via container tests.

Added exception handling for calling get_content_type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants