kaxil commented on a change in pull request #6788: WIP: [AIRFLOW-5944] 
Rendering templated_fields without accessing DAG files
URL: https://github.com/apache/airflow/pull/6788#discussion_r386480827
 
 

 ##########
 File path: airflow/www/views.py
 ##########
 @@ -570,25 +572,37 @@ def dag_details(self, session=None):
     @has_dag_access(can_dag_read=True)
     @has_access
     @action_logging
-    def rendered(self):
+    @provide_session
+    def rendered(self, session=None):
         dag_id = request.args.get('dag_id')
         task_id = request.args.get('task_id')
         execution_date = request.args.get('execution_date')
         dttm = timezone.parse(execution_date)
         form = DateTimeForm(data={'execution_date': dttm})
         root = request.args.get('root', '')
-        # Loads dag from file
-        logging.info("Processing DAG file to render template.")
-        dag = dagbag.get_dag(dag_id, from_file_only=True)
+
+        logging.info("Retrieving rendered templates.")
+        dag = dagbag.get_dag(dag_id)
+
         task = copy.copy(dag.get_task(task_id))
         ti = models.TaskInstance(task=task, execution_date=dttm)
         try:
-            ti.render_templates()
+            if STORE_SERIALIZED_DAGS:
+                rtif = RenderedTaskInstanceFields.get_templated_fields(ti)
+                if rtif:
+                    for field_name, rendered_value in rtif.items():
+                        setattr(task, field_name, rendered_value)
+                else:
+                    # ToDo: Fetch raw strings from RenderedTaskInstanceFields 
table
+                    flash("Template field not found")
+            else:
+                ti.render_templates()
 
 Review comment:
   Done !

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to