jupyter / kernel_gateway_demos

Demos associated with the kernel gateway incubator project
BSD 3-Clause "New" or "Revised" License
150 stars 76 forks source link

Pass "KERNEL_*" env variables to kernels endpoint #41

Closed ckadner closed 7 years ago

ckadner commented 7 years ago

To enable this feature in Jupyter Kernel Gateway:

Pass environment metadata to kernels on POST /api/kernels #128

ckadner commented 7 years ago

@chuyqa -- there is a similar code change in your fork, this PR would be a more generic approach

ckadner commented 7 years ago

@parente - this PR is an extension to Pass environment metadata to kernels on POST /api/kernels #128 in Jupyter Kernel Gateway

Could you give it a look? Thanks in advance!

parente commented 7 years ago

@ckadner I don't know how I missed this PR, but I did. Wow. Sorry for the long delay!

ckadner commented 7 years ago

@parente -- Thanks for merging!

ricedavida commented 7 years ago

So, I am trying to use this notebook image in a JupyterHub environment. What I want to do is pass the $JPY_USER environment variable to KernelGateway. Is there a way I can do that? I have been trying to figure out how to put $JPY_USER into a $KERNEL_JPY_USER env variable at start time, but JupyterHub seems to have that locked down, so I can't figure out how to do that. Any thoughts?

parente commented 7 years ago

@riceda195 JPY_USER would need to be whitelisted with the kernel gateway as an environment variable that can be set via:

--JupyterWebsocketPersonality.env_whitelist=<List>
    Default: []
    Environment variables allowed to be set when a client requests a new kernel

IIRC, this extension would also need to change to pass that env var in the POST request.

Doc for the KG option is here http://jupyter-kernel-gateway.readthedocs.io/en/latest/config-options.html or here jupyter kernelgateway --help-all.

ricedavida commented 7 years ago

@parente Thank you!

ricedavida commented 7 years ago

@parente this Pull Request adds the feature we discussed above to nb2kg https://github.com/jupyter/kernel_gateway_demos/pull/45