-
Notifications
You must be signed in to change notification settings - Fork 1.2k
change: add csv deserializer #737
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
Conversation
src/sagemaker/predictor.py
Outdated
|
||
def __call__(self, stream, content_type): | ||
try: | ||
return list(csv.reader(stream.read().decode('utf-8').splitlines())) |
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.
should we make encoding configurable as well here?
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.
good point
result = csv_deserializer(io.BytesIO(b'1,2,3\n3,4,5'), 'text/csv') | ||
assert result == [['1', '2', '3'], ['3', '4', '5']] | ||
|
||
|
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.
I would add a test with just one line and one value. YMMV
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.
done
@@ -230,12 +230,13 @@ def _row_to_csv(obj): | |||
|
|||
|
|||
class _CsvDeserializer(object): | |||
def __init__(self): | |||
self.content_type = CONTENT_TYPE_CSV | |||
def __init__(self, encoding='utf-8'): |
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.
do you need to pass the accept in as well?
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.
I was staying consistent with:
class _CsvSerializer(object):
def __init__(self):
self.content_type = CONTENT_TYPE_CSV
open to changing it though if there's a compelling use case
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Description of changes:
a counterpart to our CSV serializer
Merge Checklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.