Specific name attribute for selected user profile instead of display_name?

I use the pre_spawn_hook capability to get the selected user profile in the KubeSpawner.
that’s the function call I do

spawner.user_options.get("profile", "")

I only see the capability of getting a somewhat modified version of the display_name of the profile, and not any other attributes that could be dedicated only to programming and not display, something that would be more predictable.

For instance if the profile display_name is something like “This is the super profile / production”
it ends being something like “this-is-the-super-profile-production” I believe. Which is nice but not predictable and IMHO how it’s called on the UI shouldn’t be a concern for the rest of the code.

Did I miss other profile attributes that could be used here?

You can set the slug profile option to set rather than rely on the conversion of the display name.

From the code

        - `slug`: the machine readable slug to identify the profile
          (missing slugs are generated from display_name)
1 Like

oh great. exactly what I needed.

probably something that would be useful to have in the values.yaml ?

This can be done by adding slug to the profiles if you set those up via the profileList entries as these are passed through to kubespawner

Modified example from Configuration Reference — Zero to JupyterHub with Kubernetes documentation

    - display_name: "Default: Shared, 8 CPU cores"
      description: "Your code will run on a shared machine with CPU only."
      slug: "default"
      default: True
    - display_name: "Personal, 4 CPU cores & 26GB RAM, 1 NVIDIA Tesla K80 GPU"
      slug: "gpu"
      description: "Your code will run a personal machine with a GPU."
          nvidia.com/gpu: "1"

thanks for the example. That’s perfect. That’s what I’ll do indeed.

I meant that it should probably be useful if it’s in the doc and the global values.yaml file that contains all the options for the chart.
I’ll propose a simple PR.

responding to myself that it is in the KubeSpawner documentation on this page

profile_list c.KubeSpawner.profile_list = Union()
List of profiles to offer for selection by the user.

Signature is: List(Dict()), where each item is a dictionary that has two keys:

display_name: the human readable display name (should be HTML safe)

slug: the machine readable slug to identify the profile (missing slugs are generated from display_name)

and one example is here