[英]AirFlow Python operator error: got an unexpected keyword argument 'conf'
I am trying to trigger dbt cloud via AirFlow and unable to find an answer to the error below我正在尝试通过 AirFlow 触发 dbt cloud,但无法找到以下错误的答案
ERROR - run_job() got an unexpected keyword argument 'conf'
错误 - run_job() 得到了一个意外的关键字参数 'conf'
I am using the plugin code from https://github.com/sungchun12/airflow-dbt-cloud我正在使用来自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}")
I am calling the function via the following code我通过以下代码调用 function
run_dbt_cloud_job = PythonOperator(
task_id="run_dbt_cloud_job",
python_callable=dbt_cloud_job_runner_config.run_job,
provide_context=True,
)
And get the error并得到错误
run_job() got an unexpected keyword argument 'conf'
run_job() 得到了一个意外的关键字参数 'conf'
I'm not sure why it is not working.我不确定为什么它不起作用。
If I change the provide context = False then I get following error如果我更改 provide context = False 然后我得到以下错误
ERROR - 'NoneType' object is not subscriptable
错误 - 'NoneType' object 不可订阅
In this case, you need to pass **kwargs
on the parameters.在这种情况下,您需要在参数上传递
**kwargs
。
You can see this example:你可以看到这个例子:
def my_mult_function(number, **kwargs):
return number*number
It is because if you set provide_context=True
, the PythonOperator
will export context to make available for callables to use.这是因为如果您设置
provide_context=True
, PythonOperator
将导出上下文以供可调用对象使用。 A generic variable will catch all the keywords arguments.通用变量将捕获所有关键字 arguments。
You can see the PythonOperator class .您可以看到PythonOperator class 。
If your code returns this error “'NoneType' object is not subscriptable”
, it is because there are no results in your query.如果您的代码返回
this error “'NoneType' object is not subscriptable”
,那是因为您的查询中没有结果。 A solution to this is to change the query to use scalar().一个解决方案是将查询更改为使用 scalar()。
You can see this example.你可以看到这个例子。
triggered_by = (
session.query(Log.owner)
.filter(Log.dag_id == "killer_dag")
.limit(1)
.scalar()
)
You can see more documentation in this link .您可以在此链接中查看更多文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.