User_options doesn't contain form information when pre_spawn_hook function is invoked

I’m trying to create a Kubernetes based JupyterHub instance and as part of this I need a selector before the notebook server is spawned to allow users to choose a particular notebook.

I used c.KubeSpawner.options_form to assign the form and I see it displayed as I would expect. What I don’t see, however, is the selected option in the function invoked by c.KubeSpawner.pre_spawn_hook

My form is as follows:

def _stack_selector_form(spawner):
    return """
<label for="image">Select your desired stack</label>
<select name="image" size="1">
  <option value="{0}" selected>Python</option>
  <option value="{1}">R</option>
""".format(os.getenv('PYTHON_IMAGE'), os.getenv('R_IMAGE'))

c.KubeSpawner.options_form = _stack_selector_form

And my pre_spawn_hook is as follows:

def _select_image(spawner):
    print("user_options: {}".format(spawner.user_options))

c.KubeSpawner.pre_spawn_hook = _select_image

The printed output for spawner.user_options is user_options: {"profile": None}. I am expecting a property labelled image as well.

According to consideRatio this ordering should be fine so I’m at a loss as to what the issue is.

Providing a pre_spawn_hook function enables to take further actions based on the choice(s) made in the options_form .

Am I missing something obivious?

Solved thanks to Jdiavec_C.

I needed to handle the form data in c.KubeSpawner.options_from_form.