Skip to content

Commit

Permalink
Merge pull request #20 from yacchin1205/fix/jupyter-server-handler
Browse files Browse the repository at this point in the history
Update base handler
  • Loading branch information
yacchin1205 authored May 31, 2023
2 parents 48219b0 + f1952d6 commit 747e814
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 deletions.
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
2 changes: 1 addition & 1 deletion nbsearch/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version_info = (0, 1, 0, 'dev1')
version_info = (0, 2, 0, 'dev1')
__version__ = '.'.join(map(str, version_info))
3 changes: 2 additions & 1 deletion nbsearch/nbextension/notebook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion nbsearch/nbextension/tree.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 6 additions & 3 deletions nbsearch/v1/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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',
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
notebook>=6.5.4
tornado
requests
traitlets
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
zip_safe=False,
platforms=['Jupyter Notebook 6.x'],
install_requires=[
'notebook>=6.5.4',
'tornado',
'requests',
'traitlets',
Expand Down

0 comments on commit 747e814

Please sign in to comment.