[LNT] r306744 - Refactor runs.html usage; NFC

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 29 14:40:30 PDT 2017


Author: matze
Date: Thu Jun 29 14:40:30 2017
New Revision: 306744

URL: http://llvm.org/viewvc/llvm-project?rev=306744&view=rev
Log:
Refactor runs.html usage; NFC

v4_run.html would prerender runs.html with a special only_html_body flag
enabled. The result would end up in a variable that would then be used
by a 2nd rendering run of the v4_run.html template.

Refactor this:
- Leave the body part in runs.html
- Add run_report.html template for the cases where we need full html:
  It adds the surrounding html tags and includes runs.html in the body.
- For v4_run: Skip prerendering and include runs.html from the
  v4_run.html template.

Added:
    lnt/trunk/lnt/server/ui/templates/reporting/run_report.html
    lnt/trunk/lnt/server/ui/templates/reporting/run_report.txt
      - copied, changed from r306743, lnt/trunk/lnt/server/ui/templates/reporting/runs.txt
Removed:
    lnt/trunk/lnt/server/ui/templates/reporting/runs.txt
Modified:
    lnt/trunk/lnt/lnttool/main.py
    lnt/trunk/lnt/server/ui/templates/reporting/runs.html
    lnt/trunk/lnt/server/ui/templates/v4_run.html
    lnt/trunk/lnt/server/ui/views.py
    lnt/trunk/lnt/util/NTEmailReport.py

Modified: lnt/trunk/lnt/lnttool/main.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/lnttool/main.py?rev=306744&r1=306743&r2=306744&view=diff
==============================================================================
--- lnt/trunk/lnt/lnttool/main.py (original)
+++ lnt/trunk/lnt/lnttool/main.py Thu Jun 29 14:40:30 2017
@@ -369,10 +369,9 @@ def action_send_run_comparison(instance_
             baseline=None, aggregation_fn=min)
 
         env = lnt.server.ui.app.create_jinja_environment()
-        text_template = env.get_template('reporting/runs.txt')
+        text_template = env.get_template('reporting/run_report.txt')
         text_report = text_template.render(data)
-        data['only_html_body'] = False
-        html_template = env.get_template('reporting/runs.html')
+        html_template = env.get_template('reporting/run_report.html')
         html_report = html_template.render(data)
 
         subject = data['subject']

Added: lnt/trunk/lnt/server/ui/templates/reporting/run_report.html
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/reporting/run_report.html?rev=306744&view=auto
==============================================================================
--- lnt/trunk/lnt/server/ui/templates/reporting/run_report.html (added)
+++ lnt/trunk/lnt/server/ui/templates/reporting/run_report.html Thu Jun 29 14:40:30 2017
@@ -0,0 +1,8 @@
+<html>
+<head>
+   <title>{{ subject }}</title>
+</head>
+<body style="{{ styles['body'] }}">
+  {% include "reporting/runs.html" %}
+</body>
+</html>

Copied: lnt/trunk/lnt/server/ui/templates/reporting/run_report.txt (from r306743, lnt/trunk/lnt/server/ui/templates/reporting/runs.txt)
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/reporting/run_report.txt?p2=lnt/trunk/lnt/server/ui/templates/reporting/run_report.txt&p1=lnt/trunk/lnt/server/ui/templates/reporting/runs.txt&r1=306743&r2=306744&rev=306744&view=diff
==============================================================================
    (empty)

