You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "jack (Jira)" <ji...@apache.org> on 2019/11/06 13:52:00 UTC

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

    [ https://issues.apache.org/jira/browse/AIRFLOW-330?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16968374#comment-16968374 ] 

jack commented on AIRFLOW-330:
------------------------------

if it's only Python 2 issue than probably this isn't needed anymore 

> 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)