Skip to content

Commit

Permalink
add warning for recently deprecated s3 parameters (#618)
Browse files Browse the repository at this point in the history
* add warning for recently deprecated s3 parameters

* Update CHANGELOG.md
  • Loading branch information
mpenkov authored May 7, 2021
1 parent e4c3f89 commit a9b127d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
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

0 comments on commit a9b127d

Please sign in to comment.