kaxil commented on a change in pull request #11815:
URL: https://github.com/apache/airflow/pull/11815#discussion_r516834068
##########
File path: airflow/www/views.py
##########
@@ -890,6 +890,57 @@ def rendered(self):
root=root,
title=title)
+ @expose('/rendered-k8s')
+ @auth.has_access(
+ [
+ (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
+ (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
+ ]
+ )
+ @action_logging
+ def rendered_k8s(self):
+ """Get rendered Dag."""
+ 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', '')
+
+ logging.info("Retrieving rendered templates.")
+ dag = current_app.dag_bag.get_dag(dag_id)
+
+ task = copy.copy(dag.get_task(task_id))
+ ti = models.TaskInstance(task=task, execution_date=dttm)
+ try:
+ pod_spec = ti.render_k8s_pod_yaml()
+ except AirflowException as e: # pylint: disable=broad-except
+ msg = "Error rendering template: " + escape(e)
+ if e.__cause__: # pylint: disable=using-constant-test
+ msg += Markup("<br><br>OriginalError: ") + escape(e.__cause__)
+ flash(msg, "error")
+ except Exception as e: # pylint: disable=broad-except
+ flash("Error rendering template: " + str(e), "error")
+ title = "Rendered K8s Pod Spec"
+ html_dict = {}
+ # renderers = wwwutils.get_attr_renderer()
+ # content = json.dumps(pod_spec, sort_keys=True, indent=4)
Review comment:
is this needed?
##########
File path: airflow/www/views.py
##########
@@ -890,6 +890,57 @@ def rendered(self):
root=root,
title=title)
+ @expose('/rendered-k8s')
+ @auth.has_access(
+ [
+ (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
+ (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
+ ]
+ )
+ @action_logging
+ def rendered_k8s(self):
+ """Get rendered Dag."""
+ 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', '')
+
+ logging.info("Retrieving rendered templates.")
+ dag = current_app.dag_bag.get_dag(dag_id)
+
+ task = copy.copy(dag.get_task(task_id))
+ ti = models.TaskInstance(task=task, execution_date=dttm)
+ try:
+ pod_spec = ti.render_k8s_pod_yaml()
+ except AirflowException as e: # pylint: disable=broad-except
+ msg = "Error rendering template: " + escape(e)
+ if e.__cause__: # pylint: disable=using-constant-test
+ msg += Markup("<br><br>OriginalError: ") + escape(e.__cause__)
+ flash(msg, "error")
+ except Exception as e: # pylint: disable=broad-except
+ flash("Error rendering template: " + str(e), "error")
+ title = "Rendered K8s Pod Spec"
+ html_dict = {}
+ # renderers = wwwutils.get_attr_renderer()
+ # content = json.dumps(pod_spec, sort_keys=True, indent=4)
+ renderers = wwwutils.get_attr_renderer()
+ import yaml
Review comment:
Out of place import
----------------------------------------------------------------
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:
[email protected]