I am attempting to follow the Airflow documentation to use variables in a DAG.
The variables are set in the Airflow UI and I created a simple DAG use the variables. Loading the variables as shown in the documentation results in the following error:
[2021-02-18 16:32:15,350] {variable.py:64} ERROR - Can't decrypt _val for key=foo, invalid token or value
[2021-02-18 16:32:15,364] {taskinstance.py:1396} ERROR - 'Variable foo does not exist'
Below are the set variables and the code I am using. Any help would be greatly appreciated.
"""
### Load Variable
"""
import airflow.utils.dates
from airflow import DAG
from airflow.operators.python import PythonOperator
from airflow.models import Variable
dag = DAG(
dag_id="load_var",
tags=['example'],
description='load variables',
start_date=airflow.utils.dates.days_ago(1),
schedule_interval="@once",
max_active_runs=1,
)
def _get_data():
foo = Variable.get("foo")
print(foo)
foo_json = Variable.get("foo_baz", deserialize_json=True)
print(foo_json)
get_data = PythonOperator(
task_id="get_data",
python_callable=_get_data,
dag=dag,
)
get_data