Is it possible to enable xcomarg more external processing method? #22915
-
Hi, I want to use taskAPI for conveniently parameter passing. I imaged that I can do in an intuitive style. param = params.resolve(load_func= lambda x: x[1]) #params is a xcomarg while param might be a derived xcomarg? otherwise, I have to: @task
def get_detailed_value(params, keys):
return params[keys]
param = get_detailed_value(params, 1) from airflow.models import DAG
from airflow.operators.python import PythonOperator, task
from airflow.utils.dates import days_ago
from airflow.utils.edgemodifier import Label
from airflow import DAG
default_args={}
@task
def gen_params():
return {1:'a',2:'b'}
@task
def print_value(t_value):
print("value: ",t_value)
with DAG('test',
start_date=days_ago(2),
max_active_runs=3,
schedule_interval=None,
default_args=default_args,
catchup=False
) as dag:
params = gen_params()
param = params[1]
test = print_value(param) Regards! : ) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It does not work this way. You cannot pas parameters this way to decorated function. you can pass other tasks and then they will produce outputs that will be passed to the task see https://airflow.apache.org/docs/apache-airflow/stable/tutorial_taskflow_api.html it explains it on examples. |
Beta Was this translation helpful? Give feedback.
It does not work this way. You cannot pas parameters this way to decorated function. you can pass other tasks and then they will produce outputs that will be passed to the task see https://airflow.apache.org/docs/apache-airflow/stable/tutorial_taskflow_api.html it explains it on examples.