[
https://issues.apache.org/jira/browse/AIRFLOW-330?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Daniel Imberman closed AIRFLOW-330.
-----------------------------------
Resolution: Auto Closed
> Decorated PythonOperator python_callable functions don't show the original
> function in task code view
> -----------------------------------------------------------------------------------------------------
>
> Key: AIRFLOW-330
> URL: https://issues.apache.org/jira/browse/AIRFLOW-330
> Project: Apache Airflow
> Issue Type: Bug
> Components: webserver
> Reporter: Jon McKenzie
> Priority: Minor
>
> In Python 3.4 or below, if you try to decorate the {{python_callable}} to a
> {{PythonOperator}} in the following manner (i.e. like the manual application
> of a standard Python decorator using {{functools.wraps}}):
> {noformat}
> task.python_callable = wrap(task.python_callable)
> {noformat}
> ...the code view of that task in the web UI shows the code for the {{wrap}}
> function rather than the initial {{python_callable}}.
> The fix is to run something like this (where {{inspect.unwrap}} is available
> in Python 3.4+):
> {noformat}
> inspect.getsource(inspect.unwrap(func))
> {noformat}
> ...rather than:
> {noformat}
> inspect.getsource(func)
> {noformat}
> I'm not sure if this is something worth fixing or not, since I believe Python
> 3.5+ implements the above fix (although I believe it would still be an issue
> in Python 2.x).
> Just for some background, I'm writing a higher level API around Airflow that
> takes tasks as arguments and connects their inputs via {{XCom}} (among other
> things). The callables I want my API users to write aren't going to need
> access to any of the task context (only so that they don't need to know
> Airflow internals), hence the need to decorate them appropriately.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)