Modified: lnt/trunk/lnt/server/ui/templates/reporting/runs.html
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/reporting/runs.html?rev=306744&r1=306743&r2=306744&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/templates/reporting/runs.html (original)
+++ lnt/trunk/lnt/server/ui/templates/reporting/runs.html Thu Jun 29 14:40:30 2017
@@ -1,4 +1,3 @@
-
 {% import "utils.html" as utils %}
 
 {#
@@ -68,14 +67,6 @@
 {% endif %}
 {% endmacro %}
 
-{% if not only_html_body %}
-<html>
-<head>
-   <title>{{ subject }}</title>
-</head>
-<body style="{{ styles['body'] }}">
-{% endif %}
-
 <h1 style="{{ styles['h1'] }}">
   <a href="{{ report_url }}">{{ subject }}</a>
 </h1>
@@ -191,7 +182,3 @@
 {% endif %}
 <hr/>
 <b>Report Time</b>: {{ start_time | timedelta }}
-{% if not only_html_body %}
-</body>
-</html>
-{% endif %}

Removed: lnt/trunk/lnt/server/ui/templates/reporting/runs.txt
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/reporting/runs.txt?rev=306743&view=auto
==============================================================================
--- lnt/trunk/lnt/server/ui/templates/reporting/runs.txt (original)
+++ lnt/trunk/lnt/server/ui/templates/reporting/runs.txt (removed)
@@ -1,77 +0,0 @@
-{%- macro add_report_changes_detail_for_field_and_bucket(show_perf, field_display_name, bucket_name, bucket, test_names) -%}
-{%- if bucket and bucket_name != 'Unchanged Tests' %}
-
-{{ bucket_name }} - {{ field_display_name }}
-{{ '-' * (bucket_name.__len__() + field_display_name.__len__() + 3) }}
-{%- if not show_perf %}
-  {%- for name in test_names %}
-  {{ name }}
-  {%- endfor %}
-{%- endif %}
-{%- for name, cr, test_id in bucket -%}
-{% if cr.previous is not none and cr.current is not none %}
-  {{ name }}: {{ "%.2f%%" | format_or_default(cr.pct_delta and cr.pct_delta*100, '-')}} {{ "(%.4f => %.4f" | format(cr.previous, cr.current) }}{{ ", std.dev.: %.4f)" | format_or_default(cr.stddev, ")")}}
-{%- endif %}
-{%- endfor %}
-
-{%- endif %}
-{%- endmacro -%}
-
-{{ report_url }}
-Nickname: {{ machine.name }}:{{ machine.id }}
-{% if 'hostname' in machine_parameters -%}
-{{ "Hostname: %s" | format(machine_parameters['hostname']) }}
-{%- endif %}
-Comparing:
-     Run: {{ run.id }}, Order: {{ run.order.llvm_project_revision }}, Start Time: {{ run.start_time }}, End Time: {{ run.end_time }}
-{%- if compare_to %}
-      To: {{ compare_to.id }}, Order: {{ compare_to.order.llvm_project_revision }}, Start Time: {{ compare_to.start_time }}, End Time: {{ compare_to.end_time }}
-     {%- if run.machine != compare_to.machine %}
-*** WARNING ***:
-comparision is against a different machine
-({{ compare_to.machine.name }}:{{ compare_to.machine.id }})        
-     {%- endif %}
-{%- else %}
-      To: (none)
-{%- endif %}
-{%- if baseline %}
-Baseline: {{ baseline.id }}, Order: {{ baseline.order.llvm_project_revision }}, Start Time: {{ baseline.start_time }}, End Time: {{ baseline.end_time }}
-{%- endif %}
-
-===============
-Tests Summary
-===============
-{% for i, name, num_items, num_items_vs_baseline in num_item_buckets -%}
-  {%- if num_items or num_items_vs_baseline %}
-     {%- if baseline %}
-{{ name }}: {{ num_items }} ({{ num_items_vs_baseline }} on baseline)
-     {%- else %}
-{{ name }}: {{ num_items }}
-     {%- endif %}
-  {%- endif %}                
-{%- endfor %}
-Total Tests: {{ num_total_tests }}
-
-===========================
-Run-Over-Run Changes Detail
-===========================
-{%- for _, field, bucket_name, sorted_bucket, test_names, show_perf in prioritized_buckets_run_over_run %}
-  {%- set field_display_name = {"compile_time":"Compile Time", "execution_time":"Execution Time"}.get(field.name, field.name) -%}
-  {{ add_report_changes_detail_for_field_and_bucket(show_perf, field_display_name, bucket_name, sorted_bucket, test_names) }}
-{%- endfor %}
-{%- if baseline %}
-
-================================
-Run-Over-Baseline Changes Detail
-================================
-{%- for _, field, bucket_name, sorted_bucket, test_names, show_perf in prioritized_buckets_run_over_baseline -%}
-  {%- set field_display_name = {"compile_time":"Compile Time",
-                               "execution_time":"Execution Time"}.get(field.name, field.name) -%}
-  {{
-    add_report_changes_detail_for_field_and_bucket(show_perf, field_display_name,
-                                                           bucket_name, sorted_bucket, test_names)
-  }}
-{%- endfor %}
-{%- endif %}
-
-Report Time: {{ start_time | timedelta }}

Modified: lnt/trunk/lnt/server/ui/templates/v4_run.html
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/v4_run.html?rev=306744&r1=306743&r2=306744&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/templates/v4_run.html (original)
+++ lnt/trunk/lnt/server/ui/templates/v4_run.html Thu Jun 29 14:40:30 2017
@@ -1,9 +1,5 @@
 {% import "utils.html" as utils %}
 
-{% set run = request_info.run %}
-{% set compare_to = request_info.compare_to %}
-{% set baseline = request_info.baseline %}
-{% set ts = request_info.ts %}
 {% set hash_field = ts.Sample.get_hash_of_binary_field() %}
 {% set machine = run.machine %}
 {% set neighboring_runs = request_info.neighboring_runs %}
@@ -313,7 +309,8 @@ $('.profile-prev-only').tooltip();
                             placeholder="Benchmark name regex...",
                             selector_part_to_search=".benchmark-name") }}
 
-  {{request_info.html_report|safe}}
+  {% include "reporting/runs.html" %}
+
   {{ utils.render_popup_end() }}
 
   {% set graph_base=v4_url_for('v4_graph', highlight_run=run.id) %}

Modified: lnt/trunk/lnt/server/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/views.py?rev=306744&r1=306743&r2=306744&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/views.py (original)
+++ lnt/trunk/lnt/server/ui/views.py Thu Jun 29 14:40:30 2017
@@ -322,21 +322,20 @@ class V4RequestInfo(object):
         compare_to_str = request.args.get('compare_to')
         if compare_to_str:
             compare_to_id = int(compare_to_str)
