简体   繁体   English

AirFlow Python 运算符错误:得到一个意外的关键字参数 'conf'

[英]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=TruePythonOperator将导出上下文以供可调用对象使用。 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.

相关问题 错误:sink() 得到了一个意外的关键字参数 'parent' - Error: sink() got an unexpected keyword argument ‘parent’ TypeError: request() 得到了一个意外的关键字参数 'json' - PYTHON,AWS - TypeError: request() got an unexpected keyword argument 'json' - PYTHON,AWS Ansible - 得到一个意外的关键字参数 - check_invalid_arguments - Ansible - got an unexpected keyword argument - check_invalid_arguments client.get_bucket() 返回错误:api_request() 得到了一个意外的关键字参数“extra_api_info” - client.get_bucket() returns error: api_request() got an unexpected keyword argument 'extra_api_info' Airflow 无效 arguments 和关键字参数 - Airflow Invalis arguments and keyword argument DBT - 语法错误:应为“(”或关键字 SELECT 或关键字 WITH 但关键字 CREATE 位于 - DBT - Syntax error: Expected "(" or keyword SELECT or keyword WITH but got keyword CREATE at 语法错误:应为“)”但在 [2:93] 处获得了关键字 NEW - Syntax error: Expected ")" but got keyword NEW at [2:93] 我有语法错误:意外的关键字 SET - I have Syntax error: Unexpected keyword SET Airflow 运算符 BigQueryTablePartitionExistenceSensor 问题 - Airflow Operator BigQueryTablePartitionExistenceSensor Question 在使用 pandas 在 python 中执行 SQL 查询时,我遇到了错误:TypeError: __init__() got multiple values for argument 'schema' - While performing SQL query in python using pandas i am facing the error : TypeError: __init__() got multiple values for argument 'schema'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM