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

Better error messaging for "model not found" #3891

Open
paddymul opened this issue Mar 5, 2024 · 1 comment
Open

Better error messaging for "model not found" #3891

paddymul opened this issue Mar 5, 2024 · 1 comment
Labels
Custom Widget Issues related to using ipywidgets as a framework for custom widgets

Comments

@paddymul
Copy link
Contributor

paddymul commented Mar 5, 2024

For new users of my custom widget, the experience of seeing a JS based error saying "widget: model not found" is frustrating and confusing.

I want to display a message like

"You seem to have installed Buckaroo after you started your jupyterlab server,  please restart your jupyter lab server for buckaroo to function properly"

From my understanding the python package installs properly, but the js is registered as a lab extenstion. By checking the server start time, and the package MTime, we can decide if a user is in this state and message appropriately when the package is imported or the widget used.

I don't know how to find the controlling jupyterlab server, and have filed a bug asking for help with that.

This code will be useful for all custom widgets.

jupyterlab/jupyterlab#15918

@paddymul paddymul added the Custom Widget Issues related to using ipywidgets as a framework for custom widgets label Mar 5, 2024
@paddymul
Copy link
Contributor Author

paddymul commented Mar 5, 2024

After more investigation I was able to make this work.

    parent_process = psutil.Process().parent()
    server_start_time = dtdt.fromtimestamp(parent_process.create_time())

    buckaroo_mtime = dtdt.fromtimestamp(os.path.getmtime(__file__))

    if buckaroo_mtime > server_start_time:
        print("""It looks like you installed Buckaroo after you started this notebook server. If you see a message like "Failed to load model class 'DCEFWidgetModel' from module 'buckaroo'", restart the jupyter server and try again.  If you have furter errors, please file a bug report at https://github.com/paddymul/buckaroo""")
        print("buckaroo_mtime", buckaroo_mtime, "server_start_time", server_start_time)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Custom Widget Issues related to using ipywidgets as a framework for custom widgets
Projects
None yet
Development

No branches or pull requests

1 participant