You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Jon McKenzie (JIRA)" <ji...@apache.org> on 2016/07/12 22:39:20 UTC

[jira] [Created] (AIRFLOW-330) Decorated PythonOperator python_callable functions don't show the original function in task code view

Jon McKenzie created AIRFLOW-330:
------------------------------------

             Summary: 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
(v6.3.4#6332)