[llvm-commits] [zorg] r147042 - in /zorg/trunk/lnt/lnt/server/ui: app.py templates/v4_overview.html views.py

Daniel Dunbar daniel at zuster.org
Tue Dec 20 22:22:11 PST 2011


Author: ddunbar
Date: Wed Dec 21 00:22:10 2011
New Revision: 147042

URL: http://llvm.org/viewvc/llvm-project?rev=147042&view=rev
Log:
[lnt/v0.4] lnt.server.ui/v4/<name>: Implement V4 overview page.

Added:
    zorg/trunk/lnt/lnt/server/ui/templates/v4_overview.html
Modified:
    zorg/trunk/lnt/lnt/server/ui/app.py
    zorg/trunk/lnt/lnt/server/ui/views.py

Modified: zorg/trunk/lnt/lnt/server/ui/app.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/app.py?rev=147042&r1=147041&r2=147042&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/ui/app.py (original)
+++ zorg/trunk/lnt/lnt/server/ui/app.py Wed Dec 21 00:22:10 2011
@@ -34,6 +34,7 @@
         self.request_time = time.time()
         self.db = None
         self.db_summary = None
+        self.testsuite = None
 
     def elapsed_time(self):
         return time.time() - self.request_time
@@ -59,6 +60,12 @@
 
         return self.db
 
+    def get_testsuite(self):
+        if self.testsuite is None:
+            self.testsuite = self.get_db().testsuite[g.testsuite_name]
+
+        return self.testsuite
+
     def get_db_summary(self):
         return current_app.get_db_summary(g.db_name, self.get_db())
 
@@ -68,6 +75,14 @@
     """
     return url_for(*args, db_name=g.db_name, **kwargs)
 
+def v4_url_for(*args, **kwargs):
+    """
+    Like url_for, but handles automatically providing the db_name and
+    testsuite_name arguments.
+    """
+    return url_for(*args, db_name=g.db_name, testsuite_name=g.testsuite_name,
+                    **kwargs)
+
 class App(flask.Flask):
     @staticmethod
     def create_standalone(config_path):
@@ -110,6 +125,7 @@
         self.jinja_env.globals.update(
             app=current_app,
             db_url_for=db_url_for,
+            v4_url_for=v4_url_for,
             perfdb=perfdb,
             old_config=self.old_config)
 

Added: zorg/trunk/lnt/lnt/server/ui/templates/v4_overview.html
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/v4_overview.html?rev=147042&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/server/ui/templates/v4_overview.html (added)
+++ zorg/trunk/lnt/lnt/server/ui/templates/v4_overview.html Wed Dec 21 00:22:10 2011
@@ -0,0 +1,71 @@
+{% set db = request.get_db() %}
+
+{% extends "layout.html" %}
+{% set components = [(testsuite_name, v4_url_for("v4_overview"))] %}
+{% block title %}Overview{% endblock %}
+{% block body %}
+
+{# Find recent runs. #}
+<center><h3>Submission Overview</h3></center>
+<table width="100%%">
+  <tr>
+    <td valign="top" width="50%">
+      <center>
+      <h3>Active Machines</h3>
+      <table class="sortable" border=1>
+        <thead>
+        <tr>
+          <th>Latest Submission</th>
+          <th>Machine</th>
+          <th>Results</th>
+        </tr>
+        </thead>
+
+{# Show the most active machines. #}
+{% for machine_name,r in active_machines|dictsort %}
+      <tr>
+        <td>{{r.start_time}}</td>
+        <td align=left><a href="{{v4_url_for('v4_machine', id=r.machine.id)}}">{{
+            r.machine.name}}:{{r.machine.id}}</a></td>
+        <td><a href="{{v4_url_for('v4_run', id=r.id)}}">
+            View Results</a></td>
+      </tr>
+{% endfor %}
+
+      </table>
+      </center>
+    </td>
+    <td valign="top">
+      <center>
+      <h3>Recent Submissions</h3>
+      <table class="sortable" border=1>
+        <thead>
+        <tr>
+          <th>Run Order</th>
+          <th>Start Time</th>
+          <th>End Time</th>
+          <th>Machine</th>
+          <th>Results</th>
+        </tr>
+        </thead>
+
+{# Show the active submissions. #}
+{% for r,run_order in active_submissions %}
+{% set m = r.machine %}
+      <tr>
+        <td>{{run_order}}</td></td>
+        <td>{{r.start_time}}</td>
+        <td>{{r.end_time}}</td>
+        <td align=left><a href="{{v4_url_for('v4_machine',id=m.id)}}">{{
+            m.name}}:{{m.id}}</a></td>
+        <td><a href="{{v4_url_for('v4_run', id=r.id)}}">
+            View Results</a></td>
+      </tr>
+{% endfor %}
+      </table>
+      </center>
+    </td>
+  </tr>
+</table>
+
+{% endblock %}

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=147042&r1=147041&r2=147042&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/ui/views.py (original)
+++ zorg/trunk/lnt/lnt/server/ui/views.py Wed Dec 21 00:22:10 2011
@@ -170,7 +170,7 @@
         filter(RunInfo.key == "tag").\
         filter(RunInfo.value == tag).limit(100)
     recent_runs = list(recent_runs)
-    
+
     # Compute the active machine list.
     active_machines = dict((run.machine.name, run)
                            for run in recent_runs[::-1])
@@ -558,3 +558,67 @@
                               for m in available_machines]
 
     return render_template("simple_order_aggregate_report.html", **locals())
+
+###
+# V4 Schema Viewer
+
+# Decorator for implementing per-testsuite routes.
+def v4_route(rule, **options):
+    """
+    LNT V4 specific route for endpoints which always refer to some testsuite
+    object.
+    """
+
+    # FIXME: This is manually composed with db_route.
+    def decorator(f):
+        def wrap(testsuite_name, db_name = None, **args):
+            # Initialize the test suite parameters on the app globals object.
+            g.testsuite_name = testsuite_name
+
+            # Initialize the database parameters on the app globals object.
+            g.db_name = db_name or "default"
+            g.db_info = current_app.old_config.databases.get(g.db_name)
+            if g.db_info is None:
+                abort(404)
+
+            return f(**args)
+
+        frontend.add_url_rule("/v4/<testsuite_name>" + rule,
+                              f.__name__, wrap, **options)
+        frontend.add_url_rule("/db_<db_name>/v4/<testsuite_name>" + rule,
+                              f.__name__, wrap, **options)
+
+        return wrap
+    return decorator
+
+ at v4_route("/")
+def v4_overview():
+    ts = request.get_testsuite()
+
+    # Get the most recent runs in this tag, we just arbitrarily limit to looking
+    # at the last 100 submission.
+    recent_runs = ts.query(ts.Run).\
+        order_by(ts.Run.start_time.desc()).limit(100)
+    recent_runs = list(recent_runs)
+
+    # Compute the active machine list.
+    active_machines = dict((run.machine.name, run)
+                           for run in recent_runs[::-1])
+
+    # Compute the active submission list.
+    N = 30
+    active_submissions = [(r, r.order.llvm_project_revision)
+                          for r in recent_runs[:N]]
+
+    return render_template("v4_overview.html",
+                           testsuite_name=g.testsuite_name,
+                           active_machines=active_machines,
+                           active_submissions=active_submissions)
+
+ at v4_route("/machine/<id>")
+def v4_machine(id):
+    return "machine %d" % int(id)
+
+ at v4_route("/run/<id>")
+def v4_run(id):
+    return "run %d" % int(id)





More information about the llvm-commits mailing list