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

Include type in failed sizeof warning #8580

Merged
merged 2 commits into from
Mar 15, 2024
Merged
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
5 changes: 3 additions & 2 deletions distributed/sizeof.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging

from dask.sizeof import sizeof
from dask.utils import format_bytes
from dask.utils import format_bytes, typename

Check warning on line 6 in distributed/sizeof.py

View check run for this annotation

Codecov / codecov/patch

distributed/sizeof.py#L6

Added line #L6 was not covered by tests

logger = logging.getLogger(__name__)

Expand All @@ -17,7 +17,8 @@
return sizeof(obj)
except Exception:
logger.warning(
f"Sizeof calculation failed. Defaulting to {format_bytes(int(default_size))}",
f"Sizeof calculation for object of type '{typename(obj)}' failed. "
f"Defaulting to {format_bytes(int(default_size))}",
exc_info=True,
)
return int(default_size)
5 changes: 4 additions & 1 deletion distributed/tests/test_sizeof.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ def __sizeof__(self):
with captured_logger("distributed.sizeof") as logs:
assert safe_sizeof(foo) == 1e6

assert "Sizeof calculation failed. Defaulting to 0.95 MiB" in logs.getvalue()
assert (
"Sizeof calculation for object of type 'test_sizeof.BadlySized' failed. Defaulting to 0.95 MiB"
in logs.getvalue()
)

# Can provide custom `default_size`
with captured_logger("distributed.sizeof") as logs:
Expand Down
Loading