Skip to content

Commit

Permalink
Fix import for jupyter_server 1 (#1359)
Browse files Browse the repository at this point in the history
* Fix import for jupyter_server 1

* Force jupyter server version on CI

JupyterLab 4 being a build requirement, jupyter server 2 gets pulled. We
need to pin jupyter server for the test runtime.

* Fix name error server 1

* Fix import
  • Loading branch information
martinRenou committed Jul 31, 2023
1 parent 318581d commit 8f34f68
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

- name: Create the conda environment
shell: bash -l {0}
run: mamba install -q python=${{ matrix.python_version }} pip jupyterlab_pygments==0.1.0 pytest-cov pytest-rerunfailures nodejs=18 yarn=1 ipywidgets matplotlib xeus-cling "traitlets>=5.0.3,<6" ipykernel jupyter_server=${{ matrix.server_version }}
run: mamba install -q python=${{ matrix.python_version }} pip jupyterlab_pygments==0.1.0 pytest-cov pytest-rerunfailures nodejs=18 yarn=1 ipywidgets matplotlib xeus-cling "traitlets>=5.0.3,<6" ipykernel

- name: Install dependencies
shell: bash -l {0}
Expand All @@ -45,6 +45,10 @@ jobs:
(cd tests/test_template; pip install .)
(cd tests/skip_template; pip install .)
- name: Install proper jupyter server version
shell: bash -l {0}
run: pip install jupyter_server==${{ matrix.server_version }}

- name: Run tests
shell: bash -l {0}
run: |
Expand Down
10 changes: 6 additions & 4 deletions voila/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import errno
import random

from .voila_identity_provider import VoilaLoginHandler

try:
from urllib.parse import urljoin
from urllib.request import pathname2url
Expand Down Expand Up @@ -65,14 +63,15 @@
from jupyter_core.utils import run_sync
from jupyter_server.services.config.manager import ConfigManager

from jupyterlab_server.themes_handler import ThemesHandler
from .voila_identity_provider import VoilaLoginHandler
except ImportError:
JUPYTER_SERVER_2 = False

from jupyter_server.services.kernels.handlers import ZMQChannelsHandler
from jupyter_server.utils import url_path_join, run_sync
from jupyter_server.services.config import ConfigManager

from jupyterlab_server.themes_handler import ThemesHandler

from jupyter_client.kernelspec import KernelSpecManager

Expand Down Expand Up @@ -502,7 +501,8 @@ def setup_template_dirs(self):
template_name = self.voila_configuration.template
self.template_paths = collect_template_paths(['voila', 'nbconvert'], template_name, prune=True)
self.static_paths = collect_static_paths(['voila', 'nbconvert'], template_name)
self.static_paths.append(DEFAULT_STATIC_FILES_PATH)
if JUPYTER_SERVER_2:
self.static_paths.append(DEFAULT_STATIC_FILES_PATH)
conf_paths = [os.path.join(d, 'conf.json') for d in self.template_paths]
for p in conf_paths:
# see if config file exists
Expand Down Expand Up @@ -650,6 +650,8 @@ def init_handlers(self) -> List:
])

if JUPYTER_SERVER_2:


handlers.extend(self.identity_provider.get_handlers())

if self.voila_configuration.preheat_kernel:
Expand Down

0 comments on commit 8f34f68

Please sign in to comment.