Repository navigation
feat(pydeck): write compact json in to_html - #10773
Conversation
|
chrisgervang
left a comment
There was a problem hiding this comment.
Thanks!
Why would someone need the compatibility feature, if it's still serialized as valid JSON?
|
Two observable behaviors depend on the pretty default, beyond JSON validity:
So the flag scopes the change to the one path the issue measured ( |
2453422 to
ddb008a
Compare
|
The reduction is worth having, but I'd rather not add # deck.py
from .json_tools import JSONMixin, serialize
...
deck_json = serialize(self, compact=True)# json_tools.py
def to_json(self):
"""
Return a JSON-ified version of the Deck object.
"""
return serialize(self)For the tests, import |
|
Looking at similar libraries, pandas and pydantic expose an The important thing is to improve the HTML serialization. |
Comments Outside DiffThese findings could not be posted inline.
|
|
Both points taken. abe4561 keeps
The two tests now exercise the internal flag: One environment note for the record: the full pydeck suite shows 2 failures here, |
|
On Compact JSON option rejected ( On HTML bypasses JSON overrides: the mechanism is real. On So the trade is explicit and it is yours to settle: compact HTML, or honoured Also merged |
…t-to-html # Conflicts: # bindings/pydeck/docs/CHANGELOG.rst
|
Re-ran the suite on the merged head: The two failures are Upstream's #10794 also touched the jupyter widget, so the count went from 65 to 88 passed since the last run. |
chrisgervang
left a comment
There was a problem hiding this comment.
Why are subclasses a concern? 1b53b5d seems overkill
If they're already subclassing they can override whatever they need to customize, right?
|
You are right and 3469f7b drops the whole subclass branch: |
| Notes | ||
| ----- | ||
| The deck JSON is embedded in the HTML in compact form, without | ||
| indentation or separator whitespace, to reduce file size. When | ||
| :meth:`to_json` is inherited, the payload is serialized compact in one | ||
| pass; a subclass that overrides it has its string compacted instead, | ||
| so overrides keep shaping the HTML. | ||
|
|
There was a problem hiding this comment.
Could you remove this Notes section? The second sentence describes subclass handling the code doesn’t have: to_html now always calls serialize(self, compact=True). The compact format itself is an implementation detail, and the CHANGELOG and whats-new entries already cover it.
There was a problem hiding this comment.
Done in fd8179f: the Notes section is gone. The compact format is covered by the CHANGELOG and whats-new entries as you said.
…t-to-html # Conflicts: # bindings/pydeck/docs/CHANGELOG.rst
|
Merged master into the branch. The only conflict was the 0.9.4 section of
Since the push resets the latest-commit approval, it will need one more review pass. |
(cherry picked from commit 11963ab)
Closes #10747
Background
to_htmlembeds the deck JSON withindent=2, so indentation whitespace dominates file size for geojson-heavy payloads. This PR embeds it withseparators=(',', ':')and no indent, following the proposal in the issue.Change List
serialize: optionalcompactflag, off by defaultDeck.to_html: embed the deck JSON withcompact=TrueJSONMixin.to_json: unchanged, its output stays prettyPrepared with AI assistance (GLM 5.3 via Oh My Pi) and reviewed before submission.
Note
Low Risk
Serialization output format change is scoped to HTML embedding only;
to_json()behavior is unchanged and tests verify JSON equivalence.Overview
Smaller HTML exports:
Deck.to_html()now embeds the deck.gl configuration as minified JSON (noindent=2, tightseparators) instead of pretty-printed JSON, which cuts file size when payloads are large (e.g. GeoJSON-heavy maps).serialize()injson_toolsgains an optionalcompact=Trueflag; default behavior is unchanged, soto_json()and notebook-friendly pretty output stay the same. Tests assert compact output is smaller, newline-free, and semantically equal to the pretty form, and that HTML contains the compact string. CHANGELOG and what's-new docs note the behavior.Reviewed by Cursor Bugbot for commit cf184b4. Bugbot is set up for automated code reviews on this repo. Configure here.