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

Inject page config on a per-request basis #219

Closed
minrk opened this issue Nov 18, 2021 · 1 comment · Fixed by #220
Closed

Inject page config on a per-request basis #219

minrk opened this issue Nov 18, 2021 · 1 comment · Fixed by #220

Comments

@minrk
Copy link
Contributor

minrk commented Nov 18, 2021

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 before

but 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.

@minrk minrk transferred this issue from jupyterlab/jupyterlab Nov 18, 2021
@minrk
Copy link
Contributor Author

minrk commented Nov 18, 2021

I see (lab) extensions load settings from disk already, so it really is only the "taking the request into account" bit that JupyterHub needs that seems to be missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant