Is it possible to set env variable from options_form?

i am using fargatespawner and have an options form for setting various options, i would like to take one of these and set as an environment variable but cannot get my head around how to do it. is it possible to use a value from the form to set a spawner environment variable?

fargatespawner creates a task definition to override the system one and sets the environment as follows, i cannot add to the environment section as it gives a syntax error, i was hoping to do something like
os.environ[‘VAULT_KEY’] = c.Spawner.options_from_form. but stuck on syntax or if this is even possible

c.FargateSpawner.get_run_task_args= lambda spawner: {
‘cluster’: ‘jupyter’,
‘taskDefinition’: spawner.user_options[‘resources’][0] +’-notebook-prod:’ + spawner.user_options[‘notebook’][0],
‘overrides,’: {
‘containerOverrides’: [{
‘environment’: [
‘name’: name,
‘value’: value,
} for name, value in spawner.get_env().items()

It should be possible. There’s an example here which suggests you should override get_env() to include the environment variables from your options form:

worked like a charm thanks for pointing it out

1 Like