From fbd878ee8fd896ce793c74c5c8a7a3c9d38fa44b Mon Sep 17 00:00:00 2001 From: "Afshin T. Darian" Date: Wed, 6 Jan 2021 17:13:14 +0000 Subject: [PATCH] Fix integration with JupyterHub --- jupyterlab/labapp.py | 4 ++++ jupyterlab/labhubapp.py | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/jupyterlab/labapp.py b/jupyterlab/labapp.py index 3acd785f2407..6092ce77a22d 100644 --- a/jupyterlab/labapp.py +++ b/jupyterlab/labapp.py @@ -730,6 +730,10 @@ def initialize_handlers(self): self.handlers.extend(handlers) super().initialize_handlers() + def initialize(self, argv=None): + """Subclass because the ExtensionApp.initialize() method does not take arguments""" + super().initialize() + #----------------------------------------------------------------------------- # Main entry point #----------------------------------------------------------------------------- diff --git a/jupyterlab/labhubapp.py b/jupyterlab/labhubapp.py index e6fdb8dc081a..6417fa7feec5 100644 --- a/jupyterlab/labhubapp.py +++ b/jupyterlab/labhubapp.py @@ -59,6 +59,8 @@ } ) + + if make_singleuser_app: class SingleUserNotebookMixin(LabApp): @@ -510,8 +512,23 @@ def get_page(name): env.loader = ChoiceLoader([FunctionLoader(get_page), orig_loader]) + +# Overrides for Jupyter Server Extension config +class OverrideSingleUserNotebookApp(SingleUserNotebookApp): + name = 'labhub' + + # Disable the default jupyterlab extension and enable ourself + serverapp_config = { + "open_browser": True, + "jpserver_extensions": { "jupyterlab": False, "jupyterlab.labhubapp": True } + } + + +load_jupyter_server_extension = OverrideSingleUserNotebookApp._load_jupyter_server_extension + + def main(argv=None): - return SingleUserNotebookApp.launch_instance(argv) + return OverrideSingleUserNotebookApp.launch_instance(argv) if __name__ == "__main__":