-            self.compare_to = ts.query(ts.Run).\
-                filter_by(id=compare_to_id).first()
-            if self.compare_to is None:
+            compare_to = ts.query(ts.Run).filter_by(id=compare_to_id).first()
+            if compare_to is None:
                 flash("Comparison Run is invalid: " + compare_to_str,
                       FLASH_DANGER)
             else:
                 self.comparison_neighboring_runs = (
-                    list(ts.get_next_runs_on_machine(self.compare_to, N=3))[::-1] +
-                    [self.compare_to] +
-                    list(ts.get_previous_runs_on_machine(self.compare_to, N=3)))
+                    list(ts.get_next_runs_on_machine(compare_to, N=3))[::-1] +
+                    [compare_to] +
+                    list(ts.get_previous_runs_on_machine(compare_to, N=3)))
         else:
             if prev_runs:
-                self.compare_to = prev_runs[0]
+                compare_to = prev_runs[0]
             else:
-                self.compare_to = None
+                compare_to = None
             self.comparison_neighboring_runs = self.neighboring_runs
 
         try:
@@ -349,15 +348,14 @@ class V4RequestInfo(object):
         baseline_str = request.args.get('baseline')
         if baseline_str:
             baseline_id = int(baseline_str)
-            self.baseline = ts.query(ts.Run).\
-                filter_by(id=baseline_id).first()
-            if self.baseline is None:
+            baseline = ts.query(ts.Run).filter_by(id=baseline_id).first()
+            if baseline is None:
                 flash("Could not find baseline " + baseline_str, FLASH_DANGER)
         else:
-            self.baseline = None
+            baseline = None
 
         # Gather the runs to use for statistical data.
-        comparison_start_run = self.compare_to or self.run
+        comparison_start_run = compare_to or self.run
 
         # We're going to render this on a real webpage with CSS support, so
         # override the default styles and provide bootstrap class names for
@@ -374,7 +372,7 @@ class V4RequestInfo(object):
 
         self.data = lnt.server.reporting.runs.generate_run_data(
             self.run, baseurl=db_url_for('index', _external=True),
-            result=None, compare_to=self.compare_to, baseline=self.baseline,
+            result=None, compare_to=compare_to, baseline=baseline,
             num_comparison_runs=self.num_comparison_runs,
             aggregation_fn=self.aggregation_fn, confidence_lv=confidence_lv,
             styles=styles, classes=classes)
@@ -383,14 +381,13 @@ class V4RequestInfo(object):
 @v4_route("/<int:id>/report")
 def v4_report(id):
     info = V4RequestInfo(id)
-    return render_template('reporting/runs.html', only_html_body=False,
-                           **info.data)
+    return render_template('reporting/run_report.html', **info.data)
 
 @v4_route("/<int:id>/text_report")
 def v4_text_report(id):
     info = V4RequestInfo(id)
 
-    text_report = render_template('reporting/runs.txt', **info.data)
+    text_report = render_template('reporting/run_report.txt', **info.data)
     response = make_response(text_report)
     response.mimetype = "text/plain"
     return response
@@ -498,15 +495,17 @@ def v4_run(id):
     urls = {
         'search': v4_url_for('v4_search')
     }
-    info.html_report = render_template('reporting/runs.html',
-                                       only_html_body=True, **info.data)
-    return render_template(
-        "v4_run.html", ts=ts, options=options,
-        metric_fields=list(ts.Sample.get_metric_fields()),
-        test_info=test_info, analysis=lnt.server.reporting.analysis,
-        test_min_value_filter=test_min_value_filter,
-        request_info=info, urls=urls
-)
+    data = info.data
+    data.update({
+        'analysis': lnt.server.reporting.analysis,
+        'metric_fields': list(ts.Sample.get_metric_fields()),
+        'options': options,
+        'request_info': info,
+        'test_info': test_info,
+        'test_min_value_filter': test_min_value_filter,
+        'urls': urls,
+    })
+    return render_template("v4_run.html", **data)
 
 
 class PromoteOrderToBaseline(Form):

Modified: lnt/trunk/lnt/util/NTEmailReport.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/util/NTEmailReport.py?rev=306744&r1=306743&r2=306744&view=diff
==============================================================================
--- lnt/trunk/lnt/util/NTEmailReport.py (original)
+++ lnt/trunk/lnt/util/NTEmailReport.py Thu Jun 29 14:40:30 2017
@@ -51,9 +51,8 @@ def getReport(result, db, run, baseurl,
         result=result, compare_to=compare_to, num_comparison_runs=10)
 
     env = lnt.server.ui.app.create_jinja_environment()
-    text_template = env.get_template('reporting/runs.txt')
+    text_template = env.get_template('reporting/run_report.txt')
     text_report = text_template.render(data)
-    data['only_html_body'] = False
-    html_template = env.get_template('reporting/runs.html')
+    html_template = env.get_template('reporting/run_report.html')
     html_report = html_template.render(data)
     return data['subject'], text_report, html_report




More information about the llvm-commits mailing list