Can you create a Variable directly in an Airflow Dag

Viewed 181

As I understand it, a common Airflow workflow is to create a Variable in the UI and access it in a dag as needed. If for some reason you need to update this variable, you can simply Variable.set("foo", bar).

Is there any way to create a fresh variable in a dag?

Psuedo:

def create_new_client_config(client_name):
    data = get_client_details(client_name)
    client_config = Variable.create(f"{client_name}", data)
    client_config.save()

Thanks!

1 Answers

Variable.set("my_key", "my_value") is used for variables creation as well (not only for update)

Related