i am writing a airflow dag.
In that code, I want to call function ,and I want to use variables in the function names.
But, when I am using the function names and concatenating the varibales, its converting it to string, and the string cannot be called.
Below is my code:
from datetime import date, datetime, timedelta
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from datetime import timedelta
def task_1():
print("task1")
def task_2():
print("task2")
default_args = {
'owner': 'airflow',
'start_date': datetime(2019, 11, 12),
'retries': 2,
'retry_delay': timedelta(minutes=5),
}
tasks=[]
with DAG('NF-table-load-01',schedule_interval=None,catchup=False,max_active_runs=1,default_args=default_args) as dag:
for i in range(2):
task=PythonOperator(task_id=f'load-{i}', python_callable=f'task_{i}')
tasks.append(task)
for i in range(len(tasks) - 1):
tasks[i] >> tasks[i+1]
the python_callable argument should be a function, but its converting to string.
Does anyone know, how to achieve this, without converting to string?
Thanks.
Above all things I tried