uktrade / fargatespawner

Spawns JupyterHub single user servers in Docker containers running in AWS Fargate
MIT License
47 stars 21 forks source link

Send environment from JupyterHub HTTP API #10

Open YOxan opened 4 years ago

YOxan commented 4 years ago

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 commented 4 years ago

Hi @YOxan,

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

Can I ask, what's the use case?

YOxan commented 4 years ago

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 commented 4 years ago

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