[llvm-commits] [zorg] r147163 - in /zorg/trunk/lnt/lnt: server/db/testsuitedb.py server/reporting/ server/reporting/__init__.py server/reporting/runs.py server/ui/views.py util/NTEmailReport.py

Daniel Dunbar daniel at zuster.org
Thu Dec 22 11:24:21 PST 2011


Author: ddunbar
Date: Thu Dec 22 13:24:21 2011
New Revision: 147163

URL: http://llvm.org/viewvc/llvm-project?rev=147163&view=rev
Log:
[lnt/v0.4] lnt.server.reporting: Start defining V4 report implementation.

Added:
    zorg/trunk/lnt/lnt/server/reporting/
    zorg/trunk/lnt/lnt/server/reporting/__init__.py
    zorg/trunk/lnt/lnt/server/reporting/runs.py
Modified:
    zorg/trunk/lnt/lnt/server/db/testsuitedb.py
    zorg/trunk/lnt/lnt/server/ui/views.py
    zorg/trunk/lnt/lnt/util/NTEmailReport.py

Modified: zorg/trunk/lnt/lnt/server/db/testsuitedb.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/db/testsuitedb.py?rev=147163&r1=147162&r2=147163&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/db/testsuitedb.py (original)
+++ zorg/trunk/lnt/lnt/server/db/testsuitedb.py Thu Dec 22 13:24:21 2011
@@ -40,6 +40,14 @@
 
         # Create parameterized model classes for this test suite.
         class ParameterizedMixin(object):
+            # Class variable to allow finding the associated test suite from
+            # model instances.
+            testsuite = self
+
+            # Class variable (expected to be defined by subclasses) to allow
+            # easy access to the field list for parameterized model classes.
+            fields = None
+
             def get_field(self, field):
                 return getattr(self, field.name)
 

Added: zorg/trunk/lnt/lnt/server/reporting/__init__.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/reporting/__init__.py?rev=147163&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/server/reporting/__init__.py (added)
+++ zorg/trunk/lnt/lnt/server/reporting/__init__.py Thu Dec 22 13:24:21 2011
@@ -0,0 +1 @@
+__all__ = []

Added: zorg/trunk/lnt/lnt/server/reporting/runs.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/reporting/runs.py?rev=147163&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/server/reporting/runs.py (added)
+++ zorg/trunk/lnt/lnt/server/reporting/runs.py Thu Dec 22 13:24:21 2011
@@ -0,0 +1,132 @@
+"""
+Report functionality centered around individual runs.
+"""
+
+import StringIO
+import os
+
+def generate_run_report(run, baseurl, only_html_body = False,
+                        num_comparison_runs = 10):
+    """
+    generate_run_report(...) -> (str: subject, str: text_report,
+                                 str: html_report)
+
+    Generate a comprehensive report on the results of the given individual
+    run, suitable for emailing or presentation on a web page.
+    """
+
+    assert num_comparison_runs > 0
+
+
+    ts = run.testsuite
+    machine = run.machine
+    machine_parameters = machine.parameters
+
+    # Gather the runs to use for statistical data.
+    comparison_window = list(ts.get_previous_runs_on_machine(
+            run, num_comparison_runs))
+
+    # Get the specific run to compare to.
+    if comparison_window:
+        compare_to = comparison_window[0]
+    else:
+        compare_to = None
+
+    # Begin report generation...
+    subject = """%s test results: %s""" % (
+        machine.name, run.start_time.strftime('%Y-%m-%d %H:%M:%S %Z PST'))
+    report = StringIO.StringIO()
+    html_report = StringIO.StringIO()
+
+    # Generate the report header.
+    if baseurl[-1] == '/':
+        baseurl = baseurl[:-1]
+
+    report_url = """%s/%d/""" % (baseurl, run.id)
+    print >>report, report_url
+    print >>report, """Nickname: %s:%d""" % (machine.name, machine.id)
+    if 'name' in machine_parameters:
+        print >>report, """Name: %s""" % (machine_parameters['name'],)
+    print >>report, """Comparing:"""
+    # FIXME: Remove hard coded field use here.
+    print >>report, """  Run: %d, Order: %s, Start Time: %s, End Time: %s""" % (
+        run.id, run.order.llvm_project_revision, run.start_time, run.end_time)
+    if compare_to:
+        # FIXME: Remove hard coded field use here.
+        print >>report, ("""   To: %d, Order: %s, """
+                         """Start Time: %s, End Time: %s""") % (
+            compare_to.id, compare_to.order.llvm_project_revision,
+            compare_to.start_time, compare_to.end_time)
+        if run.machine != compare_to.machine:
+            print >>report, """*** WARNING ***:""",
+            print >>report, """comparison is against a different machine""",
+            print >>report, """(%s:%d)""" % (compare_to.machine.name,
+                                             compare_to.machine.id)
+    else:
+        print >>report, """   To: (none)"""
+    print >>report
+
+    # Generate the HTML report header.
+    print >>html_report, """\
+<h1>%s</h1>
+<table>""" % subject
+    print >>html_report, """\
+<tr><td>URL</td><td><a href="%s">%s</a></td></tr>""" % (report_url, report_url)
+    print >>html_report, "<tr><td>Nickname</td><td>%s:%d</td></tr>" % (
+        machine.name, machine.id)
+    if 'name' in machine_parameters:
+        print >>html_report, """<tr><td>Name</td><td>%s</td></tr>""" % (
+            machine_parameters['name'],)
+    print >>html_report, """</table>"""
+    print >>html_report, """\
+<p>
+<table>
+  <tr>
+    <th>Run</th>
+    <th>ID</th>
+    <th>Order</th>
+    <th>Start Time</th>
+    <th>End Time</th>
+  </tr>"""
+    # FIXME: Remove hard coded field use here.
+    print >>html_report, """\
+<tr><td>Current</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td></tr>""" % (
+        run.id, run.order.llvm_project_revision, run.start_time, run.end_time)
+    if compare_to:
+        # FIXME: Remove hard coded field use here.
+        print >>html_report, """\
+<tr><td>Previous</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td></tr>""" % (
+            compare_to.id, compare_to.order.llvm_project_revision,
+            compare_to.start_time, compare_to.end_time)
+    else:
+        print >>html_report, """<tr><td colspan=4>No Previous Run</td></tr>"""
+    print >>html_report, """</table>"""
+    if compare_to and run.machine != compare_to.machine:
+        print >>html_report, """<p><b>*** WARNING ***:""",
+        print >>html_report, """comparison is against a different machine""",
+        print >>html_report, """(%s:%d)</b></p>""" % (compare_to.machine.name,
+                                                      compare_to.machine.id)
+
+    html_report = html_report.getvalue()
+    if not only_html_body:
+        # We embed the additional resources, so that the message is self
+        # contained.
+        static_path = os.path.join(os.path.dirname(os.path.dirname(__file__)),
+                                   "ui", "static")
+        style_css = open(os.path.join(static_path,
+                                      "style.css")).read()
+
+        html_report = """
+<html>
+  <head>
+    <style type="text/css">
+%(style_css)s
+    </style>
+    <title>%(subject)s</title>
+  </head>
+  <body onload="init_report()">
+%(html_report)s
+  </body>
+</html>""" % locals()
+
+    return subject, report.getvalue(), html_report

