GitHub user AdamStormhardtGH added a comment to the discussion: 
AirflowNotFoundException(f"The conn_id `{conn_id}` isn't defined")

Heads up this issue will be thrown if you accidentally create a 
`PythonOperator` with a `python_callable` which includes brackets.

ie. 

```python
task_number1 = PythonOperator(
        task_id="task_name_for_task_number1",
        python_callable=my_function(), # this bit
        provide_context=True,
        dag=dag,
    )
```

using `python_callable=my_function(), ` will execute on import, which will mean 
Airflow will attempt to resolve values which have not yet been imported 
correctly, or initialised. 

I had this connection error thrown due to this, since the function included a 
Bq Hook which had a connection id I needed to reference from the dag. 

correct would be:

```python
task_number1 = PythonOperator(
        task_id="task_name_for_task_number1",
        python_callable=my_function, # this bit with the removal of ()
        provide_context=True,
        dag=dag,
    )
```

Hopefully this helps someone who's seeing this weird error raise. tbh airflow 
should probably have a check within the PythonOperator to expect a function, 
not an executed function.

GitHub link: 
https://github.com/apache/airflow/discussions/20813#discussioncomment-12182181

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to