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

Do not touch botocore unless it is installed #803

Merged
merged 3 commits into from
Feb 26, 2024

Conversation

ddelange
Copy link
Contributor

Title

Raise a proper S3 import exception (leftover from #785).

Motivation

Leftover from #785, not raising the proper Exception anymore:

  File "/usr/share/python3/app/lib/python3.11/site-packages/smart_open/s3.py", line 121, in <module>
    RETRY = Retry()
            ^^^^^^^
  File "/usr/share/python3/app/lib/python3.11/site-packages/smart_open/s3.py", line 86, in __init__
    self.exceptions: List[Exception] = [botocore.exceptions.EndpointConnectionError]
                                        ^^^^^^^^
NameError: name 'botocore' is not defined

Tests

Work in progress

Checklist

Before you create the PR, please make sure you have:

  • Picked a concise, informative and complete title
  • Clearly explained the motivation behind the PR
  • Linked to any existing issues that your PR will be solving
  • Included tests for any new functionality
  • Checked that all unit tests pass

Workflow

@ddelange
Copy link
Contributor Author

ddelange commented Feb 26, 2024

cc @mpenkov this error was raised when importing smart_open on a smart_open[azure] container.

@ddelange
Copy link
Contributor Author

ddelange commented Feb 26, 2024

hmm, now we're getting

smart_open/transport.py:22: in <module>
    _REGISTRY = {NO_SCHEME: smart_open.local_file}
E   AttributeError: partially initialized module 'smart_open' has no attribute 'local_file' (most likely due to a circular import)

What would be the proper fix?

edit: 252430c

@ddelange
Copy link
Contributor Author

ddelange commented Feb 26, 2024

is there a point in time where we can test import smart_open before any optional deps are installed? to catch this case?

edit: 947bbe0

@mpenkov mpenkov changed the title Raise proper S3 exception on MISSING_DEPS Do not touch botocore unless it is installed Feb 26, 2024
@mpenkov
Copy link
Collaborator

mpenkov commented Feb 26, 2024

Fixes #804

@mpenkov
Copy link
Collaborator

mpenkov commented Feb 26, 2024

Thank you @ddelange !

@mpenkov mpenkov merged commit d23ec41 into piskvorky:develop Feb 26, 2024
21 checks passed
@ddelange
Copy link
Contributor Author

thanks too for the quick action!
https://http.cat/202

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants