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

Add support for widgets #73

Merged
merged 5 commits into from
Apr 17, 2023
Merged

Add support for widgets #73

merged 5 commits into from
Apr 17, 2023

Conversation

hbcarlos
Copy link
Contributor

@hbcarlos hbcarlos commented Apr 14, 2023

To test it, you can hardcode a widget here:
https://github.com/hbcarlos/jupyterlab-blockly/blob/be29b8b5eb5409f8a52a17731e9b8e6803787dcf/packages/blockly/src/layout.ts#L164

Then, if you press the run button, it will always generate the hardcoded widget.

Screencast.from.04-14-2023.01.22.08.PM.webm

@hbcarlos hbcarlos added the enhancement New feature or request label Apr 14, 2023
@hbcarlos hbcarlos self-assigned this Apr 14, 2023
@github-actions
Copy link
Contributor

Binder 👈 Launch a Binder on branch hbcarlos/jupyterlab-blockly/widgets

@@ -23,7 +23,8 @@ classifiers = [
"Programming Language :: Python :: 3.11",
]
dependencies = [
"jupyterlab~=3.6"
"jupyterlab~=3.6",
"jupyterlab_widgets~=3.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be ipywidgets ?

Copy link
Member

@jtpio jtpio Apr 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess jupyterlab_widgets is the minimal required dependency, so the sharedPackages like @jupyter-widgets/jupyterlab-manager defined in the package.json don't trigger errors on page load if they are missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's right @jtpio.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it actually needs any of those two?

It seems to me only the front-end would need this dependency. If ipywidgets is not installed by the user they cannot use widgets, and that's fine. If it is installed, they can.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understood correctly, jupyterlab_widgets is a lab extension. If that's the case, we need to make sure the extension is installed, and we can only do that if we depend on its Python package.

I don't understand why the versions differ between its JS and Python packages though.
https://github.com/jupyter-widgets/ipywidgets/blob/511663a56324cea5324f49a65ebe25e2f1b04d87/python/jupyterlab_widgets/jupyterlab_widgets/_version.py#L4
https://github.com/jupyter-widgets/ipywidgets/blob/511663a56324cea5324f49a65ebe25e2f1b04d87/python/jupyterlab_widgets/package.json#L3

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the same situation as in Voila. Voila front-end requires ipywidgets JS packages (to implement our own widget manager), but the Python package does not require ipywidgets or jupyterlab_widgets.

I don't understand why the versions differ between its JS and Python packages though

Legacy? We're in the same situation in many widgets packages (like bqplot and ipyleaflet), because at some point we only bumped the Python package because there were no applied changes in the front-end code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, I just tried to remove the Python dependency, but I can not.

I require IJupyterWidgetRegistry from '@jupyter-widgets/base' as an optional token, and still, if the token is missing, the extension doesn't activate.

Copy link
Member

@martinRenou martinRenou Apr 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I require IJupyterWidgetRegistry from '@jupyter-widgets/base' as an optional token, and still, if the token is missing, the extension doesn't activate.

Even if making the token optional?

Could this be part of a separate plugin just for widgets? This way it would not prevent the rest of the extension to activate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if making the token optional?

Yes

Could this be part of a separate plugin just for widgets? This way it would not prevent the rest of the extension to activate.

I think that might work. But I would need to create multiple plugins. We are not providing the document tracker at the moment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's really really really annoying that a missing optional token would broke the extension. That completely defeats the purpose of optional tokens.

@SylvainCorlay
Copy link
Member

Awesome, thanks for fixing this! This will allow us to have jupyterlab-blockly work with ipylgbst.

@hbcarlos hbcarlos merged commit 32b4140 into QuantStack:main Apr 17, 2023
@hbcarlos hbcarlos deleted the widgets branch April 17, 2023 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants