Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pyiceberg/catalog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ def delete_files(io: FileIO, files_to_delete: set[str], file_type: str) -> None:
for file in files_to_delete:
try:
io.delete(file)
except OSError as exc:
logger.warning(msg=f"Failed to delete {file_type} file {file}", exc_info=exc)
except OSError:
logger.warning(f"Failed to delete {file_type} file {file}", exc_info=logger.isEnabledFor(logging.DEBUG))


def delete_data_files(io: FileIO, manifests_to_delete: list[ManifestFile]) -> None:
Expand All @@ -305,8 +305,8 @@ def delete_data_files(io: FileIO, manifests_to_delete: list[ManifestFile]) -> No
if not deleted_files.get(path, False):
try:
io.delete(path)
except OSError as exc:
logger.warning(msg=f"Failed to delete data file {path}", exc_info=exc)
except OSError:
logger.warning(f"Failed to delete data file {path}", exc_info=logger.isEnabledFor(logging.DEBUG))
deleted_files[path] = True


Expand All @@ -319,8 +319,8 @@ def _import_catalog(name: str, catalog_impl: str, properties: Properties) -> Cat
module = importlib.import_module(module_name)
class_ = getattr(module, class_name)
return class_(name, **properties)
except ModuleNotFoundError as exc:
logger.warning(f"Could not initialize Catalog: {catalog_impl}", exc_info=exc)
except ModuleNotFoundError:
logger.warning(f"Could not initialize Catalog: {catalog_impl}", exc_info=logger.isEnabledFor(logging.DEBUG))
return None


Expand Down
4 changes: 2 additions & 2 deletions pyiceberg/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ def _import_file_io(io_impl: str, properties: Properties) -> FileIO | None:
module = importlib.import_module(module_name)
class_ = getattr(module, class_name)
return class_(properties)
except ModuleNotFoundError as exc:
logger.warning(f"Could not initialize FileIO: {io_impl}", exc_info=exc)
except ModuleNotFoundError:
logger.warning(f"Could not initialize FileIO: {io_impl}", exc_info=logger.isEnabledFor(logging.DEBUG))
return None


Expand Down
7 changes: 5 additions & 2 deletions pyiceberg/table/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,11 @@ def _import_location_provider(
module = importlib.import_module(module_name)
class_ = getattr(module, class_name)
return class_(table_location, table_properties)
except ModuleNotFoundError as exc:
logger.warning(f"Could not initialize LocationProvider: {location_provider_impl}", exc_info=exc)
except ModuleNotFoundError:
logger.warning(
f"Could not initialize LocationProvider: {location_provider_impl}",
exc_info=logger.isEnabledFor(logging.DEBUG),
)
return None


Expand Down
4 changes: 4 additions & 0 deletions tests/io/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,11 @@ def test_import_file_io() -> None:


def test_import_file_io_does_not_exist(caplog: Any) -> None:
import logging

caplog.set_level(logging.DEBUG)
assert _import_file_io("pyiceberg.does.not.exist.FileIO", {}) is None
assert "Could not initialize FileIO: pyiceberg.does.not.exist.FileIO" in caplog.text
assert "ModuleNotFoundError: No module named 'pyiceberg.does'" in caplog.text


Expand Down
4 changes: 4 additions & 0 deletions tests/table/test_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,14 @@ def test_custom_location_provider_single_path() -> None:


def test_custom_location_provider_not_found(caplog: Any) -> None:
import logging

caplog.set_level(logging.DEBUG)
with pytest.raises(ValueError, match=r"Could not initialize LocationProvider"):
load_location_provider(
table_location="table_location", table_properties={"write.py-location-provider.impl": "module.not_found"}
)
assert "Could not initialize LocationProvider: module.not_found" in caplog.text
assert "ModuleNotFoundError: No module named 'module'" in caplog.text


Expand Down