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

Log exception when FileIO import fails #1578

Merged
merged 2 commits into from
Jan 26, 2025

Conversation

rshkv
Copy link
Contributor

@rshkv rshkv commented Jan 26, 2025

Closes #1577.

Log the underlying exception when a FileIO import fails.

Copy link
Contributor

@kevinjqliu kevinjqliu left a 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?

Comment on lines 318 to 319
except ModuleNotFoundError:
logger.warning("Could not initialize FileIO: %s", io_impl)
Copy link
Contributor

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

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
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, was also surprised

@rshkv
Copy link
Contributor Author

rshkv commented Jan 26, 2025

Updated the warnings for location providers and custom catalogs.

@rshkv rshkv requested a review from kevinjqliu January 26, 2025 18:28
Copy link
Contributor

@kevinjqliu kevinjqliu left a 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
Copy link
Contributor

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

@kevinjqliu kevinjqliu merged commit 6fffb64 into apache:main Jan 26, 2025
7 checks passed
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.

Log exception when FileIO import fails
2 participants