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

Fall back to pickle in protocol.dumps instead of failing hard #8447

Merged
merged 6 commits into from
Jan 10, 2024

Conversation

hendrikmakait
Copy link
Member

Closes #8446

  • Tests added / passed
  • Passes pre-commit run --all-files

try:
frames[0] = msgpack.dumps(msg, default=_encode_default, use_bin_type=True)
except TypeError as e:
logger.warning(e)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure how meaningful this is to users. Just logging the original exception appears to be an error for users but we're handling it gracefully. If anything we should log a custom message making them aware of a possible performance issue but I'm not sure if this is actually worth a warning log

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair enough, I'll de-escalate that to an INFO log with a custom message. I'd like to have something logged here to raise user attention and possibly for log analysis to highlight potential performance issues.

Comment on lines 114 to 129
if isinstance(obj, (Serialize, Serialized)):
offset = len(frames)
frames.extend(create_serialized_sub_frames(obj))
return {"__Serialized__": offset}
elif isinstance(obj, (ToPickle, Pickled)):
offset = len(frames)
frames.extend(create_pickled_sub_frames(obj))
return {"__Pickled__": offset}
else:
encoded = msgpack_encode_default(obj)
if encoded is not obj or _is_msgpack_serializable(obj):
return encoded
obj = ToPickle(obj)
offset = len(frames)
frames.extend(create_pickled_sub_frames(obj))
return {"__Pickled__": offset}
Copy link
Member

Choose a reason for hiding this comment

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

in the interest of DRY

Suggested change
if isinstance(obj, (Serialize, Serialized)):
offset = len(frames)
frames.extend(create_serialized_sub_frames(obj))
return {"__Serialized__": offset}
elif isinstance(obj, (ToPickle, Pickled)):
offset = len(frames)
frames.extend(create_pickled_sub_frames(obj))
return {"__Pickled__": offset}
else:
encoded = msgpack_encode_default(obj)
if encoded is not obj or _is_msgpack_serializable(obj):
return encoded
obj = ToPickle(obj)
offset = len(frames)
frames.extend(create_pickled_sub_frames(obj))
return {"__Pickled__": offset}
rv = _enode_default(obj)
if rv is obj and not _is_msgpack_serializable(obj):
obj = ToPickle(obj)
offset = len(frames)
frames.extend(create_pickled_sub_frames(obj))
return {"__Pickled__": offset}
return rv

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point

Copy link
Contributor

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

    27 files  ± 0      27 suites  ±0   9h 37m 42s ⏱️ - 22m 5s
 3 952 tests + 1   3 840 ✅  -  2    109 💤 ±0  2 ❌ +2  1 🔥 +1 
49 710 runs  +14  47 419 ✅ +12  2 288 💤  - 1  2 ❌ +2  1 🔥 +1 

For more details on these failures and errors, see this check.

Results for commit d88c407. ± Comparison against base commit 5c481dd.

@hendrikmakait hendrikmakait merged commit c545342 into dask:main Jan 10, 2024
30 of 33 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
2 participants