气流Python操作员传递参数

编程入门 行业动态 更新时间:2024-10-23 06:19:28
本文介绍了气流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操作员传递参数

本文发布于:2023-11-23 20:56:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622842.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:操作员   气流   参数   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!