-
Notifications
You must be signed in to change notification settings - Fork 5
feat(RND-13624): Migrate WithS3File to AWS Data Wrangler
#88
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
base: master
Are you sure you want to change the base?
Conversation
WithS3File to AWS Data Wrangler
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #88 +/- ##
==========================================
+ Coverage 88.21% 89.40% +1.18%
==========================================
Files 16 16
Lines 1256 1321 +65
Branches 142 153 +11
==========================================
+ Hits 1108 1181 +73
+ Misses 110 98 -12
- Partials 38 42 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| @@ -1,4 +1,6 @@ | |||
| """Invokes dynamicio cli.""" | |||
|
|
|||
| # Application Imports | |||
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.
Black does this now...
| """Handles I/O operations for AWS Athena. | ||
| Note: | ||
| The `__abstractmethods__ = frozenset()` is used to silence false positives from pylint, | ||
| which might wrongly assume this class has abstract methods due to NotImplementedError. | ||
| This class is *not* an abstract base class and does not use `abc.ABC`. | ||
| """ | ||
|
|
||
| __abstractmethods__ = frozenset() |
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.
Fixes a pylint false positive on abstract methods not implemented...
| # 🧼 Check if this is a single-record json file | ||
| if is_single_record: | ||
| # Re-wrap as single dict row — i.e., rehydrate the record | ||
| df = pd.DataFrame([{df.columns[0]: dict(zip(df.index, df.iloc[:, 0]))}]) | ||
| elif ( | ||
| df.shape[1] == 1 | ||
| and df.columns.dtype == "object" | ||
| and df.index.dtype == "object" | ||
| and all(isinstance(i, str) for i in df.index) | ||
| and all(isinstance(v, (str, int, float, bool, type(None))) for v in df.iloc[:, 0]) | ||
| ): | ||
| logger.warning("[local-json-read] File appears to be a single-record JSON object. Pass 'single_record=True' in options to handle this case.") |
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.
Necessary for alignment with wrangler.read_json() behaviour.
|
yuan-vortexa
left a comment
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.
lgtm



🚀 Migrate
WithS3Fileto AWS Data WranglerLinks
RND-13624
Summary
This PR refactors the
WithS3Filemixin to use[awswrangler](https://github.com/aws/aws-sdk-pandas)for all S3 I/O operations (CSV, JSON, Parquet, and HDF), removing reliance on local temp files,boto3, and the AWS CLI. HDF files are now streamed in-memory usingboto3.client().download_fileobjand PyTables.Key Changes
awswrangler:wr.s3.read_*/to_*calls.BytesIO._read_s3_{type}_file/_write_s3_{type}_filemethods.allow_optionsdecorator to:pandas,pyarrow,wrangler, etc).pandas_kwargs,pyarrow_additional_kwargs,s3_additional_kwargs.convert_dates=Trueis ignored to ensure consistency.single_record=Trueoption to force wrapping a single JSON object into a tabular DataFrame.pandas.read_jsonandawswrangler.read_jsonfororient="records"andlines=Trueusage.Benefits
awswrangler.Notes
_s3_reader,_s3_writer,_s3_named_file_reader) has been fully removed.awswrangleris now a required dependency.single_record=True.