Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't let ExtensionApp jpserver_extensions be overridden by config #1447

Merged
merged 1 commit into from
Aug 1, 2024

Conversation

minrk
Copy link
Contributor

@minrk minrk commented Jul 30, 2024

ensures jpserver_extensions set in make_serverapp is preserved after loading config files in ServerApp.initialize.

closes jupyterhub/jupyterhub#4859

Repro:

# jupyter_server_config.py
c.ServerApp.jpserver_extensions = {"anything": False}
# testext.py
from jupyter_server.extension.application import ExtensionApp


def _jupyter_server_extension_points():
    return [{"module": __name__, "app": TestExtension}]


class TestExtension(ExtensionApp):
    name = "tester"


if __name__ == "__main__":
    TestExtension.launch_instance()

and run:

python3 testext.py --config ./jupyter_server_config.py

which results in:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/minrk/dev/jpy/jupyterhub/test-env/testext.py", line 13, in <module>
    TestExtension.launch_instance()
  File "/Users/minrk/dev/jpy/jupyter_server/jupyter_server/extension/application.py", line 618, in launch_instance
    serverapp = cls.initialize_server(argv=args)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/minrk/dev/jpy/jupyter_server/jupyter_server/extension/application.py", line 587, in initialize_server
    serverapp.initialize(
  File "/Users/minrk/.virtualenvs/test-env/lib/python3.11/site-packages/traitlets/config/application.py", line 118, in inner
    return method(app, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/minrk/dev/jpy/jupyter_server/jupyter_server/serverapp.py", line 2750, in initialize
    point = self.extension_manager.extension_points[starter_extension]
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'tester'

ensures jpserver_extensions set in make_serverapp is preserved after loading config files
in ServerApp.initialize
@Zsailer
Copy link
Member

Zsailer commented Aug 1, 2024

Thanks, @minrk!

@Zsailer Zsailer merged commit 74655ce into jupyter-server:main Aug 1, 2024
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JupyterHub customizations prevent jupyter-server from starting up
2 participants