K3D-tools / K3D-jupyter

K3D lets you create 3D plots backed by WebGL with high-level API (surfaces, isosurfaces, voxels, mesh, cloud points, vtk objects, volume renderer, colormaps, etc). The primary aim of K3D-jupyter is to be easy for use as stand alone package like matplotlib, but also to allow interoperation with existing libraries as VTK.
MIT License
916 stars 123 forks source link

Texture plots can't render: ipywidgets not loaded by jupyterlab 3.5 or 3.6 #420

Closed dcunited001 closed 6 months ago

dcunited001 commented 1 year ago

I've pasted my requirements.txt at the end. I reduced the environment to just k3d and jupyterlab

Description

I seem to be having issues similar to #265, considering the error below:

Unsatisfied version 6.0.4 from @jupyter-widgets/jupyterlab-manager of shared singleton module @jupyter-widgets/base (required ^4.1.0)

Also, this is perhaps similar to jupyterlab/jupyterlab-desktop#576, but I don't really know much about jupyter extensions or ipywidgets.

It's hard for me to trace the JS errors, since the sourcemaps aren't working and it's minified. I tried pulling it into emacs and reformatting, but the bulk of it is still minified.

To deal with this, I installed k3d on devel and built locally.

What I Did

Some plots will render:

import k3d

plot = k3d.plot()
plot += k3d.line([[0, 0, 0],
                 [1, 1, 1]])

plot.display()

dem = examples.download_crater_topo()
data = dem.get_array(0).reshape(dem.dimensions[::-1])[0, :, :].astype(np.float32)

plot2 = k3d.plot()

obj = k3d.surface(data,
            attribute=data,
            flat_shading=False,
            color_map = k3d.colormaps.matplotlib_color_maps.viridis,
            xmin=dem.bounds[0],
            xmax=dem.bounds[1],
            ymin=dem.bounds[2],
            ymax=dem.bounds[3])

plot2 += obj
plot2.display

But other plots present an error:

plt_texture = k3d.texture(data,
                          file_format='png')

plot = k3d.plot()
plot += plt_texture

Web console log / python logs

Unsatisfied version 6.0.4 from @jupyter-widgets/jupyterlab-manager of shared singleton module @jupyter-widgets/base (required ^4.1.0)
Unsatisfied version 6.0.4 from @jupyter-widgets/jupyterlab-manager of shared singleton module @jupyter-widgets/base (required ^4.1.0)

Starting application in workspace: "default"
Starting WebSocket: ws://localhost:8888/api/kernels/ef1d45d8-50d9-4c36-a179-6ae48d37beec 
Starting WebSocket: ws://localhost:8888/api/kernels/9efcadb5-ae51-4c83-87f9-152617ee4d9d 
Starting WebSocket: ws://localhost:8888/api/kernels/ef1d45d8-50d9-4c36-a179-6ae48d37beec 2 

Failed to fetch ipywidgets through the "jupyter.widget.control" comm channel, fallback to fetching individual model state. Reason: Control comm was closed too early 2 

Error: widget model not found
    get_model http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager
    renderModel http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager

Source map error: Error: request failed with status 404
Resource URL: http://localhost:8888/static/lab/jlab_core.a1b2c3.js
Source Map URL: jlab_core.a1b2c3.js.map

After the failed sourcemap fetches:

WEBGL_debug_renderer_info is deprecated in Firefox and will be removed. Please use RENDERER. 
K3D: (UNMASKED_VENDOR_WEBGL) AMD
K3D: (UNMASKED_RENDERER_WEBGL) Radeon R9 200 Series
K3D: (depth bits) 24
K3D: (stencil bits) 8

Pip environment

