3 回答
TA贡献1966条经验 获得超4个赞
参数名称给出了它。您正在传递调用的结果而不是可调用的。
python_callable=check_poke(129600,600)
第二个错误指出 callable 是用 25 个参数调用的。所以是lambda:
行不通的。以下方法可行,但忽略 25 个参数确实值得怀疑。
python_callable=lambda *args, **kwargs: check_poke(129600,600)
TA贡献1821条经验 获得超6个赞
代码需要一个可调用的,而不是结果(正如已经指出的那样)。
您可以使用functools.Partial来填写参数:
from functools import partial
def check_poke(threshold,sleep_interval):
flag=snowflake_poke(1000,10).poke()
return flag
func = partial(check_poke, 129600, 600)
dependency = PythonOperator(
task_id='poke_check',
provide_context=True,
python_callable=func,
dag=dag)
TA贡献1893条经验 获得超10个赞
同意@Dan D.的问题;但令人困惑的是为什么他的解决方案不起作用(它在python shell 中肯定有效)
看看这是否会给您带来任何运气(它只是@Dan D.解决方案的详细变体)
from typing import Callable
# your original check_poke function
def check_poke(arg_1: int, arg_2: int) -> bool:
# do something
# somehow returns a bool
return arg_1 < arg_2
# a function that returns a callable, that in turn invokes check_poke
# with the supplied params
def check_poke_wrapper_creator(arg_1: int, arg_2: int) -> Callable[[], bool]:
def check_poke_wrapper() -> bool:
return check_poke(arg_1=arg_1, arg_2=arg_2)
return check_poke_wrapper
..
# usage
python_callable=check_poke_wrapper_creator(129600, 600)
添加回答
举报