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

serverapp not defined in extension manager #1134

Closed
davidbrochart opened this issue Dec 16, 2022 · 8 comments · Fixed by #1139
Closed

serverapp not defined in extension manager #1134

davidbrochart opened this issue Dec 16, 2022 · 8 comments · Fixed by #1139
Labels

Comments

@davidbrochart
Copy link
Contributor

Description

jupyter server extension list fails with AttributeError: 'NoneType' object has no attribute 'reraise_server_extension_failures' when terminals extension is installed in jupyter-server<2.

Reproduce

  1. pip install jupyterlab
  2. pip freeze|grep jupyter shows:
jupyter_server==2.0.1
jupyter_server_terminals==0.4.2
  1. pip install jupyter-server==1.23.3
  2. pip freeze|grep jupyter shows:
jupyter-server==1.23.3
jupyter_server_terminals==0.4.2
  1. jupyter server extension list
Config dir: /home/david/.jupyter

/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_server_terminals/__init__.py:8: UserWarning: Could not import submodules
  warnings.warn("Could not import submodules")
Traceback (most recent call last):
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_server/extension/manager.py", line 320, in add_extension
    extpkg = ExtensionPackage(name=extension_name, enabled=enabled)
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_server/extension/manager.py", line 166, in __init__
    super().__init__(*args, **kwargs)
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/traitlets/traitlets.py", line 1357, in __init__
    value = self._traits[key]._cross_validate(self, getattr(self, key))
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/traitlets/traitlets.py", line 743, in _cross_validate
    value = obj._trait_validators[self.name](obj, proposal)
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/traitlets/traitlets.py", line 1229, in __call__
    return self.func(*args, **kwargs)
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_server/extension/manager.py", line 175, in _validate_name
    self._module, self._metadata = get_metadata(name)
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_server/extension/utils.py", line 58, in get_metadata
    return module, module._jupyter_server_extension_points()
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_server_terminals/__init__.py", line 15, in _jupyter_server_extension_points
    "app": TerminalsExtensionApp,