aiofiles==22.1.0
aiosqlite==0.19.0
anyio==3.6.2
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
arrow==1.2.3
asttokens==2.2.1
attrs==23.1.0
Babel==2.12.1
backcall==0.2.0
beautifulsoup4==4.12.2
bleach==6.0.0
certifi==2022.12.7
cffi==1.15.1
charset-normalizer==3.1.0
comm==0.1.3
debugpy==1.6.7
decorator==5.1.1
defusedxml==0.7.1
executing==1.2.0
fastjsonschema==2.16.3
fqdn==1.5.1
idna==3.4
ipykernel==6.22.0
ipython==8.13.2
ipython-genutils==0.2.0
ipywidgets==8.0.6
isoduration==20.11.0
jedi==0.18.2
Jinja2==3.1.2
json5==0.9.11
jsonpointer==2.3
jsonschema==4.17.3
jupyter-events==0.6.3
jupyter-ydoc==0.2.4
jupyter_client==8.2.0
jupyter_core==5.3.0
jupyter_server==2.5.0
jupyter_server_fileid==0.9.0
jupyter_server_terminals==0.4.4
jupyter_server_ydoc==0.8.0
jupyterlab==3.5.3
jupyterlab-pygments==0.2.2
jupyterlab-widgets==3.0.7
jupyterlab_server==2.22.1
k3d @ git+https://github.com/K3D-tools/K3D-jupyter@25bd5a22a08812a94db078a6dc142611dc4d5b09
MarkupSafe==2.1.2
matplotlib-inline==0.1.6
mistune==2.0.5
msgpack==1.0.5
nbclassic==1.0.0
nbclient==0.7.4
nbconvert==7.3.1
nbformat==5.8.0
nest-asyncio==1.5.6
notebook==6.5.4
notebook_shim==0.2.3
numpy==1.24.3
packaging==23.1
pandocfilters==1.5.0
parso==0.8.3
pexpect==4.8.0
pickleshare==0.7.5
platformdirs==3.5.0
prometheus-client==0.16.0
prompt-toolkit==3.0.38
psutil==5.9.5
ptyprocess==0.7.0
pure-eval==0.2.2
pycparser==2.21
Pygments==2.15.1
pyrsistent==0.19.3
python-dateutil==2.8.2
python-json-logger==2.0.7
PyYAML==6.0
pyzmq==25.0.2
requests==2.30.0
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
Send2Trash==1.8.2
six==1.16.0
sniffio==1.3.0
soupsieve==2.4.1
stack-data==0.6.2
terminado==0.17.1
tinycss2==1.2.1
tomli==2.0.1
tornado==6.3.1
traitlets==5.9.0
traittypes==0.2.1
uri-template==1.2.0
urllib3==2.0.2
wcwidth==0.2.6
webcolors==1.13
webencodings==0.5.1
websocket-client==1.5.1
widgetsnbextension==4.0.7
y-py==0.5.9
ypy-websocket==0.8.2
dcunited001 commented 1 year ago

I didn't realize that I needed to enable Jupyter extensions, but after enabling them, my console logs are pretty much the same, except for a line mentioning the following. However, these are all requests for images from Jupyter.

Some cookies are misusing the recommended “SameSite“ attribute (309)

So I created a new profile to run Firefox in standard mode. I also tried with Ungoogled Chromium and Librewolf, but these are more restrictive. I can't install the normal chromium because "it conflicts with the ungoogled version." Changing to standard mode doesn't seem to change much.

When I try to load the code using snapshots on devel, I'm getting an error related to unpkg.com not having the 2.15.3 code.

artur-trzesiok commented 1 year ago

Hi @dcunited001

You use K3D version: 2.15.3 (devel@25bd5a2). That version is not publish so that why snapshots are not working. You can produce snapshots with plot.snapshot_type='full' to be independent from npm/unkpg.com status.

To install devel version I use:

pip install -ve .
jupyter nbextension install --py --user k3d
jupyter nbextension enable --py --user k3d

It is working on my machine in chrome and firefox. K3D will be not related to cookies problem (k3d does not use cookies)

Can you tell me if you can run other example from k3d or just texture?

artur-trzesiok commented 10 months ago

@dcunited001 any updates?

artur-trzesiok commented 6 months ago

I'm closing a issue because of long silent