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

react/ts custom widget fails to render with "Failed to load model class" exception #262

Open
zkbitcoin opened this issue Jul 7, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@zkbitcoin
Copy link

zkbitcoin commented Jul 7, 2024

Reproduce

  1. create simple project using steps (leave defaults, project name will be myproject)

https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20Custom.html

  1. serve ipynb (via react code) file containing (myproject.ipynb)

import myproject
w = myproject.ExampleWidget()

typescript client uses

import {CellSidebarRun, Jupyter, Notebook} from '@datalayer/jupyter-react';

Notebook
readOnly={true}
path="/myproject.ipynb"
CellSidebar={CellSidebarRun}

  1. js error will occur:

[Open Browser Console for more detailed log - Double click to close this message]
Failed to load model class 'ExampleModel' from module 'myproject'
Error: Script error for "myproject"
https://requirejs.org/docs/errors.html#scripterror
at makeError (https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js:1:1795)
at HTMLScriptElement.onScriptError (https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js:1:17084)

console shows an attempt to load form registry potentially pointing to issue with registration

Loading from https://cdn.jsdelivr.net/npm/ for myproject@^0.1.0

Expected behavior

invoking same widget via running jupyter notebook works just fine, only react/ts code interface fails

Context

latest jupiter-ui npm libraries, mac, chrome

myproject % jupyter --version
Selected Jupyter core packages...
IPython : 8.26.0
ipykernel : 6.29.5
ipywidgets : 8.1.3
jupyter_client : 8.6.2
jupyter_core : 5.7.2
jupyter_server : 2.14.1
jupyterlab : 4.2.3
nbclient : 0.10.0
nbconvert : 7.16.4
nbformat : 5.10.4
notebook : 7.2.1
qtconsole : not installed
traitlets : 5.14.3

Note steps below wont work with latest jupyter version also ipywidgets work just fine with jupyter-ui (react/ts framework)

jupyter nbextension install --sys-prefix --symlink --overwrite --py myproject
jupyter nbextension enable --sys-prefix --py myproject

@zkbitcoin zkbitcoin added the bug Something isn't working label Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant