From e3beeab1ce872b6894f6d9a4d4a7f835155a9ad8 Mon Sep 17 00:00:00 2001 From: yacchin1205 <968739+yacchin1205@users.noreply.github.com> Date: Tue, 30 May 2023 19:24:15 +0900 Subject: [PATCH 1/3] Fix base handler for jupyter_server --- Dockerfile | 11 +++++------ nbsearch/_version.py | 2 +- nbsearch/nbextension/notebook.yaml | 3 ++- nbsearch/nbextension/tree.yaml | 3 ++- nbsearch/v1/handlers.py | 9 ++++++--- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 73cface..412d746 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,6 +54,11 @@ RUN mkdir -p /opt/nbsearch/original/bin/ && \ chmod +x /opt/conda/bin/jupyterhub-singleuser /opt/conda/bin/jupyter-notebook /opt/conda/bin/jupyter-lab \ /opt/nbsearch/bin/run-hook.sh +RUN jupyter nbclassic-extension install --py --sys-prefix nbsearch && \ + jupyter nbclassic-serverextension enable --py --sys-prefix nbsearch && \ + jupyter nbclassic-extension enable --py --sys-prefix nbsearch && \ + jupyter nbclassic-extension enable --py --sys-prefix lc_notebook_diff + # Configuration for Server Proxy RUN cat /tmp/nbsearch/example/jupyter_notebook_config.py >> $CONDA_DIR/etc/jupyter/jupyter_notebook_config.py @@ -70,10 +75,4 @@ RUN mkdir /home/$NB_USER/.nbsearch/conf.d && \ RUN precreate-core jupyter-notebook /opt/nbsearch/solr/jupyter-notebook/ && \ precreate-core jupyter-cell /opt/nbsearch/solr/jupyter-cell/ -RUN jupyter nbextensions_configurator enable --user && \ - jupyter nbextension install --py --user nbsearch && \ - jupyter serverextension enable --py --user nbsearch && \ - jupyter nbextension enable --py --user nbsearch && \ - jupyter nbextension enable --py --user lc_notebook_diff - VOLUME /var/solr /var/minio diff --git a/nbsearch/_version.py b/nbsearch/_version.py index 53f025b..ffeb5e8 100644 --- a/nbsearch/_version.py +++ b/nbsearch/_version.py @@ -1,2 +1,2 @@ -version_info = (0, 1, 0, 'dev1') +version_info = (0, 2, 0, 'dev1') __version__ = '.'.join(map(str, version_info)) diff --git a/nbsearch/nbextension/notebook.yaml b/nbsearch/nbextension/notebook.yaml index 847a496..84613a9 100644 --- a/nbsearch/nbextension/notebook.yaml +++ b/nbsearch/nbextension/notebook.yaml @@ -3,4 +3,5 @@ Name: NBSearch - Notebook Section: notebook Description: "Database Extension for Notebooks" Main: notebook.js -Compatibility: 6.x +# 1.x means nbclassic - leave 6.x in place just in case. +Compatibility: 1.x 6.x \ No newline at end of file diff --git a/nbsearch/nbextension/tree.yaml b/nbsearch/nbextension/tree.yaml index 7069566..87da8a8 100644 --- a/nbsearch/nbextension/tree.yaml +++ b/nbsearch/nbextension/tree.yaml @@ -3,4 +3,5 @@ Name: NBSearch - Tree Section: tree Description: "Database Extension for Notebooks" Main: tree.js -Compatibility: 6.x +# 1.x means nbclassic - leave 6.x in place just in case. +Compatibility: 1.x 6.x \ No newline at end of file diff --git a/nbsearch/v1/handlers.py b/nbsearch/v1/handlers.py index d3bca28..6e23a3a 100644 --- a/nbsearch/v1/handlers.py +++ b/nbsearch/v1/handlers.py @@ -3,7 +3,8 @@ import os from stat import S_IREAD -from tornado import gen +from jupyter_server.base.handlers import APIHandler +from tornado import web import tornado.escape import tornado.ioloop import tornado.web @@ -12,10 +13,11 @@ NBSEARCH_TMP = 'nbsearch-tmp' -class SearchHandler(tornado.web.RequestHandler): +class SearchHandler(APIHandler): def initialize(self, db, base_dir): self.db = db + @web.authenticated async def get(self, target): start, limit = self._get_page() sort = self.get_query_argument('sort', None) @@ -47,7 +49,7 @@ def _get_page(self): return int(start), int(limit) -class ImportHandler(tornado.web.RequestHandler): +class ImportHandler(APIHandler): def initialize(self, db, base_dir): self.db = db self.base_dir = base_dir @@ -73,6 +75,7 @@ def _unique_filename(self, path, filename): alt_filename = '{} ({}){}'.format(base_filename, index, ext) return alt_filename + @web.authenticated async def get(self, path, id): solrquery, result = await self.db.query( 'jupyter-notebook', From 6262ec697fd1c8c7dd7bb5cdb4eae2244f148a0d Mon Sep 17 00:00:00 2001 From: yacchin1205 <968739+yacchin1205@users.noreply.github.com> Date: Tue, 30 May 2023 19:25:49 +0900 Subject: [PATCH 2/3] Fix whitespaces --- nbsearch/nbextension/notebook.yaml | 2 +- nbsearch/nbextension/tree.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nbsearch/nbextension/notebook.yaml b/nbsearch/nbextension/notebook.yaml index 84613a9..262a0dc 100644 --- a/nbsearch/nbextension/notebook.yaml +++ b/nbsearch/nbextension/notebook.yaml @@ -4,4 +4,4 @@ Section: notebook Description: "Database Extension for Notebooks" Main: notebook.js # 1.x means nbclassic - leave 6.x in place just in case. -Compatibility: 1.x 6.x \ No newline at end of file +Compatibility: 1.x 6.x diff --git a/nbsearch/nbextension/tree.yaml b/nbsearch/nbextension/tree.yaml index 87da8a8..5c99923 100644 --- a/nbsearch/nbextension/tree.yaml +++ b/nbsearch/nbextension/tree.yaml @@ -4,4 +4,4 @@ Section: tree Description: "Database Extension for Notebooks" Main: tree.js # 1.x means nbclassic - leave 6.x in place just in case. -Compatibility: 1.x 6.x \ No newline at end of file +Compatibility: 1.x 6.x From f1952d6a83c4779a0b59b759ffbbf456126c4aad Mon Sep 17 00:00:00 2001 From: yacchin1205 <968739+yacchin1205@users.noreply.github.com> Date: Wed, 31 May 2023 12:06:01 +0900 Subject: [PATCH 3/3] Fix dependencies --- requirements.txt | 1 + setup.py | 1 + 2 files changed, 2 insertions(+) diff --git a/requirements.txt b/requirements.txt index f3231fd..6c60d0d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +notebook>=6.5.4 tornado requests traitlets diff --git a/setup.py b/setup.py index a655cc9..98b48a8 100644 --- a/setup.py +++ b/setup.py @@ -18,6 +18,7 @@ zip_safe=False, platforms=['Jupyter Notebook 6.x'], install_requires=[ + 'notebook>=6.5.4', 'tornado', 'requests', 'traitlets',