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

TypeError: Cannot read properties of undefined (reading 'shape') #311

Closed
joelostblom opened this issue May 11, 2023 · 3 comments
Closed

Comments

@joelostblom
Copy link

When the run the following code from the altair doc page of large datasets:

import altair as alt
import pandas as pd
import vegafusion as vf
vf.enable()

data = pd.DataFrame({"x": range(10000)})
alt.Chart(data).mark_line()

I run into this error

ValueError: Vega-Lite to Vega conversion failed:
TypeError: Cannot read properties of undefined (reading 'shape')
    at js (https://cdn.skypack.dev/-/vega-lite@v5.8.0-4snbURNltT4se5LjMOKF/dist=es2020,mode=imports,min/optimized/vega-lite.js:1:82625)
    at Qm.hasMatchingType (https://cdn.skypack.dev/-/vega-lite@v5.8.0-4snbURNltT4se5LjMOKF/dist=es2020,mode=imports,min/optimized/vega-lite.js:1:82955)
    at eh.mapUnit (https://cdn.skypack.dev/-/vega-lite@v5.8.0-4snbURNltT4se5LjMOKF/dist=es2020,mode=imports,min/optimized/vega-lite.js:1:85584)
    at eh.mapLayerOrUnit (https://cdn.skypack.dev/-/vega-lite@v5.8.0-4snbURNltT4se5LjMOKF/dist=es2020,mode=imports,min/optimized/vega-lite.js:1:80174)
    at eh.map (https://cdn.skypack.dev/-/vega-lite@v5.8.0-4snbURNltT4se5LjMOKF/dist=es2020,mode=imports,min/optimized/vega-lite.js:1:80078)
    at eh.map (https://cdn.skypack.dev/-/vega-lite@v5.8.0-4snbURNltT4se5LjMOKF/dist=es2020,mode=imports,min/optimized/vega-lite.js:1:85239)
    at _h (https://cdn.skypack.dev/-/vega-lite@v5.8.0-4snbURNltT4se5LjMOKF/dist=es2020,mode=imports,min/optimized/vega-lite.js:1:92457)
    at _u (https://cdn.skypack.dev/-/vega-lite@v5.8.0-4snbURNltT4se5LjMOKF/dist=es2020,mode=imports,min/optimized/vega-lite.js:1:92253)
    at Module.gS (https://cdn.skypack.dev/-/vega-lite@v5.8.0-4snbURNltT4se5LjMOKF/dist=es2020,mode=imports,min/optimized/vega-lite.js:1:243034)
    at compileVegaLite_v5_8 (<anon>:14:17)

I tried with altair 5.0, vegafusion 1.2.4, vl-convert 0.9.0, and both jlab 3.6.3 and 4.0rc1. Is this maybe related to vegafusion and altair being out of sync in the vega-lite version they use?

When I run the example from the vegafusion widget docs, I see a slightly different error (the vegafusion mime-renderer examples work fine):

[Open Browser Console for more detailed log - Double click to close this message]
Failed to create view for 'VegaFusionView' from module 'vegafusion-jupyter' with model 'VegaFusionModel' from module 'vegafusion-jupyter'
RuntimeError: unreachable
    at http://localhost:8888/lab/extensions/vegafusion-jupyter/static/8361f39a3a84c8fad476.module.wasm:wasm-function[3318]:0x4f3eb4
    at http://localhost:8888/lab/extensions/vegafusion-jupyter/static/8361f39a3a84c8fad476.module.wasm:wasm-function[4544]:0x538cb0
    at http://localhost:8888/lab/extensions/vegafusion-jupyter/static/8361f39a3a84c8fad476.module.wasm:wasm-function[3686]:0x51dae8
    at http://localhost:8888/lab/extensions/vegafusion-jupyter/static/8361f39a3a84c8fad476.module.wasm:wasm-function[104]:0x1b90fc
    at http://localhost:8888/lab/extensions/vegafusion-jupyter/static/8361f39a3a84c8fad476.module.wasm:wasm-function[3652]:0x51c08e
    at q (http://localhost:8888/lab/extensions/vegafusion-jupyter/static/42.9865e6db7d1c799b693e.js?v=9865e6db7d1c799b693e:1:6535)
    at u.h [as embedVegaFusion] (http://localhost:8888/lab/extensions/vegafusion-jupyter/static/439.27bdac80f01ed3218e54.js?v=27bdac80f01ed3218e54:1:612)
    at u.value_changed (http://localhost:8888/lab/extensions/vegafusion-jupyter/static/480.24da4f13095ccf2d40e2.js?v=24da4f13095ccf2d40e2:1:2733)
    at u.render (http://localhost:8888/lab/extensions/vegafusion-jupyter/static/480.24da4f13095ccf2d40e2.js?v=24da4f13095ccf2d40e2:1:1575)
    at async http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.1a6d6a3a0542a41bec5a.js?v=1a6d6a3a0542a41bec5a:1:2951
@jonmmease
Copy link
Collaborator

Hi @joelostblom, I'm seeing the same error in the JS output without VegaFusion:

Screenshot 2023-05-11 at 2 08 57 PM

What is this example supposed to do, given that it doesn't have any encodings specified?

@joelostblom
Copy link
Author

Oh weird, we should update that example in the docs to use mark_point instead. The example is just supposed to illustrate how to disable the maxrows warning, but it doesn't make sense to use a line mark since it seems like that requires and encoding (even an empty one) whereas a point mark can be used without an encoding for illustration purposes.

One thing that confused me here was that the error including a lot of additional info than what I usually see when something goes wrong on the Vega-Lite side of things. For troubleshooting purposes, I think it would be helpful to just output what is shown in your screenshot when the error is not related to VegaFusion, but it's a minor comment as it seems like all the warnings raised on the Python level in Altair still show as expected and it is just when there are Javascript warnings that the VegaFusion and Vega-Lite messages get intermixed.

@joelostblom
Copy link
Author

Closing as this is not a vegafusion issue and we did the doc update in vega/altair#3052

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

No branches or pull requests

2 participants