[英]AirFlow Python operator error: got an unexpected keyword argument 'conf'
我正在尝试通过 AirFlow 触发 dbt cloud,但无法找到以下错误的答案
错误 - run_job() 得到了一个意外的关键字参数 'conf'
我正在使用来自https://github.com/sungchun12/airflow-dbt-cloud的插件代码
"""Main handler method to run the dbt Cloud job and track the job run status"""
job_run_id = self._trigger_job()
print(f"job_run_id = {job_run_id}")
visit_url = f"https://cloud.getdbt.com/#/accounts/{self.account_id}/projects/{self.project_id}/runs/{job_run_id}/"
print(f"Check the dbt Cloud job status! Visit URL:{visit_url}")
while True:
time.sleep(1) # make an api call every 1 second
job_run_status = self._get_job_run_status(job_run_id)
print(f"job_run_status = {job_run_status}")
if job_run_status == dbt_job_run_status.SUCCESS:
print(f"Success! Visit URL: {visit_url}")
break
elif (
job_run_status == dbt_job_run_status.ERROR
or job_run_status == dbt_job_run_status.CANCELLED
):
raise Exception(f"Failure! Visit URL: {visit_url}")
我通过以下代码调用 function
run_dbt_cloud_job = PythonOperator(
task_id="run_dbt_cloud_job",
python_callable=dbt_cloud_job_runner_config.run_job,
provide_context=True,
)
并得到错误
run_job() 得到了一个意外的关键字参数 'conf'
我不确定为什么它不起作用。
如果我更改 provide context = False 然后我得到以下错误
错误 - 'NoneType' object 不可订阅
在这种情况下,您需要在参数上传递**kwargs
。
你可以看到这个例子:
def my_mult_function(number, **kwargs):
return number*number
这是因为如果您设置provide_context=True
, PythonOperator
将导出上下文以供可调用对象使用。 通用变量将捕获所有关键字 arguments。
您可以看到PythonOperator class 。
如果您的代码返回this error “'NoneType' object is not subscriptable”
,那是因为您的查询中没有结果。 一个解决方案是将查询更改为使用 scalar()。
你可以看到这个例子。
triggered_by = (
session.query(Log.owner)
.filter(Log.dag_id == "killer_dag")
.limit(1)
.scalar()
)
您可以在此链接中查看更多文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.