jupyter-server / jupyverse

A Jupyter server based on FastAPI :rocket:
https://jupyter-server.github.io/jupyverse
Other
212 stars 27 forks source link

fps_yjs missing runtime dependency on ypywidgets #374

Closed minrk closed 7 months ago

minrk commented 7 months ago

Description

instaling jupyverse requires ypywidgets, but does not get installed, so startup fails with:

  File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/fps_yjs/main.py", line 13, in <module>
    from .routes import _Yjs
  File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/fps_yjs/routes.py", line 31, in <module>
    from .ywidgets import Widgets
  File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/fps_yjs/ywidgets/__init__.py", line 1, in <module>
    from .widgets import Widgets as Widgets
  File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/fps_yjs/ywidgets/widgets.py", line 3, in <module>
    from ypywidgets.utils import (  # type: ignore
ModuleNotFoundError: No module named 'ypywidgets'

The dependency is in the test requirements, but should presumably be in the runtime requirements, since it doesn't run without it.

Found in https://github.com/jupyterhub/jupyterhub/pull/4663

Reproduce

  1. pip instal jupyverse
  2. jupyverse
  3. fails with:
> jupyverse
[2023-12-18 15:11:04,909 INFO] Running in development mode
[2023-12-18 15:11:05,070 INFO] Starting application
[2023-12-18 15:11:07,310 ERROR] Error during application startup
Traceback (most recent call last):
  File "/Users/minrk/.virtualenvs/test_jpy/lib/python3.10/site-packages/asphalt/core/runner.py", line 110, in run_application
    event_loop.run_until_complete(coro)
  File "/Users/minrk/conda/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/Users/minrk/conda/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
    return fut.result()
  File "/Users/minrk/.virtualenvs/test_jpy/lib/python3.10/site-packages/jupyverse_api/main/__init__.py", line 83, in start
    await super().start(ctx)
  File "/Users/minrk/.virtualenvs/test_jpy/lib/python3.10/site-packages/asphalt/web/asgi3.py", line 121, in start
    await super().start(ctx)
  File "/Users/minrk/.virtualenvs/test_jpy/lib/python3.10/site-packages/asphalt/core/component.py", line 112, in start
    self.add_component(alias)
  File "/Users/minrk/.virtualenvs/test_jpy/lib/python3.10/site-packages/asphalt/core/component.py", line 101, in add_component
    component = component_types.create_object(**config)
  File "/Users/minrk/.virtualenvs/test_jpy/lib/python3.10/site-packages/asphalt/core/utils.py", line 182, in create_object
    plugin_class = self.resolve(type)
  File "/Users/minrk/.virtualenvs/test_jpy/lib/python3.10/site-packages/asphalt/core/utils.py", line 165, in resolve
    value = self._resolved[obj] = value.load()
  File "/Users/minrk/conda/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/Users/minrk/conda/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/minrk/.virtualenvs/test_jpy/lib/python3.10/site-packages/fps_yjs/main.py", line 13, in <module>
    from .routes import _Yjs
  File "/Users/minrk/.virtualenvs/test_jpy/lib/python3.10/site-packages/fps_yjs/routes.py", line 31, in <module>
    from .ywidgets import Widgets
  File "/Users/minrk/.virtualenvs/test_jpy/lib/python3.10/site-packages/fps_yjs/ywidgets/__init__.py", line 1, in <module>
    from .widgets import Widgets as Widgets
  File "/Users/minrk/.virtualenvs/test_jpy/lib/python3.10/site-packages/fps_yjs/ywidgets/widgets.py", line 3, in <module>
    from ypywidgets.utils import (  # type: ignore
ModuleNotFoundError: No module named 'ypywidgets'

Expected behavior

jupyverse starts with expressed dependencies.

Context

pip freeze ``` aiosqlite==0.19.0 annotated-types==0.6.0 anyio==4.2.0 asgiref==3.7.2 asphalt==4.12.0 asphalt-web==1.3.0 async-generator==1.10 async-timeout==4.0.3 asyncio-extras==1.3.2 attrs==23.1.0 Babel==2.14.0 beautifulsoup4==4.12.2 bleach==6.1.0 click==8.1.7 defusedxml==0.7.1 exceptiongroup==1.2.0 fastapi==0.103.0 fastjsonschema==2.19.0 fps_contents==0.4.0 fps_frontend==0.4.0 fps_kernels==0.4.0 fps_lab==0.4.0 fps_nbconvert==0.4.0 fps_terminals==0.4.0 fps_yjs==0.4.0 h11==0.14.0 idna==3.6 Jinja2==3.1.2 json5==0.9.14 jsonschema==4.20.0 jsonschema-specifications==2023.11.2 jupyter_client==8.6.0 jupyter_core==5.5.1 jupyterlab_pygments==0.3.0 jupyverse==0.4.0 jupyverse_api==0.4.0 markdown-it-py==3.0.0 MarkupSafe==2.1.3 mdurl==0.1.2 mistune==3.0.2 nbclient==0.9.0 nbconvert==7.13.0 nbformat==5.9.2 packaging==23.2 pandocfilters==1.5.0 platformdirs==4.1.0 pycrdt==0.7.2 pydantic==2.5.2 pydantic_core==2.14.5 Pygments==2.17.2 python-dateutil==2.8.2 pyzmq==25.1.2 referencing==0.32.0 rich==13.7.0 rich-click==1.7.2 rpds-py==0.15.2 ruamel.yaml==0.18.5 ruamel.yaml.clib==0.2.8 six==1.16.0 sniffio==1.3.0 soupsieve==2.5 starlette==0.27.0 tinycss2==1.2.1 tornado==6.4 traitlets==5.14.0 types-python-dateutil==2.8.19.14 typing_extensions==4.9.0 uvicorn==0.24.0.post1 watchfiles==0.21.0 webencodings==0.5.1 websockets==12.0 ```
davidbrochart commented 7 months ago

Thanks for reporting the issue. I'm going to make ypywidgets an optional dependency, with a check at run-time.

davidbrochart commented 7 months ago

I released jupyverse v0.4.1 which should fix this issue.

minrk commented 7 months ago

Thanks!