Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Oct 27, 2021
1 parent 9ca2762 commit f58e770
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions voila/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
from jupyter_server.utils import url_path_join, run_sync
from jupyter_server.services.config import ConfigManager

from fps_uvicorn.cli import app as fps_app
from fps_voila.routes import init_voila_handler

from jupyter_client.kernelspec import KernelSpecManager

from jupyter_core.paths import jupyter_config_path, jupyter_path
Expand Down Expand Up @@ -457,6 +454,9 @@ def start(self):
self.server_url = self.server_url or self.base_url

if self.fps:
from fps_uvicorn.cli import app as fps_app
from fps_voila.routes import init_voila_handler

# pass options to FPS app
options = sys.argv[1:]
sys.argv = sys.argv[:1]
Expand Down
2 changes: 1 addition & 1 deletion voila/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async def _get(self, path=None):
else:
# All kernels are used or pre-heated kernel is disabled, start a normal kernel.
gen = NotebookRenderer(
self.is_fps,
is_fps=self.is_fps,
voila_configuration=self.voila_configuration,
traitlet_config=self.traitlet_config,
notebook_path=notebook_path,
Expand Down
6 changes: 3 additions & 3 deletions voila/notebook_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from nbclient.util import ensure_async
from nbconvert.preprocessors import ClearOutputPreprocessor
from traitlets.config.configurable import LoggingConfigurable
from fps_kernels.kernel_server.server import KernelServer, kernels, connect_channel

from .execute import VoilaExecutor, strip_code_cell_warnings
from .exporter import VoilaExporter
Expand All @@ -32,9 +31,9 @@
class NotebookRenderer(LoggingConfigurable):
"""Render the notebook into HTML string."""

def __init__(self, is_fps, **kwargs):
def __init__(self, **kwargs):
super().__init__()
self.is_fps = is_fps
self.is_fps = kwargs.pop("is_fps", False)
self.root_dir = kwargs.get('root_dir', [])
self.notebook_path = kwargs.get('notebook_path', []) # should it be []
self.template_paths = kwargs.get('template_paths', [])
Expand Down Expand Up @@ -210,6 +209,7 @@ async def _jinja_kernel_start(self, nb, kernel_id, kernel_future):
assert not self.kernel_started, 'kernel was already started'
km = await ensure_async(kernel_future)
if self.is_fps:
from fps_kernels.kernel_server.server import KernelServer, kernels, connect_channel
connection_cfg = km.get_connection_info()
connection_cfg["key"] = connection_cfg["key"].decode()
kernel_server = KernelServer(connection_cfg=connection_cfg, write_connection_file=False)
Expand Down
2 changes: 1 addition & 1 deletion voila/treehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import os

from tornado import web
from fastapi import HTTPException

from jupyter_server.base.handlers import JupyterHandler
from jupyter_server.utils import url_path_join, url_escape
Expand Down Expand Up @@ -56,6 +55,7 @@ def allowed_content(content):
return self.redirect(url)
else:
if self.is_fps:
from fastapi import HTTPException
raise HTTPException(status_code=404, detail=f"{path} not found")
else:
raise web.HTTPError(404)
Expand Down

0 comments on commit f58e770

Please sign in to comment.