NameError: name 'TerminalsExtensionApp' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/david/mambaforge/envs/nbclient_issue/bin/jupyter-server", line 8, in <module>
    sys.exit(main())
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_core/application.py", line 276, in launch_instance
    return super().launch_instance(argv=argv, **kwargs)
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/traitlets/config/application.py", line 992, in launch_instance
    app.start()
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_server/serverapp.py", line 2814, in start
    self.start_app()
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_server/serverapp.py", line 2710, in start_app
    super().start()
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_core/application.py", line 265, in start
    self.subapp.start()
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_server/extension/serverextension.py", line 368, in start
    super().start()
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_core/application.py", line 265, in start
    self.subapp.start()
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_server/extension/serverextension.py", line 342, in start
    self.list_server_extensions()
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_server/extension/serverextension.py", line 323, in list_server_extensions
    config_dir, ext_manager = _get_extmanager_for_context(**option)
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_server/extension/serverextension.py", line 59, in _get_extmanager_for_context
    extension_manager = ExtensionManager(
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/traitlets/config/configurable.py", line 86, in __init__
    super().__init__(**kwargs)
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/traitlets/traitlets.py", line 1364, in __init__
    self.notify_change(changes[key])
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/traitlets/traitlets.py", line 1513, in notify_change
    return self._notify_observers(change)
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/traitlets/traitlets.py", line 1560, in _notify_observers
    c(event)
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_server/extension/manager.py", line 253, in _config_manager_changed
    self._load_config_manager(change.new)
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_server/extension/manager.py", line 308, in _load_config_manager
    self.from_jpserver_extensions(jpserver_extensions)
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_server/extension/manager.py", line 313, in from_jpserver_extensions
    self.add_extension(name, enabled=enabled)
  File "/home/david/mambaforge/envs/nbclient_issue/lib/python3.10/site-packages/jupyter_server/extension/manager.py", line 325, in add_extension
    if self.serverapp.reraise_server_extension_failures:
AttributeError: 'NoneType' object has no attribute 'reraise_server_extension_failures'
@blink1073
Copy link
Contributor

The terminals server extension is only compatible with jupyter_server 2.0. We could make it fail more gracefully though.

@blink1073
Copy link
Contributor

@davidbrochart
Copy link
Contributor Author

Mmmm it's still showing the same error.

@blink1073
Copy link
Contributor

I haven't released a new version of terminals yet

@davidbrochart
Copy link
Contributor Author

I tested jupyter_server_terminals/main locally.

@blink1073
Copy link
Contributor

Ah, okay, what does it look like now from the CLI?

@davidbrochart
Copy link
Contributor Author

OK I think it's more explicit now:

Config dir: /home/david/.jupyter

Traceback (most recent call last):
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/jupyter_server/extension/manager.py", line 320, in add_extension
    extpkg = ExtensionPackage(name=extension_name, enabled=enabled)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/jupyter_server/extension/manager.py", line 166, in __init__
    super().__init__(*args, **kwargs)
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/traitlets/traitlets.py", line 1360, in __init__
    value = self._traits[key]._cross_validate(self, getattr(self, key))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/traitlets/traitlets.py", line 746, in _cross_validate
    value = obj._trait_validators[self.name](obj, proposal)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/traitlets/traitlets.py", line 1232, in __call__
    return self.func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/jupyter_server/extension/manager.py", line 175, in _validate_name
    self._module, self._metadata = get_metadata(name)
                                   ^^^^^^^^^^^^^^^^^^
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/jupyter_server/extension/utils.py", line 55, in get_metadata
    module = importlib.import_module(package_name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/david/github/davidbrochart/jupyter_server_terminals/jupyter_server_terminals/__init__.py", line 9, in <module>
    raise RuntimeError("Jupyter Server Terminals requires Jupyter Server 2.0+")
RuntimeError: Jupyter Server Terminals requires Jupyter Server 2.0+

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/david/mambaforge/envs/jupyter_server_terminals/bin/jupyter-server", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/jupyter_core/application.py", line 276, in launch_instance
    return super().launch_instance(argv=argv, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/traitlets/config/application.py", line 1041, in launch_instance
    app.start()
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/jupyter_server/serverapp.py", line 2814, in start
    self.start_app()
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/jupyter_server/serverapp.py", line 2710, in start_app
    super().start()
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/jupyter_core/application.py", line 265, in start
    self.subapp.start()
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/jupyter_server/extension/serverextension.py", line 368, in start
    super().start()
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/jupyter_core/application.py", line 265, in start
    self.subapp.start()
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/jupyter_server/extension/serverextension.py", line 342, in start
    self.list_server_extensions()
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/jupyter_server/extension/serverextension.py", line 323, in list_server_extensions
    config_dir, ext_manager = _get_extmanager_for_context(**option)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/jupyter_server/extension/serverextension.py", line 59, in _get_extmanager_for_context
    extension_manager = ExtensionManager(
                        ^^^^^^^^^^^^^^^^^
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/traitlets/config/configurable.py", line 85, in __init__
    super().__init__(**kwargs)
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/traitlets/traitlets.py", line 1367, in __init__
    self.notify_change(changes[key])
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/traitlets/traitlets.py", line 1516, in notify_change
    return self._notify_observers(change)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/traitlets/traitlets.py", line 1563, in _notify_observers
    c(event)
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/jupyter_server/extension/manager.py", line 253, in _config_manager_changed
    self._load_config_manager(change.new)
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/jupyter_server/extension/manager.py", line 308, in _load_config_manager
    self.from_jpserver_extensions(jpserver_extensions)
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/jupyter_server/extension/manager.py", line 313, in from_jpserver_extensions
    self.add_extension(name, enabled=enabled)
  File "/home/david/mambaforge/envs/jupyter_server_terminals/lib/python3.11/site-packages/jupyter_server/extension/manager.py", line 325, in add_extension
    if self.serverapp.reraise_server_extension_failures:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'reraise_server_extension_failures'

@blink1073
Copy link
Contributor

Okay, it seems like the action is to make this cleaner on the jupyter_server side.

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 a pull request may close this issue.

2 participants