Open metafeather opened 2 years ago
Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:
Somewhat related, but not so well documented is that you can declare multiple entry_points
in a setup.py to aid code reuse, e.g.
entry_points={
"jupyter_serverproxy_servers": [
# name = packagename:function_name
"research/wiki = wiki_server_proxies:setup_research_wiki_service",
"research = wiki_server_proxies:setup_research_docs_service",
"platform/wiki = wiki_server_proxies:setup_platform_wiki_service",
"platform= wiki_server_proxies:setup_platform_docs_service",
]
}
However these still get sorted globally.
Does importlib.metadata
give you the names in the order you specified them?
from importlib.metadata import entry_points
entry_points(group='jupyter_serverproxy_servers')
This is the modern replacement for pkg_resources
, so if it fixes this problem, it should be easy for JSP to switch over.
Docs: https://jupyter-server-proxy.readthedocs.io/en/latest/server-process.html#specifying-config-via-traitlets
When using
traitlets
(in ajupyter_lab_config.py
file) the declared order of the urls to proxy is used when being turned in to url handlers inside the Tornado server 1.But when using
entry_points
(in a python package)pkg_resources.iter_entry_points('jupyter_serverproxy_servers')
is used to get the list of paths to proxy and this is sorted alphabetically bysetuptools
first 2.This means that url handlers can mask each other and be unreachable, e.g. if the order declared is:
with
entry_points
the order returned will be:and so the proxy to a/b/some/path/ cannot be reached.
As the list of
entry_points
is global to all installed packages this can be hard to track down.A quick fix for this would be to reverse the results of
pkg_resources.iter_entry_points('jupyter_serverproxy_servers')
before using them, as these would be in an appropriate order for url routing.In my particular case I wanted to proxy to my wiki server under my application root so that links from the app worked as expected, and was forced to use
traitlets
, with my users copy and pasting configs rather than being able to install a module.