-
-
Notifications
You must be signed in to change notification settings - Fork 101
Description
Problem
When running in JupyterHub, we would like to inject some fields to page config that are based on the incoming request (e.g. based on the authenticated user, which can vary from one request to the next). However, the way page config is populated in LabHandler.get makes it hard to find a hook to add/modify fields.
Proposed Solution
Add a hook for 'extra page config' that can be a callable, so that page config can be extended. Possibly this could be discovered via jupyter-server extensions, so that each extension could add its own page config? For us, at least some mechanism would need to to take the current request into account.
What would suffice for us:
page_config = ...
# apply extra page config hook
if self.settings.get("extra_page_config", None):
page_config = self.settings["extra_page_config"](self, copy.copy(page_config))
... # continue as beforebut just one hook might not suffice if multiple extensions also want to do this. I'm not sure they will, though, because extensions generally have their own place to put settings. JupyterHub does need to modify the root page config itself.
Additional context
JupyterHub's server-extension code where we would call this hook is here. We generally inject some things into Jupyter handler base classes. I'd like to do this via existing extension APIs as much as possible. Ultimately, I'd like to get to the point where jupyterhub-singleuser is implemented as a Jupyter Server Extension, but the necessary extension points don't exist yet.