-
Notifications
You must be signed in to change notification settings - Fork 218
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
Log exception when FileIO import fails #1578
Conversation
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.
Thanks for the contribution!
we use the same pattern for loading custom location provider and custom catalog, do you mind also making the same changes there?
pyiceberg/io/__init__.py
Outdated
except ModuleNotFoundError: | ||
logger.warning("Could not initialize FileIO: %s", io_impl) |
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.
nit: what about something like this
iceberg-python/pyiceberg/catalog/__init__.py
Lines 287 to 288 in 1e01101
except OSError as exc: | |
logger.warning(msg=f"Failed to delete data file {path}", exc_info=exc) |
@@ -281,6 +282,11 @@ def test_import_file_io_does_not_exist() -> None: | |||
assert _import_file_io("pyiceberg.does.not.exist.FileIO", {}) is None | |||
|
|||
|
|||
def test_import_file_io_logs_exception(caplog: Any) -> None: | |||
_import_file_io("pyiceberg.does.not.exist.FileIO", {}) | |||
assert "ModuleNotFoundError: No module named 'pyiceberg.does'" in caplog.text |
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.
does the error just return pyiceberg.does
or the entire import, pyiceberg.does.not.exist.FileIO
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.
It fails here on pyiceberg.does
. I presume that's Python trying and failing to import higher-level modules first?
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.
thanks! i was curious about the behavior
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.
Yeah, was also surprised
Updated the warnings for location providers and custom catalogs. |
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, thanks for adding this!
@@ -281,6 +282,11 @@ def test_import_file_io_does_not_exist() -> None: | |||
assert _import_file_io("pyiceberg.does.not.exist.FileIO", {}) is None | |||
|
|||
|
|||
def test_import_file_io_logs_exception(caplog: Any) -> None: | |||
_import_file_io("pyiceberg.does.not.exist.FileIO", {}) | |||
assert "ModuleNotFoundError: No module named 'pyiceberg.does'" in caplog.text |
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.
thanks! i was curious about the behavior
Closes #1577.
Log the underlying exception when a FileIO import fails.