You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2020/08/31 13:32:42 UTC

[airflow] branch master updated: Display conf as a JSON in the DagRun list view (#10644)

This is an automated email from the ASF dual-hosted git repository.

kamilbregula pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/master by this push:
     new e6a0a53  Display conf as a JSON in the DagRun list view (#10644)
e6a0a53 is described below

commit e6a0a5374dabc431542113633148445e4c5159b9
Author: Marco Aguiar <ma...@gmail.com>
AuthorDate: Mon Aug 31 10:31:58 2020 -0300

    Display conf as a JSON in the DagRun list view (#10644)
    
    Co-authored-by: Marco Aguiar <ma...@DESKTOP-8IVSCHM.localdomain>
---
 airflow/www/utils.py    | 9 +++++++++
 airflow/www/views.py    | 1 +
 tests/www/test_views.py | 2 +-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/airflow/www/utils.py b/airflow/www/utils.py
index efcb518..21e6687 100644
--- a/airflow/www/utils.py
+++ b/airflow/www/utils.py
@@ -269,6 +269,15 @@ def datetime_f(attr_name):
 # pylint: enable=invalid-name
 
 
+def json_f(attr_name):
+    """Returns a formatted string with HTML for given JSON serializable"""
+    def json_(attr):
+        f = attr.get(attr_name)
+        serialized = json.dumps(f)
+        return Markup('<nobr>{}</nobr>').format(serialized)  # noqa
+    return json_
+
+
 def dag_link(attr):
     """Generates a URL to the Graph View for a Dag."""
     dag_id = attr.get('dag_id')
diff --git a/airflow/www/views.py b/airflow/www/views.py
index 04923bc..07c8d2f 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -2628,6 +2628,7 @@ class DagRunModelView(AirflowModelView):
         'start_date': wwwutils.datetime_f('start_date'),
         'dag_id': wwwutils.dag_link,
         'run_id': wwwutils.dag_run_link,
+        'conf': wwwutils.json_f('conf'),
     }
 
     @action('muldelete', "Delete", "Are you sure you want to delete selected records?",
diff --git a/tests/www/test_views.py b/tests/www/test_views.py
index cd7f08d..cb55c27 100644
--- a/tests/www/test_views.py
+++ b/tests/www/test_views.py
@@ -2860,7 +2860,7 @@ class TestDagRunModelView(TestBase):
         self.assertEqual(dr.conf, {"include": "me"})
 
         resp = self.client.get('/dagrun/list', follow_redirects=True)
-        self.check_content_in_response("{&#39;include&#39;: &#39;me&#39;}", resp)
+        self.check_content_in_response("{&#34;include&#34;: &#34;me&#34;}", resp)
 
 
 class TestDecorators(TestBase):