Modified: zorg/trunk/lnt/lnt/server/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=147163&r1=147162&r2=147163&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/ui/views.py (original)
+++ zorg/trunk/lnt/lnt/server/ui/views.py Thu Dec 22 13:24:21 2011
@@ -645,7 +645,8 @@
     run = ts.getRun(id)
 
     _, _, html_report = NTEmailReport.getReport(
-        result=None, db=db, run=run, baseurl=v4_url_for('index'),
+        result=None, db=db, run=run,
+        baseurl=v4_url_for('v4_overview', _external=True),
         was_added=True, will_commit=True, only_html_body=False)
 
     return make_response(html_report)
@@ -657,7 +658,8 @@
     run = ts.getRun(id)
 
     _, text_report, _ = NTEmailReport.getReport(
-        result=None, db=db, run=run, baseurl=v4_url_for('index'),
+        result=None, db=db, run=run,
+        baseurl=v4_url_for('v4_overview', _external=True),
         was_added=True, will_commit=True, only_html_body=True)
 
     response = make_response(text_report)
@@ -705,7 +707,8 @@
     # FIXME: This is a crummy implementation of the concept that we want the
     # webapp UI to be easy to correlate with the email reports.
     _, text_report, html_report = NTEmailReport.getReport(
-        result=None, db=db, run=run, baseurl=v4_url_for('index'),
+        result=None, db=db, run=run,
+        baseurl=v4_url_for('v4_overview', _external=True),
         was_added=True, will_commit=True, only_html_body=True)
 
     return render_template("v4_run.html", ts=ts, run=run,

Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/NTEmailReport.py?rev=147163&r1=147162&r2=147163&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/util/NTEmailReport.py (original)
+++ zorg/trunk/lnt/lnt/util/NTEmailReport.py Thu Dec 22 13:24:21 2011
@@ -19,6 +19,7 @@
 from lnt.db import perfdb
 from lnt.util.NTUtil import *
 import lnt.server.db.v4db
+import lnt.server.reporting.runs
 
 from lnt.db.perfdb import Run, Sample
 
@@ -468,7 +469,8 @@
 
     # We haven't implemented V4DB support yet in reports.
     if isinstance(db, lnt.server.db.v4db.V4DB):
-        return "NotYetImplemented", "NotYetImplemented", "NotYetImplemented"
+        return lnt.server.reporting.runs.generate_run_report(
+            run, baseurl=baseurl, only_html_body=only_html_body)
 
     # Use a simple report unless the tag indicates this is an old style nightly
     # test run.





More information about the llvm-commits mailing list