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

Fix DeckGL TextLayer issues #5427

Merged
merged 5 commits into from
Aug 24, 2023
Merged

Fix DeckGL TextLayer issues #5427

merged 5 commits into from
Aug 24, 2023

Conversation

MarcSkovMadsen
Copy link
Collaborator

Closes #5346

@MarcSkovMadsen
Copy link
Collaborator Author

MarcSkovMadsen commented Aug 24, 2023

The last issue I need to fix is how to handle the fact that DeckGL JS supports data rows containing lists like the coordinates value below. But the DeckGL pane does not.

The ColumnDataSource used to transfer the data does not support the coordinates list. Only -122.418466 ends up in the DeckGL data on the js side. 37.752254 is dropped along the way. See #5346 (comment)

data = {
        "layers": [
            {
                "@@type": "TextLayer",
                "data": [
                            {
                                "name": "24th St. Mission (24TH)",
                                "code": "24",
                                "address": "2800 Mission Street, San Francisco CA 94110",
                                "entries": 12817,
                                "exits": 12529,
                                "coordinates": [-122.418466, 37.752254]
                            }
                ],
            }
        ],
    }
    pane = DeckGL(data)

This can be handled in many ways

  • 1: Enable using list/ array values.
    • That seems difficult as we assume data is columnar and we want to transfer it efficiently using ColumnDataSource.
  • 2: Add validation to the DeckGL.object.
    • This could be done. But it could slow things down because there could be lots of rows to test if you want to test all the .data types supported. One place it could be done is when the ColumnDataSource is created. If we try to convert to a Pandas dataframe it raises an exception

image

cds.to_df()
*** ValueError: Per-column arrays must each be 1-dimensional

But again this could be a costly operation.

Please advice @philippjfr. Thanks.

@codecov
Copy link

codecov bot commented Aug 24, 2023

Codecov Report

Merging #5427 (edb106a) into main (78abc39) will decrease coverage by 2.43%.
The diff coverage is 25.00%.

❗ Current head edb106a differs from pull request most recent head 3d2dda7. Consider uploading reports for the commit 3d2dda7 to get more accurate results

@@            Coverage Diff             @@
##             main    #5427      +/-   ##
==========================================
- Coverage   72.59%   70.17%   -2.43%     
==========================================
  Files         274      274              
  Lines       39964    40005      +41     
==========================================
- Hits        29013    28073     -940     
- Misses      10951    11932     +981     
Flag Coverage Δ
unitexamples-tests 70.17% <25.00%> (-2.43%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
panel/pane/deckgl.py 67.26% <21.73%> (-28.14%) ⬇️
panel/tests/pane/test_deckgl.py 72.79% <28.00%> (-27.21%) ⬇️

... and 14 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@philippjfr
Copy link
Member

This example does not yet work for me with this PR: https://deckgl.readthedocs.io/en/latest/gallery/text_layer.html

@philippjfr
Copy link
Member

Nevermind, I see that this is because of the coordinates issue. Will fix.

@philippjfr
Copy link
Member

philippjfr commented Aug 24, 2023

Okay, fixed, i.e. implemented your suggestion 1.

Screen Shot 2023-08-24 at 11 41 26

This isn't actually difficult because the data is already serialized and sent correctly it just had to be correctly unpacked in JS.

@philippjfr philippjfr marked this pull request as ready for review August 24, 2023 09:48
@philippjfr philippjfr merged commit 811788b into main Aug 24, 2023
1 check passed
@philippjfr philippjfr deleted the fix/pydeck-text-layer-issue branch August 24, 2023 09:52
@MarcSkovMadsen
Copy link
Collaborator Author

Thanks so much for finalizing this.

panel/models/data.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Serialization Error When Visualizing PyDeck TextLayer
2 participants