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

add warning for recently deprecated s3 parameters #618

Merged
merged 2 commits into from
May 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Unreleased

- Add warning for recently deprecated s3 parameters (PR [#618](https://github.com/RaRe-Technologies/smart_open/pull/618), [@mpenkov](https://github.com/mpenkov))
- Add new top-level compression parameter (PR [#609](https://github.com/RaRe-Technologies/smart_open/pull/609), [@dmcguire81](https://github.com/dmcguire81))

# 5.0.0, 30 Mar 2021

This release modifies the handling of transport parameters for the S3 back-end in a backwards-incompatible way.
Expand All @@ -9,7 +12,6 @@ See [the migration docs](MIGRATING_FROM_OLDER_VERSIONS.rst) for details.
- Fix potential infinite loop when reading from webhdfs (PR [#597](https://github.com/RaRe-Technologies/smart_open/pull/597), [@traboukos](https://github.com/traboukos))
- Add timeout parameter for http/https (PR [#594](https://github.com/RaRe-Technologies/smart_open/pull/594), [@dustymugs](https://github.com/dustymugs))
- Remove `tests` directory from package (PR [#589](https://github.com/RaRe-Technologies/smart_open/pull/589), [@e-nalepa](https://github.com/e-nalepa))
- Add new top-level compression parameter (PR [#609](https://github.com/RaRe-Technologies/smart_open/pull/609), [@dmcguire81](https://github.com/dmcguire81))

# 4.2.0, 15 Feb 2021

Expand Down
28 changes: 28 additions & 0 deletions smart_open/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import functools
import logging
import time
import warnings

try:
import boto3
Expand Down Expand Up @@ -190,6 +191,33 @@ def inject(**kwargs):


def open_uri(uri, mode, transport_params):
deprecated = (
'multipart_upload_kwargs',
'object_kwargs',
'resource',
'resource_kwargs',
'session',
'singlepart_upload_kwargs',
)
detected = [k for k in deprecated if k in transport_params]
if detected:
doc_url = (
'https://github.com/RaRe-Technologies/smart_open/blob/develop/'
'MIGRATING_FROM_OLDER_VERSIONS.rst'
)
#
# We use warnings.warn /w UserWarning instead of logger.warn here because
#
# 1) Not everyone has logging enabled; and
# 2) check_kwargs (below) already uses logger.warn with a similar message
#
# https://github.com/RaRe-Technologies/smart_open/issues/614
#
message = (
'ignoring the following deprecated transport parameters: %r. '
'See <%s> for details' % (detected, doc_url)
)
warnings.warn(message, UserWarning)
parsed_uri = parse_uri(uri)
parsed_uri, transport_params = _consolidate_params(parsed_uri, transport_params)
kwargs = smart_open.utils.check_kwargs(open, transport_params)
Expand Down