https://dagster.io/ logo
#ask-community
Title
# ask-community
a

Abdul Haris Djafar

08/23/2022, 7:46 AM
Can we update environment variable through dagster UI?
dagster bot responded by community 1
s

Stephen Bailey

08/23/2022, 12:45 PM
Not unless you are setting environment variables through the config schema. For example
Copy code
import os
import json
from dagster import op

@op(config_schema={"env_vars": dict})
def print_env_vars(context):
    # sets environment variables from the config provided
    for k, v in context.op_config["env_vars"].items():
         os.environ[k] = v

    # prints all environment variables
    <http://context.log.info|context.log.info>(json.dumps(os.environ))
a

Abdul Haris Djafar

08/23/2022, 1:06 PM
So, we just can update through the code right? @Stephen Bailey
s

Stephen Bailey

08/23/2022, 1:13 PM
in that scenario, you could use the launchpad / ui to update the configuration for each run -- a la
Copy code
ops:
  print_env_vars:
    config:
      env_vars:
        foo: bar
or
Copy code
ops:
  print_env_vars:
    config:
      env_vars:
        baz: boom
and that would all be in the launchpad of the UI
a

Abdul Haris Djafar

08/23/2022, 1:15 PM
I see. I will try it. Thanks so much for your help @Stephen Bailey
🌈 1