I’ve been running into traceback whilst trying to develop a Jupyter Server extension within a Python namespace package.
Here’s a minimal reproducible example based on the example in the docs:
And here is some example traceback from attempting to run it:
$ t_ns_jps_ext
[I 2021-05-19 12:40:39.457 ServerApp] t_namespace | extension was successfully linked.
Traceback (most recent call last):
File ".../t_ns_jps_ext", line 33, in <module>
sys.exit(load_entry_point('jps-namespace-extension', 'console_scripts', 't_ns_jps_ext')())
File ".../python3.9/site-packages/jupyter_server/extension/application.py", line 518, in launch_instance
serverapp = cls.initialize_server(argv=args)
File ".../python3.9/site-packages/jupyter_server/extension/application.py", line 488, in initialize_server
serverapp.initialize(
File ".../python3.9/site-packages/traitlets/config/application.py", line 87, in inner
return method(app, *args, **kwargs)
File ".../python3.9/site-packages/jupyter_server/serverapp.py", line 1855, in initialize
point = self.extension_manager.extension_points[starter_extension]
KeyError: 'test_namespace_extension'
Note the log line t_namespace | extension was successfully linked.
which shows the extension being loaded with the name of the namespace package rather than the extension name.
If I patch this code to use the namespace name for the extension name I hit more traceback as Jupyter Server goes looking for load_jupyter_server_extension
in the namespace package rather than the namespace.
$ t_ns_jps_ext
[I 2021-05-19 12:48:25.936 ServerApp] t_namespace | extension was successfully linked.
> .../python3.9/site-packages/jupyter_server/serverapp.py(1856)initialize()
-> point = self.extension_manager.extension_points[starter_extension]
(Pdb) starter_extension
'test_namespace_extension'
(Pdb) starter_extension = 't_namespace'
(Pdb) c
[W 2021-05-19 12:48:37.635 ServerApp] t_namespace | extension failed loading with message: module 't_namespace' has no attribute 'load_jupyter_server_extension'
I’m not sure if this is a mistake on my part, a bug or a design limitation?
Any ideas?