enisnazif opened a new issue, #27232: URL: https://github.com/apache/airflow/issues/27232
### Apache Airflow version Other Airflow 2 version (please specify below) ### What happened Using the ExternalPythonOperator directly in v2.4.2 as opposed to via the @task.external decorator described in https://airflow.apache.org/docs/apache-airflow/stable/howto/operator/python.html#externalpythonoperator causes the following error: ``` AttributeError: 'python_path' is configured as a template field but ExternalPythonOperator does not have this attribute. ``` This seems to be due to https://github.com/apache/airflow/blob/main/airflow/operators/python.py#L624 having 'python_path' as an additional template field, instead of 'python', which is the correct additional keyword argument for the operator ### What you think should happen instead We should change https://github.com/apache/airflow/blob/main/airflow/operators/python.py#L624 to read: ``` template_fields: Sequence[str] = tuple({'python'} | set(PythonOperator.template_fields)) ``` instead of ``` template_fields: Sequence[str] = tuple({'python_path'} | set(PythonOperator.template_fields)) ``` This has been verified by adding: ``` ExternalPythonOperator.template_fields = tuple({'python'} | set(PythonOperator.template_fields)) ``` in the sample DAG code below, which causes the DAG to run successfully ### How to reproduce ``` import airflow from airflow.models import DAG from airflow.operators.python import ExternalPythonOperator args = dict( start_date=airflow.utils.dates.days_ago(3), email=["[email protected]"], email_on_failure=False, email_on_retry=False, retries=0 ) dag = DAG( dag_id='test_dag', default_args=args, schedule_interval='0 20 * * *', catchup=False, ) def print_kwargs(*args, **kwargs): from mca.ingest.barclays_swaps.entrypoint import ingest_barclays_swaps, download_barclays_swaps_report print('args', args) print('kwargs', kwargs) with dag: def print_hello(): print('hello') # Due to a typo in the airflow library :( # ExternalPythonOperator.template_fields = tuple({'python'} | set(PythonOperator.template_fields)) t1 = ExternalPythonOperator( task_id='test_task', python='/opt/airflow/miniconda/envs/nexus/bin/python', python_callable=print_kwargs ) ``` ### Operating System Ubuntu 18.04 ### Versions of Apache Airflow Providers _No response_ ### Deployment Docker-Compose ### Deployment details _No response_ ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
