-
Notifications
You must be signed in to change notification settings - Fork 69
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
Conversation
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 |
There was a problem hiding this comment.
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.
67fcb8e
to
80c2dca
Compare
Unit tests added, tested with tox and passing. |
There was a problem hiding this 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': |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Found a slight bug. Confirming the fix via container tests. |
80c2dca
to
9cd3d73
Compare
Added exception handling for calling get_content_type.
9cd3d73
to
15d6d27
Compare
Description of changes:
This commit includes following changes:
from the CSV type. We apply that parsing rule for all content types
allowing optional key-value parameters after the primary type string.
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.