You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/08/06 23:41:35 UTC

[GitHub] [airflow] kaxil commented on a change in pull request #5701: [AIRFLOW-5088][AIP-24] Add DAG serialization using JSON

kaxil commented on a change in pull request #5701: [AIRFLOW-5088][AIP-24] Add DAG serialization using JSON
URL: https://github.com/apache/airflow/pull/5701#discussion_r311318514
 
 

 ##########
 File path: airflow/www/utils.py
 ##########
 @@ -374,6 +376,30 @@ def get_chart_height(dag):
     return 600 + len(dag.tasks) * 10
 
 
+def get_python_source(x: Union[Callable, str]) -> str:
+    """
+    Helper function to get Python source (or not), preventing exceptions
+    """
+    if isinstance(x, str):
+        return x
+    source_code = None
+    if isinstance(x, functools.partial):
+        source_code = inspect.getsource(x.func)
+    if source_code is None:
+        try:
+            source_code = inspect.getsource(x)
+        except TypeError:
+            pass
+    if source_code is None:
+        try:
+            source_code = inspect.getsource(x.__call__)
 
 Review comment:
   Why do we need this?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services