-
Notifications
You must be signed in to change notification settings - Fork 504
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
Passing request URI to kernel env #414
Passing request URI to kernel env #414
Conversation
Now adding |
https://tools.ietf.org/html/rfc3875 may be useful. But, I'm not sure everybody is on board with this idea. Maybe it should be an opt-in? |
For other variables? Having access to the request and query params would already be very useful to dashboard authors. |
Having |
Added |
does "voila / 0.1.13" make sense ? |
Having a lot of fun with this feature. It totally let us build connected/linked dashboards. Any thoughts about merging it in/next steps? @maartenbreddels @jtpio |
I think it's a good idea to discuss this at the next meeting: https://voila-dashboards.github.io/ |
Sounds good to me! I won't be able to join this Monday, but will join for the next meeting. |
Thanks @derek-pyne for working on this. Having access to the query parameters is indeed very useful, making it possible to recreate dashboards with a particular state. Especially in multi-page setups where one dashboard has a link to another dashboard and passes information via query parameters to initialize the state of the second dashboard. |
I think if we do this, we should coordinate for voila/lab/notebook/server. It makes kernels frontend aware. |
Sure, but this is very specific to the voila handler. Kernels wouldn't be exposed to it in other environments.
JupyterHub exposes a few environment variables yes. For example on mybinder.org: |
Note that if This only exist in the future though, so I don't think that should block this, but more acts as a note to the future. |
@vidartf - thanks for the cc. Yes. In fact, I'd like to support a well-known entry of A couple things to keep in mind. Currently, (in EG), any env prefixed with |
You can do this via the hook too #218 (comment) |
Hey all, sorry for leaving this PR hanging for the team. @jtpio @maartenbreddels Any suggested next steps? Doesn't necessarily need to be merged, just want to help getting to a conclusion :) @timkpaine Prelaunch hooks looks like a REALLY nice more general solution to this. If we are moving forward on prelaunch hooks, I'd suggest killing this PR and using that functionality. |
1e3ddd0
to
6dee2ed
Compare
Co-authored-by: Maarten Breddels <[email protected]>
6dee2ed
to
843d7b2
Compare
I've rebased this and removed |
self.kernel_env['SERVER_PROTOCOL'] = str(self.request.version) | ||
host, port = split_host_and_port(self.request.host.lower()) | ||
self.kernel_env['SERVER_PORT'] = str(port) if port else '' | ||
self.kernel_env['SERVER_NAME'] = host |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these environment variables be namespaced (prefixed with VOILA
for example).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it follows https://tools.ietf.org/html/rfc3875
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok then...
🎉 |
Thanks all! We've been using this branch/feature for awhile now. Happy to see this feature get a path into master :) Changes look good. |
Thanks for your patience, and for starting this, I think it's gonna be a super useful feature. Note that we don't have REQUEST_URI anymore, but SCRIPT_NAME + QUERY_STRING should be the same |
Hi all! let's assume I render my notebook in my jupyterhub with: how can I access the variable a inside the notebook? i.e. where do I access SCRIPT_NAME and QUERY_STRING? (Note: I don't find them in os.environ, I already tried) |
See https://github.com/voila-dashboards/voila/blob/master/notebooks/query-strings.ipynb, but this requires voila 0.2+ |
Thanks Maarten! It works, I was actually using an old version of Voilà.. thanks and congrats for all you’re doing! -Marco |
Issue: #410
POC of ability to pass request uri into kernel. This would enable all sorts of dynamic/linking dashboard setups.
Added a sample notebook that prints the env.
Concerns:
When the kernel manager starts a new kernel, it either uses the existing environment or an environment passed in as an argument. It does not merge these environments. This is a concern if there was anything in the previous
os.environ
that we needed.https://github.com/jupyter/jupyter_client/blob/dc213de1b5cc7b5c28485ae799fecfef77589a85/jupyter_client/manager.py#L239