Hi,
I am attempting to get JupyterHub to launch with a specific workspace when students sign up and launch their servers (TLJH on a University cluster using FirstUseAuthenticator).
Its simple enough getting the workspace JSON files into the user/workspace folders and setting the default_url
to point to them, but I cannot figure out how to have JupyterLab actually import the workspace files prior to the server starting. Adding the import to .profile
/.bashrc
only seems to work when a student launches a terminal - so it does not influence the landing page - and I have attempted (unsuccessfully) to use pre/post spawner hooks, but am not sure if this is even the right approach.
Is there a simple way to do this that I am missing?
1 Like
Some of the links on previous threads about workspaces might help:
2 Likes
Thanks for the links!
I am not using Binder so I do not know if there is something equivalent to postBuild
that runs when a new server is spawned by JupyterHub (or when a new user is created). I tried modifying the spawner hooks specifically and adding the jupyter lab workspaces import
command there, but these did not seem to run in the user context that I could see.
I have managed to figure out a solution based on a previous question about launching user shell scripts on environment startup.
I created a custom script to call jupyterhub-singleuser
that also imports the necessary workspace JSON files:
/usr/local/bin/custom_startup.sh
#!/bin/bash
jupyter lab workspaces import {workspace.json file}
exec /opt/tljh/user/bin/jupyterhub-singleuser "$@"
And added a c.Spawner.cmd
configuration option so that it uses this script to launch the server by adding the line…
c.Spawner.cmd = "custom_startup.sh"
…to /opt/tljh/hub/lib/python3.6/site-packages/tljh/jupyterhub_config.py
.
The workspace file(s) are then imported before the server is launched and are valid targets for a default_url
config setting that tries to load them as the default landing page.
2 Likes