jupyterlab / hatch-jupyter-builder

A hatch plugin to help build Jupyter packages

Home Page:https://hatch-jupyter-builder.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add some type of check command

paddymul opened this issue · comments

Problem

I have had a lot of trouble trying to package and deploy jupyterlab widgets. Particularly around "module not found errors". There are many moving parts to a widget, and it would be nice to know at build time what doesn't line up.

From my investigations I can see module names pop up in the following places

package.json -> name
this is imported into js or src version.ts as MODULE_NAME

MODULE_NAME is used in
DOMWidgetModel extending models on the js/ts side

MODULE_NAME is also used in plugin.ts in the activateWidgetExtension function via registry.registerWidget

There is also an EXTENSION_ID used for IPlugin

Then on the python side there is

_frontend.py which references a hardcoded module_name

finally in ipydatagrid.json there is the following form

  "load_extensions": {
    "ipydatagrid/extension": true
  }
}

I think this gets converted into an install.json

I am trying to take the ipydatagrid repo as a baseline and first strip out everything to a very simple installable pip package (with it's own repo).

Then I want to put my ipywidget on to of that repo.


Another way of stating this is: "When I look at an existing working repo for an ipywidget - like ipydatagrid. I see the string ipydatagrid repeated in a variety of locations referencing different things - a python module, the name of an npm package, the MODULE_NAME of an ipywidget. and as part of the string of some type of jupyter notebook registration piece".

I understand that by convention ipydatagrid will be the same in each place, it would be nice to read an explanation of the true meaning of each occurence.

Proposed Solution

There should be some type of check command included with hatch-jupyter-builder that will make a good faith attempt to verify that all of these strings line up properly.

Additional context

I filed a related bug against widget-ts-cookiecutter
jupyter-widgets/widget-ts-cookiecutter#131

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

After further investigation,
ipydatagrid:_jupyter_labextension_paths
also seems very important.

the code seems to be called here
https://github.com/jupyterlab/jupyterlab/blob/fd875338edd5b1bbe360760c25ae740c2a42daaa/jupyterlab/federated_labextensions.py

It is difficult to tell when python modules are being referenced, and when js paths relative to python modules are being referenced.

I added a minimal reproduction repo https://github.com/paddymul/ts-ipywidget-starter