气流Python操作员传递参数 [英] Airflow Python operator passing parameters
本文介绍了气流Python操作员传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在气流DAG中编写Python运算符,并将某些参数传递给Python可调用对象。
I'm trying to write a Python operator in an airflow DAG and pass certain parameters to the Python callable.
我的代码如下。
def my_sleeping_function(threshold):
print(threshold)
fmfdependency = PythonOperator(
task_id='poke_check',
python_callable=my_sleeping_function,
provide_context=True,
op_kwargs={'threshold': 100},
dag=dag)
end = BatchEndOperator(
queue=QUEUE,
dag=dag)
start.set_downstream(fmfdependency)
fmfdependency.set_downstream(end)
但是我一直收到以下错误。
But I keep getting the below error.
TypeError:my_sleeping_function()得到了意外的关键字参数'dag_run'
TypeError: my_sleeping_function() got an unexpected keyword argument 'dag_run'
无法弄清原因。
推荐答案
在操作符参数列表后添加** kwargs您的阈值参数
Add **kwargs to your operator parameters list after your threshold param
这篇关于气流Python操作员传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文