Different default profiles per user

We are trying to set up a different default profiles per user. The use case is, people often use the Jupyterhub with remote connection to the running kernel and to my understanding Jupyterhub always launches the default profile. The users of course can go to the web UI and launch it manually, but what sometimes happens is they forget, their instance gets culled and now they launch the default profile.
I was looking into JH API, which could work I guess JupyterHub REST API β€” JupyterHub documentation , but I was mostly interested if there is possibility to override the profile list per user basis.
Thank you

What profiles are you referring to? What spawner are you using? Could you share more details on your deployment?

I am referring to Configuration Reference β€” Zero to JupyterHub with Kubernetes documentation. We are using KubeSpawner. The whole deployment is done using Z2JH Zero to JupyterHub with Kubernetes β€” Zero to JupyterHub with Kubernetes documentation helm chart.
I am wondering if there is a way to somehow have the default option in the profile list linked above dependent on the current user.

I dont have experience with Kubernetes deployment so I am not quite sure I understand your requirement. But if you want to change KubeSpawner.profile_list per user, you may be able to do it with pre_spawn_hook. As in the example in the docs, you use the username to set spawner.profile_list attribute? I dont know the internals of KubeSpawner so take it with a grain of salt.

This is something tottally achievable! In my case, I am applying somthing siimilar and different profiles are available depending on specific attriubtes of users.

What you will need is to create a script that does this and ingest it in your deployment via extraConfig or exrtaFiles.

If you choose extraConfig you would need to type the code inside Helm .yaml which can be very frustrating!

If you use exrtaFiles you would need to add the below in your hub.exrtaFiles:

      mountPath: /usr/local/etc/jupyterhub/jupyterhub_config.d/profileList.py

Personally I prefer extraFiles method.

Let’s go to the script!

The tricky part would be to figure out how to get the users data coming from log in. Depending on the authentication class you are using this may be different (in my case this is Auth0).

Once you find it, you would need to play around with some β€œif” statements and Kubespawner.profile_list.

Eventually the needed code would be something like this:

async def custom_options_form(spawner):

	auth_state = await spawner.user.get_auth_state()
	user_details = auth_state["auth0_user"]

	if user_details["name"] == 'foo':
		spawner.profile_list = [
				'display_name': 'Data science blah blah blah',
				'description': 'Datascience Environment with Sample Notebooks',
				'server_name': 'datasciencel_notebook',
				'kubespawner_override': {
					'image': 'jupyter/datascience-notebook:ubuntu-22.04',
					'mem_guarantee': '4G',
					'mem_limit': '4G'
				'display_name': 'tensorflow blah blah',
				'description': 'tensorflow',
				'server_name': 'tensorflow',
				'kubespawner_override': {
					'image': 'jupyter/tensorflow-notebook:python-3.11',
					'mem_guarantee': '16G',
					'mem_limit': '16G'
	if user_details['name'] == 'bar':
		spawner.profile_list = [
				'display_name': 'R notebook blah blah',
				'description': 'r',
				'server_name': 'r_notebook',
				'kubespawner_override': {
					'image': 'jupyter/r-notebook:r-4.3.1',
					'cpu_guarantee': 1,
					'cpu_limit': 2
				'display_name': 'yeah! science',
				'description': 'let's kook',
				'server_name': 'crystal',
				'kubespawner_override': {
					'image': 'jupyter/scipy-notebook:2023-08-19',
					'cpu_guarantee': 2,
					'cpu_limit': 4
	return spawner._options_form_default()

c.KubeSpawner.options_form = custom_options_form