JCoder01 opened a new issue, #37136:
URL: https://github.com/apache/airflow/issues/37136
### Apache Airflow version
Other Airflow 2 version (please specify below)
### If "Other Airflow 2 version" selected, which one?
2.7.3
### What happened?
```
2024-02-01T15:01:41.731+0000] {process_utils.py:186} INFO - Output:
[2024-02-01T15:01:41.912+0000] {process_utils.py:190} INFO - Traceback (most
recent call last):
[2024-02-01T15:01:41.912+0000] {process_utils.py:190} INFO - File
"/tmp/tmdfow99m6c/script.py", line 17, in <module>
[2024-02-01T15:01:41.913+0000] {process_utils.py:190} INFO -
@external_python_task(task_id = 'task_runner', python=PYENV,
expect_airflow=False)
[2024-02-01T15:01:41.913+0000] {process_utils.py:190} INFO -
^^^^^^^^^^^^^^^^^^^^
[2024-02-01T15:01:41.913+0000] {process_utils.py:190} INFO - NameError: name
'external_python_task' is not defined
```
When generating `python_callable_source` the airflow decorator is included
in the source
### What you think should happen instead?
Airflow should strip the decorator from the function definition
### How to reproduce
Create python env that doesn't install airflow (PYENV)
run something to effect of:
```python
from airflow.decorators import external_python_task
from airflow.models.taskinstance import TaskInstance
@external_python_task(python=PYENV, expect_airflow=False)
def task_runner():
pass
with DAG(dag_id="test", start_date=pendulum.now()):
task_runner()
task = dag.get_task('task_runner')
t1 = TaskInstance(task=task, execution_date=dag.get_latest_execution_date())
t1.render_templates()
task.execute(t1.get_template_context())
```
### Operating System
linux
### Versions of Apache Airflow Providers
_No response_
### Deployment
Official Apache Airflow Helm Chart
### 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]