-1

I have a python operator.

PythonOperator(
            task_id="getData",
            python_callable=getData,
            op_kwargs={
                "params": {
                    "days": 1,
                    "limit": 10
                }
            },
            provide_context=True,
        )

I have set the provide_context to True as i need data to be sent to other task. I have the function where i want to pass just the params not kwargs.

  def getData(params):
        return params

I am getting an error upon running as:

TypeError: getData() got an unexpected keyword argument 'conf'

When i pass **kwargs and extract the params from it, it works fine but i do not want to pass kwargs just the params, what can be done for that?

Avenger
  • 793
  • 11
  • 31
  • Read the section titled [How to pass parameters to PythonOperator in Airflow](https://marclamberti.com/blog/airflow-pythonoperator/) – y2k-shubham Sep 02 '20 at 18:05

1 Answers1

0

Referring to official documentation at here:

When you set the provide_context argument to True, Airflow passes in an additional set of keyword arguments

If you just want to pass the params to function, turn the provide_context False. provide_context is for Dag related meta information. This can be used in xcomm and to access configs.

khari-sing
  • 650
  • 6
  • 16