# Different default profiles per user

**URL:** <https://discourse.jupyter.org/t/different-default-profiles-per-user/21927>\
**Category:** Zero to JupyterHub on Kubernetes\
**Tags:** jupyterhub, how-to, help-wanted\
**Created:** [October 17, 2023, 6:50am UTC](https://discourse.jupyter.org/t/different-default-profiles-per-user/21927 "2023-10-17T06:50:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mg4515](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mg4515/32/10476_2.png) [@mg4515](https://discourse.jupyter.org/u/mg4515)\
**Post date:** [October 17, 2023, 6:50am UTC](https://discourse.jupyter.org/t/different-default-profiles-per-user/21927/1 "2023-10-17T06:50:29Z")

</div>

Hello,  
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](https://jupyterhub.readthedocs.io/en/stable/reference/rest-api.html#/default/post_users __name__ server) , but I was mostly interested if there is possibility to override the profile list per user basis.  
Thank you

---

<div class="post-metadata">

**Author:** ![mahendrapaipuri](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mahendrapaipuri/32/6800_2.png) [@mahendrapaipuri](https://discourse.jupyter.org/u/mahendrapaipuri)\
**Post date:** [October 17, 2023, 9:04am UTC](https://discourse.jupyter.org/t/different-default-profiles-per-user/21927/2 "2023-10-17T09:04:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mg4515](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mg4515/32/10476_2.png) [@mg4515](https://discourse.jupyter.org/u/mg4515)\
**Post date:** [October 18, 2023, 1:51pm UTC](https://discourse.jupyter.org/t/different-default-profiles-per-user/21927/3 "2023-10-18T13:51:53Z")

</div>

Hi,  
I am referring to [Configuration Reference — Zero to JupyterHub with Kubernetes documentation](https://z2jh.jupyter.org/en/stable/resources/reference.html#singleuser-profilelist). We are using KubeSpawner. The whole deployment is done using Z2JH [Zero to JupyterHub with Kubernetes — Zero to JupyterHub with Kubernetes documentation](https://z2jh.jupyter.org/en/stable/) 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.

---

<div class="post-metadata">

**Author:** ![mahendrapaipuri](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mahendrapaipuri/32/6800_2.png) [@mahendrapaipuri](https://discourse.jupyter.org/u/mahendrapaipuri)\
**Post date:** [October 18, 2023, 5:53pm UTC](https://discourse.jupyter.org/t/different-default-profiles-per-user/21927/4 "2023-10-18T17:53:38Z")

</div>

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`](https://jupyterhub.readthedocs.io/en/stable/reference/api/spawner.html#jupyterhub.spawner.Spawner.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.

---

<div class="post-metadata">

**Author:** ![agelosnm](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/agelosnm/32/10273_2.png) [@agelosnm](https://discourse.jupyter.org/u/agelosnm)\
**Post date:** [October 27, 2023, 7:48pm UTC](https://discourse.jupyter.org/t/different-default-profiles-per-user/21927/5 "2023-10-27T19:48:58Z")

</div>

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](https://z2jh.jupyter.org/en/latest/administrator/advanced.html#hub-extraconfig) or [exrtaFiles](https://z2jh.jupyter.org/en/latest/resources/reference.html#hub-extrafiles).

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`:

```auto
  extraFiles:
    profileListConfig:
      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

```
