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

Send environment from JupyterHub HTTP API #10

Open
YOxan opened this issue Feb 18, 2020 · 3 comments
Open

Send environment from JupyterHub HTTP API #10

YOxan opened this issue Feb 18, 2020 · 3 comments

Comments

@YOxan
Copy link

YOxan commented Feb 18, 2020

Hello! Just a quick question: is there any way to send variables from JupyterHub API request like POST /users/{name}/servers/{server_name} to the container. So for example if I set some kind of key in JSON body like { "key1":"value1"} would it be possible to use this variable inside the container at notebool?

@michalc
Copy link
Member

michalc commented Apr 13, 2020

Hi @YOxan,

The short answer to this is no, for various reasons:

  • AFAIK, environment variables can only be populated at a process start, and there isn't a way to change/add to them dynamically into a running kernel.
  • Potentially variables could be populated in new kernels, but I also don't think there is any existing way to pass any environment variables that weren't available on the JupyterLab instance start.

Can I ask, what's the use case?

@YOxan
Copy link
Author

YOxan commented Apr 13, 2020

Hey @michalc. Basically, the case is to put some identifier to container to retrieve the data from the db. I thought about using some pre-start scripts with using this id to query the DB and fill the dataframe. Thanks!

@michalc
Copy link
Member

michalc commented Jun 29, 2020

You can override the get_env() from the Spawner that runs in the hub just before the task is created, and then notebooks would I think have access to the environment variables. Not sure if you wanted something a bit more dynamic/done after the single user server startup...

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

No branches or pull requests

2 participants