Skip to content

Compress serialized config data with zlib #4465

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import base64
import tblib.pickling_support
import xml.etree.ElementTree
import zlib

try:
import resource
Expand Down Expand Up @@ -1467,7 +1468,7 @@ def serialize_for_cli(data):
serialized_data: str
The serialized data as a string
"""
return base64.urlsafe_b64encode(json.dumps(data).encode()).decode()
return base64.urlsafe_b64encode(zlib.compress(json.dumps(data).encode())).decode()


def deserialize_for_cli(data):
Expand All @@ -1482,7 +1483,7 @@ def deserialize_for_cli(data):
deserialized_data: obj
The de-serialized data
"""
return json.loads(base64.urlsafe_b64decode(data.encode()).decode())
return json.loads(zlib.decompress(base64.urlsafe_b64decode(data.encode())).decode())


class EmptyContext:
Expand Down