-
Notifications
You must be signed in to change notification settings - Fork 148
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
Url handler order different dependent on whether config is by traitlets vs entry_points #326
Comments
Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗 |
Somewhat related, but not so well documented is that you can declare multiple 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 from importlib.metadata import entry_points
entry_points(group='jupyter_serverproxy_servers') This is the modern replacement for |
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.The text was updated successfully, but these errors were encountered: