[llvm-commits] [zorg] r146402 - in /zorg/trunk/lnt/lnt/viewer: app.py publisher.py root.ptl simple.ptl zview/__init__.py zview/zviewui.ptl
Daniel Dunbar
daniel at zuster.org
Mon Dec 12 11:31:23 PST 2011
Author: ddunbar
Date: Mon Dec 12 13:31:23 2011
New Revision: 146402
URL: http://llvm.org/viewvc/llvm-project?rev=146402&view=rev
Log:
lnt.viewer: Start ripping out Quixote based UI.
Removed:
zorg/trunk/lnt/lnt/viewer/app.py
zorg/trunk/lnt/lnt/viewer/publisher.py
zorg/trunk/lnt/lnt/viewer/root.ptl
zorg/trunk/lnt/lnt/viewer/simple.ptl
zorg/trunk/lnt/lnt/viewer/zview/__init__.py
zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl
Removed: zorg/trunk/lnt/lnt/viewer/app.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/app.py?rev=146401&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/app.py (original)
+++ zorg/trunk/lnt/lnt/viewer/app.py (removed)
@@ -1,22 +0,0 @@
-import os
-import sys
-
-def create_publisher(configPath):
- import warnings
- warnings.simplefilter("ignore", category=DeprecationWarning)
-
- configData = {}
- exec open(configPath) in configData
-
- # Optionally enable auto-restart.
- if configData.get('wsgi_restart', False):
- from lnt.viewer import wsgi_restart
- wsgi_restart.track(configPath)
- wsgi_restart.start()
-
- from lnt.viewer import publisher
- return publisher.create_publisher(configPath, configData, threaded=True)
-
-def create_app(cfg_path=None):
- import quixote.wsgi
- return quixote.wsgi.QWIP(create_publisher(cfg_path))
Removed: zorg/trunk/lnt/lnt/viewer/publisher.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/publisher.py?rev=146401&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/publisher.py (original)
+++ zorg/trunk/lnt/lnt/viewer/publisher.py (removed)
@@ -1,48 +0,0 @@
-import time
-from quixote.publish import Publisher
-
-# FIXME: This is a bit of a hack.
-class ExtPublisher(Publisher):
- def __init__(self, *args, **kwargs):
- Publisher.__init__(self, *args, **kwargs)
- self.create_time = time.time()
-
- def process_request(self, request):
- request.start_time = time.time()
- return Publisher.process_request(self, request)
-
-class ThreadedPublisher(ExtPublisher):
- is_thread_safe = True
-
- def __init__ (self, root_namespace, *args, **kwargs):
- ExtPublisher.__init__(self, root_namespace, *args, **kwargs)
- self._request_dict = {}
-
- def _set_request(self, request):
- import thread
- self._request_dict[thread.get_ident()] = request
-
- def _clear_request(self):
- import thread
- try:
- del self._request_dict[thread.get_ident()]
- except KeyError:
- pass
-
- def get_request(self):
- import thread
- return self._request_dict.get(thread.get_ident())
-
-def create_publisher(configPath, configData, threaded=False):
- import Config
- config = Config.Config.fromData(configPath, configData)
-
- from quixote import enable_ptl
- enable_ptl()
-
- from root import RootDirectory
- if threaded:
- publisher_class = ThreadedPublisher
- else:
- publisher_class = ExtPublisher
- return publisher_class(RootDirectory(config), display_exceptions='plain')
Removed: zorg/trunk/lnt/lnt/viewer/root.ptl
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/root.ptl?rev=146401&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/root.ptl (original)
+++ zorg/trunk/lnt/lnt/viewer/root.ptl (removed)
@@ -1,418 +0,0 @@
-# -*- python -*-
-
-"""
-Root LNT webapp UI.
-"""
-
-import os
-import re
-import time
-
-import quixote
-import quixote.form
-import quixote.form.css
-import quixote.errors
-from quixote import get_response
-from quixote.directory import Directory, Resolving
-from quixote.util import StaticDirectory
-
-import lnt
-from lnt.db import perfdbsummary
-from lnt.util import json
-from lnt.db import perfdb
-from lnt.viewer import Util
-from lnt.db.perfdb import Machine, Run
-
-class RootDirectory(Resolving, Directory):
- _q_exports = ["", "resources", "js", "machines", "runs", "tests",
- "browse", "submitRun", "nightlytest", "simple", "zview",
-
- # Redirections.
- "select_db",
-
- ("favicon.ico", "favicon_ico")]
-
- def __init__(self, config, dbName='default', dbInfo=None, pathToRoot="./"):
- self.config = config
- self.dbName = dbName
- self.dbInfo = dbInfo
- if self.dbInfo is None:
- self.dbInfo = config.databases[dbName]
- self.pathToRoot = pathToRoot
- self.db_summary = None
-
- def getDB(self):
- db = perfdb.PerfDB(self.dbInfo.path)
-
- # Enable SQL logging with db_log.
- #
- # FIXME: Conditionalize on an is_production variable.
- request = quixote.get_request()
- if request.form.get('db_log'):
- import logging, StringIO
- request.db_log = StringIO.StringIO()
- logger = logging.getLogger("sqlalchemy")
- logger.addHandler(logging.StreamHandler(request.db_log))
- db.engine.echo = True
-
- return db
-
- def getHeader [html] (self, title, pathToRoot, components=None,
- addSorttableJS=True,
- addFormCSS=False,
- addPopupJS=False,
- addGraphJS=False,
- addJSScript=None,
- onload=None):
- pathToRoot = os.path.join(self.pathToRoot,
- pathToRoot)
-
- """
- <html>
- <head>
- """
- if addSorttableJS:
- """
- <script src="%s/resources/sorttable.js"></script>
- """ % (pathToRoot,)
- if addPopupJS:
- """
- <script src="%s/resources/popup.js"></script>
- """ % (pathToRoot,)
- if addGraphJS:
- """
- <script src="%s/js/View2D.js"></script>
- """ % pathToRoot
- if addJSScript:
- """\
-<script type="text/javascript">
-%s
-</script>
-""" % (addJSScript,)
-
- if components:
- component_title = ' : %s' %(
- ' : '.join(short_name for short_name,_ in components))
- else:
- component_title = ''
- """
- <link rel="stylesheet" href="%s/resources/style.css" type="text/css" />
- """ % (pathToRoot,)
- if addFormCSS:
- """
- <link rel="stylesheet" href="%s/resources/form.css" type="text/css" />
- """ % (pathToRoot,)
- """
- <link rel="icon" type="image/png" href="%s/favicon.ico">
- <title>%s%s - %s</title>
- </head>
- """ % (pathToRoot, self.config.name, component_title, title)
-
- """\
- <body"""
- if onload:
- """ onload="%s">""" % (onload,)
- else:
- """>"""
-
- # Database selection header.
- """\
- <div class="zorg_navheader">
- <form method="get" action="%s/select_db">
- <table style="padding:0.1em;" width="100%%">
- <tr>
- <td>
- <strong>
- [%s]
- </strong>
- </td>
- <td style="text-align:right;">
- <strong>Database:</strong>
- <select name="db" onchange="submit()">
- """ % (pathToRoot, self.dbName)
- for name in self.config.databases.keys():
- """\
- <option %s>%s</option>
- """ % (('', 'selected')[name == self.dbName],
- name)
- """\
- </select>
- <input type="submit" value="Go" />
- </td>
- </tr>
- </table>
- </form>
- </div>
- """
-
- if components is not None:
- """<h2><a href="%s">%s</a>""" % (pathToRoot, self.config.name)
- for short_name,path in components:
- """ : <a href="%s/db_%s/%s">%s</a>""" % (pathToRoot,self.dbName,
- path,short_name)
- """ - %s</h2>""" % title
-
- def getFooter [html] (self):
- db_log = getattr(quixote.get_request(), str('db_log'), None)
- if db_log:
- """<hr><h3>SQL Log</h3><pre>%s</pre>""" % db_log.getvalue()
-
- current = time.time()
- """
- <hr>
- LNT Version: %s<br>
- Server Started: %s<br>
- Generated: %s<br>
- Render Time: %.2fs<br>
- </body>
- </html>
- """ % (lnt.__version__,
- time.strftime(str('%Y-%m-%dT%H:%M:%Sz'),
- time.localtime(quixote.get_publisher().create_time)),
- time.strftime(str('%Y-%m-%dT%H:%M:%Sz'),
- time.localtime(current)),
- current - quixote.get_request().start_time)
-
- def get_db_summary(self, db):
- if not self.db_summary or not self.db_summary.is_up_to_date(db):
- self.db_summary = perfdbsummary.PerfDBSummary.fromdb(db)
- return self.db_summary
-
- def _q_index [html] (self):
- # Get a DB connection.
- db = self.getDB()
-
- self.getHeader("Overview", ".",
- components=(),)
-
- # Display available test result suites.
- summary = self.get_db_summary(db)
- """
- <h3>Test Results</h3>"""
- for suite in summary.suites:
- """
- <a href="%s">%s</a><br>""" % (os.path.join(*suite.path), suite.name)
-
- if self.dbInfo.showGeneral:
- """
- <hr>
-
- <h3>General Database Access</h3>
- <p><a href="browse">Browse DB</a>
- <p><a href="submitRun">Submit Run</a>
- """
-
- self.getFooter()
-
- def browse [html] (self):
- # Get a DB connection.
- db = self.getDB()
-
- self.getHeader("Database Browser", ".", components=(),
- addSorttableJS=False)
-
- # List machines.
- """
- <h3>Machines</h3>
- <table class="sortable" border=1 cellborder=1>
- <thead>
- <tr>
- <th>Name</th>
- </tr>
- </thead>
- """
- for m in db.machines():
- """
- <tr>
- <td><a href="machines/%d/">%s:%d</a></td>
- </tr>
- """ % (m.id, m.name, m.number)
- """
- </table>
- """
-
- # List runs.
- """
- <h3>Run List</h3>
- <table class="sortable" border=1 cellborder=1>
- <thead>
- <tr>
- <th>ID</th>
- <th>Machine</th>
- <th>Start Time</th>
- <th>End Time</th>
- </tr>
- </thead>
- """
- for r,m in db.session.query(Run,Machine).join(Machine):
- """
- <tr>
- <td><a href="runs/%d/">%d</a></td>
- <td><a href="machines/%d/">%s:%d</a></td>
- <td>%s</td>
- <td>%s</td>
- </tr>
- """ % (r.id, r.id,
- r.machine_id, m.name, m.number,
- r.start_time, r.end_time)
- """
- </table>
- """
-
-
- # List tests.
- """
- <h3>Test List</h3>
- <table class="sortable" border=1 cellborder=1>
- <thead>
- <tr>
- <th>ID</th>
- <th>Test</th>
- </tr>
- </thead>
- """
- for t in db.tests():
- """
- <tr>
- <td><a href="tests/%d/">%d</a></td>
- <td>%s</td>
- </tr>
- """ % (t.id, t.id, t.name)
- """
- </table>
- """
-
- self.getFooter()
-
- def submitRun(self):
- form = quixote.form.Form(enctype="multipart/form-data")
- form.add(quixote.form.FileWidget, "file",
- title="Input File (plist)")
- form.add(quixote.form.TextWidget, "input_data",
- title="Input Data (plist)")
- form.add(quixote.form.SingleSelectWidget, "commit",
- title="Commit", value="0",
- options=["0", "1"], required=True)
- form.add_submit("submit", "Submit")
-
- def render [html] ():
- self.getHeader("Submit Run", ".", components=(), addFormCSS=1)
- form.render()
- self.getFooter()
-
- if not form.is_submitted() or form.has_errors():
- return render()
-
- import plistlib
- import tempfile
- from lnt.util import ImportData
- from StringIO import StringIO
-
- commit = int(form.get_widget('commit').parse())
-
- # Get the input data.
- input_file = form.get_widget('file')
- file_value = input_file.parse()
-
- input_data = form.get_widget('input_data')
- data_value = input_data.parse()
-
- if ((file_value is None and data_value is None) or
- (file_value is not None and data_value is not None)):
- raise quixote.errors.QueryError(
- "Must supply either an input file or input text data")
-
- if file_value is not None:
- data_value = file_value.fp.read()
- file_value.fp.close()
-
- # Stash a copy of the raw submission.
- prefix = time.strftime("data-%Y-%m-%d_%H-%M-%S")
- fd,path = tempfile.mkstemp(prefix=prefix,
- suffix='.plist',
- dir=self.config.tempDir)
- os.write(fd, data_value)
- os.close(fd)
-
- # Get a DB connection.
- db = self.getDB()
-
- # Import the data.
- #
- # FIXME: Gracefully handle formats failures and DOS attempts. We
- # should at least reject overly large inputs.
- result = ImportData.import_and_report(
- self.config, self.dbName, db, path, '<auto>', commit)
-
- return json.dumps(result)
-
- def favicon_ico(self):
- response = get_response()
- response.set_content_type("image/x-icon")
- response.set_expires(days=1)
- return FAVICON
-
- def _q_resolve(self, component):
- if component == 'machines':
- import machines
- return machines.MachinesDirectory(self)
- if component == 'runs':
- import runs
- return runs.RunsDirectory(self)
- if component == 'tests':
- import tests
- return tests.TestsDirectory(self)
- if component == 'nightlytest':
- import nightlytest
- return nightlytest.NightlyTestDirectory(self)
- if component == 'simple':
- import simple
- return simple.RootDirectory(self)
- if component == 'zview':
- from zview import zviewui
- return zviewui.ZViewUI(self)
-
- def _q_lookup(self, component):
- if component.startswith('db_'):
- dbName = component[3:]
- dbInfo = self.config.databases.get(dbName)
- if dbInfo:
- return RootDirectory(self.config, dbName, dbInfo, "../")
-
- def select_db(self):
- request = quixote.get_request()
- dbName = request.form.get('db')
- return quixote.redirect("db_%s/" % (dbName,))
-
- resources = StaticDirectory(os.path.join(os.path.dirname(__file__),
- 'resources'),
- list_directory=True)
- js = StaticDirectory(os.path.join(os.path.dirname(__file__), 'js'),
- list_directory=True)
-
-FAVICON = """\
-AAABAAEAEBAAAAAAAABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAAAEAAAAAAAAAAAAAAAEA
-AAAAAAD///8AAAD/ALOz/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgEAAAAAAAAAAAAAAAAAAgECAQIAAAAAAAAAAAAAAAEA
-AAIBAQIAAAACAQIAAAECAAAAAAIBAQICAQIBAgECAAAAAAAAAAIBAQIAAAECAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=""".decode('base64')
Removed: zorg/trunk/lnt/lnt/viewer/simple.ptl
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/simple.ptl?rev=146401&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/simple.ptl (original)
+++ zorg/trunk/lnt/lnt/viewer/simple.ptl (removed)
@@ -1,953 +0,0 @@
-# -*- python -*-
-
-"""
-Nightly Test UI instance for actual nightly test data.
-"""
-
-import sys
-import time
-
-import quixote
-from quixote.directory import Directory
-from quixote.errors import TraversalError
-from quixote.html import htmltext
-
-from lnt.db import runinfo
-from lnt.db import perfdbsummary
-from lnt.util import stats
-from lnt.util import NTEmailReport
-from lnt.viewer import GraphUtil
-
-import Util
-from Util import safediv
-from NTUtil import *
-
-from lnt.db.perfdb import Machine, Run, RunInfo, Test
-
-class SimpleRunUI(Directory):
- _q_exports = ["", "graph", "report", "text_report"]
-
- def __init__(self, root, tag, idstr):
- self.root = root
- self.tag = tag
- try:
- self.id = int(idstr)
- except ValueError, exc:
- raise TraversalError(str(exc))
- self.popupDepth = 0
-
- def renderPopupBegin [html] (self, id, title, hidden):
- self.popupDepth += 1
- """\
- <p>
- <a href="javascript://" onclick="toggleLayer('%s')"; id="%s_">(%s) %s</a>
- <div id="%s" style="display: %s;" class="hideable_%d">
- """ % (id, id, ("+","-")[hidden], title, id, ("","none")[hidden],
- self.popupDepth)
-
- def renderPopupEnd [html] (self):
- """
- </div>"""
- self.popupDepth -= 1
-
- def getInfo(self, db):
- request = quixote.get_request()
-
- compareToID = request.form.get('compare', '')
- compareTo = None
- if compareToID:
- try:
- compareTo = db.getRun(int(compareToID))
- except:
- pass
-
- run = db.getRun(self.id)
-
- # Get the run summary which has run ordering information.
- run_summary = perfdbsummary.SimpleSuiteRunSummary.get_summary(db,
- self.tag)
-
- # Find previous run to compare to.
- if compareTo is None:
- id = run_summary.get_previous_run_on_machine(run.id)
- if id is not None:
- compareTo = db.getRun(id)
-
- return run, run_summary, compareTo
-
- def show_run_page [html] (self, db, run, run_summary, compare_to,
- contents_fn):
- machine = run.machine
-
- """
- <center>
- <table>
- <tr>
- <td align=right>Machine:</td>
- <td>%s:%d</td>
- </tr>
- <tr>
- <td align=right>Run:</td>
- <td>%s (%s)</td>
- </tr>
- """ % (machine.name, machine.number, run.start_time,
- run.info['run_order'].value)
- if compare_to:
- """
- <tr>
- <td align=right>Compare To:</td>
- <td>%s (%s)</td>
- </tr>
- """ % (compare_to.start_time, compare_to.info['run_order'].value)
- """
- </table>
- </center>
- <p>
- """
-
- """
- <table width="100%%" border=1>
- <tr>
- <td valign="top" width="200">
- <a href="..">Homepage</a>
- <h4>Machine:</h4>
- <a href="../machines/%d/">%s:%d</a>
- <h4>Runs:</h4>
- <ul>
- """ % (machine.id, machine.name, machine.number)
-
- # Show a small number of neighboring runs.
- cur_id = run.id
- for i in range(3):
- id = run_summary.get_next_run_on_machine(cur_id)
- if not id:
- break
- cur_id = id
- for i in range(6):
- r = db.getRun(cur_id)
- if r == run:
- """ <li> <h3><a href="../%d/">%s</a></h3> """ % (r.id,
- r.start_time)
- else:
- """ <li> <a href="../%d/">%s</a> """ % (r.id, r.start_time)
- cur_id = run_summary.get_previous_run_on_machine(cur_id)
- if cur_id is None:
- break
-
- """
- </ul>
- </td>
- <td valign="top">
- <table border=1>
- <tr>
- <td> <b>Nickname</b> </td>
- <td> %s </td>
- </tr>
- <tr>
- <td> <b>Machine ID</b> </td>
- <td> %d </td>
- </tr>
- </table>""" % (machine.name, machine.id)
-
- self.renderPopupBegin('machine_info', 'Machine Info', True)
- """
- <table border=1>"""
- info = machine.info.values()
- info.sort(key = lambda i: i.key)
- for mi in info:
- """
- <tr>
- <td> <b>%s</b> </td>
- <td>%s</td>
- </tr>
- """ % (mi.key, mi.value)
- """
- </table>"""
- self.renderPopupEnd()
-
- self.renderPopupBegin('run_info', 'Run Info', True)
- """
- <table border=1>"""
- info = run.info.values()
- info.sort(key = lambda i: i.key)
- for ri in info:
- """
- <tr>
- <td> <b>%s</b> </td>
- <td>%s</td>
- </tr>
- """ % (ri.key, ri.value)
- """
- </table>"""
- self.renderPopupEnd()
-
- contents_fn()
-
- """
- </td>
- </tr>
- </table>
- """
-
- self.root.getFooter()
-
- def _q_index [html] (self):
- # Get a DB connection.
- db = self.root.getDB()
-
- run,run_summary,compare_to = self.getInfo(db)
- machine = run.machine
-
- # Add JS to run the init_report function, if embedded.
- init = """\
- function init() {
- if (init_report) {
- init_report();
- }
- }
- """
- self.root.getHeader('Run Results', "../../..",
- components=((self.tag,
- '%s/%s' % ('simple',self.tag)),
- ('machine',
- 'simple/%s/machines/%d'%(self.tag,
- machine.id))),
- addPopupJS=True, addFormCSS=True, addGraphJS=True,
- addJSScript=init,
- onload="init()")
-
- self.show_run_page(db, run, run_summary, compare_to,
- lambda: self._q_index_body(db, run, run_summary,
- compare_to))
-
- def graph [html] (self):
- def init_form(form):
- # Add default fields, Quixote doesn't like missing values if the
- # form data exists.
- form['show_mad'] = form.get('show_mad') or '1'
- form['show_stddev'] = form.get('show_stddev') or '0'
- form['show_linear_regression'] = form.get(
- 'show_linear_regression') or '1'
-
- request = quixote.get_request()
- init_form(request.form)
-
- # Get the view options form.
- form = quixote.form.Form(method=str("get"))
- form.add(quixote.form.IntWidget, "show_mad", title="Show MAD")
- form.add(quixote.form.IntWidget, "show_stddev",
- title="Show Standard Deviation")
- form.add(quixote.form.IntWidget, "show_linear_regression",
- title="Show Linear Regression Line")
-
- # Add all the hidden fields.
- for name,value in request.form.items():
- if (name.startswith(str('test.')) or name.startswith(str('pset.'))):
- form.add(quixote.form.HiddenWidget, name, value)
-
- form.add_submit("submit", "Update")
-
- # Get the form values.
-
- # Get a DB connection.
- db = self.root.getDB()
-
- run,run_summary,compare_to = self.getInfo(db)
- machine = run.machine
-
- # Load the test suite summary.
- ts_summary = perfdbsummary.get_simple_suite_summary(db, self.tag)
-
- # Load the form data.
- show_mad = form.get('show_mad')
- show_stddev = form.get('show_stddev')
- show_linear_regression = form.get('show_linear_regression')
- graph_tests = []
- graph_psets = []
- for name,value in request.form.items():
- if name.startswith(str('test.')):
- graph_tests.append(name[5:])
- elif name.startswith(str('pset.')):
- graph_psets.append(ts_summary.parameter_sets[int(name[5:])])
-
- # Get the test ids we want data for.
- test_ids = [ts_summary.test_id_map[(name,pset)]
- for name in graph_tests
- for pset in graph_psets]
-
- # Build the graph data
- pset_id_map = dict([(pset,i)
- for i,pset in enumerate(ts_summary.parameter_sets)])
- legend = []
- num_points = 0
- plot_points = []
- plots = ""
- plots_iter = GraphUtil.get_test_plots(
- db, machine, test_ids, run_summary, ts_summary,
- show_mad_error = show_mad, show_stddev = show_stddev,
- show_linear_regression = show_linear_regression, show_points = True)
- for test_id, plot_js, col, points, ext_points in plots_iter:
- test = db.getTest(test_id)
- name = test.name
- pset = test.get_parameter_set()
-
- num_points += len(points)
- legend.append(("%s : P%d" % (name, pset_id_map[pset]), col))
- plots += plot_js
- plot_points.append(ext_points)
-
- def graph_body [html] ():
- # Show the view options form.
- self.renderPopupBegin('view_options', 'View Options', True)
- form.render()
- self.renderPopupEnd()
-
- """
- <h3>Graph</h3>
- <table>
- <tr>
- <td rowspan=2 valign="top">
- <canvas id="graph" width="600" height="400"></canvas>
- </td>
- <td valign="top">
- <table cellspacing=4 border=1>
- <tr><th colspan=2>Test</th></tr>
- """
- for name,col in legend:
- """
- <tr><td bgcolor="%02x%02x%02x"> </td>
- <td>%s</td></tr>""" % (255*col[0], 255*col[1], 255*col[2], name)
- """
- </table>
- </td></tr>
- <tr><td align="right" valign="bottom">
- <font size="-2">
- Shift-Left Mouse: Pan<br>
- Alt/Meta-Left Mouse: Zoom<br>
- Wheel: Zoom (<i>Shift Slows</i>)<br>
- </font>
- </td></tr>
- </table>
- <p>
- <b>Plots</b>: %d<br>
- <b>Num Points<b>: %d<br>
- """ % (len(test_ids), num_points)
-
- """
- <h2>Deltas</h2>"""
-
- resample_list = set()
- new_sample_list = []
- for (name,col),points in zip(legend,plot_points):
- """
- <h3>%s</h3>""" % name
- """
- <table>
- <tr>
- <th colspan=2>Revision</th>
- <th> </th>
- <th colspan=2>Value</th>
- <th></th>
- <th></th>
- <th colspan=2>MAD</th>
- <th colspan=2>Med - Min</th>
- <tr>
- <th>Current</th>
- <th>Previous</th>
- <th>Delta (%)</th>
- <th>Current</th>
- <th>Previous</th>
- <th># Revs</th>
- <th> </th>
- <th>Current</th>
- <th>Previous</th>
- <th>Current</th>
- <th>Previous</th>
- </tr>"""
- points.sort()
- deltas = [(Util.safediv(p1[1], p0[1]), p0, p1)
- for p0,p1 in Util.pairs(points)]
- deltas.sort()
- deltas.reverse()
- for (pct,(r0,t0,mad0,med0),(r1,t1,mad1,med1)) in deltas[:20]:
- """
- <tr>
- <td><a href="http://llvm.org/viewvc/llvm-project?view=rev&revision=%d">%d</a></td>
- <td><a href="http://llvm.org/viewvc/llvm-project?view=rev&revision=%d">%d</a></td>
- %s
- <td>%.4f</td><td>%.4f</td>
- <td>%d</td>
- <td> </td>
- <td>%.4f</td><td>%.4f</td>
- <td>%.4f</td><td>%.4f</td>
- </tr>
- """ % (r1, r1, r0, r0, Util.PctCell(pct, delta=True).render(),
- t1, t0, r1 - r0, mad1, mad0, med1-t1, med0-t0)
-
- # Find the best next revision to sample, unless we have
- # sampled to the limit. To conserve resources, we try to
- # align to the largest "nice" revision boundary that we can,
- # so that we tend to sample the same revisions, even as we
- # drill down.
- assert r0 < r1 and r0 != r1
- if r0 + 1 != r1:
- for align in [scale * boundary
- for scale in (100000,10000,1000,100,10,1)
- for boundary in (5, 1)]:
- r = r0 + 1 + (r1 - r0)//2
- r = (r // align) * align
- if r0 < r < r1:
- new_sample_list.append(r)
- break
-
- resample_list.add(r0)
- resample_list.add(r1)
- """
- </table>"""
-
- """
- <h3>Revisions to Sample</h3>
- %s
- <p>
- <h3>Revisions to Resample</h3>
- %s
- <p>""" % (' '.join(map(str, new_sample_list)),
- ' '.join(map(str, Util.sorted(resample_list))))
-
- # FIXME: Allow run_order to define this.
- xAxis_format = 'graph.xAxis.formats.normal'
- graph_init = """\
- function init() {
- graph = new Graph2D("graph");
- graph.clearColor = [1, 1, 1];
- %s
- graph.xAxis.format = %s;
- graph.draw();
- }
- """ % (plots,xAxis_format)
- self.root.getHeader('Run Results', "../../..",
- components=((self.tag,
- '%s/%s' % ('simple',self.tag)),
- ('machine',
- 'simple/%s/machines/%d' %(self.tag,
- machine.id)),
- ('run', 'simple/%s/%d' % (self.tag,
- run.id))),
- addPopupJS=True, addGraphJS=True,
- addJSScript=graph_init,
- onload="init()")
-
- self.show_run_page(db, run, run_summary, compare_to, graph_body)
-
- def report(self):
- db = self.root.getDB()
-
- request = quixote.get_request()
- show_graphs = bool(request.form.get('show_graphs'))
- run,run_summary,compare_to = self.getInfo(db)
-
- _, _, html_report = NTEmailReport.getSimpleReport(None,
- db, run, str("%s/db_%s/") % (self.root.config.zorgURL,
- self.root.dbName),
- True, True, show_graphs = show_graphs)
-
- return htmltext(html_report)
-
- def text_report(self):
- db = self.root.getDB()
-
- run,run_summary,compare_to = self.getInfo(db)
-
- _, text_report, _ = NTEmailReport.getSimpleReport(None,
- db, run, str("%s/db_%s/") % (self.root.config.zorgURL,
- self.root.dbName),
- True, True)
-
- response = quixote.get_response()
- response.set_content_type('text/plain')
-
- return text_report
-
- def _q_index_body [html] (self, db, run, run_summary, compare_to):
- # Get the test status style used in each run.
- run_status_kind = run_summary.get_run_status_kind(db, run.id)
- if compare_to:
- compare_to_status_kind = run_summary.get_run_status_kind(
- db, compare_to.id)
- else:
- compare_to_status_kind = None
-
- # Load the test suite summary.
- ts_summary = perfdbsummary.get_simple_suite_summary(db, self.tag)
- sri = runinfo.SimpleRunInfo(db, ts_summary)
-
- # Get the view options form.
- form = quixote.form.Form(method=str("get"))
- form.add(quixote.form.CheckboxWidget, "show_delta",
- title="Show Delta")
- form.add(quixote.form.CheckboxWidget, "show_stddev",
- title="Show Standard Deviation")
- form.add(quixote.form.CheckboxWidget, "show_mad",
- title="Show Median Absolute Deviation")
- form.add(quixote.form.CheckboxWidget, "show_all",
- title="Show All Values")
- form.add(quixote.form.CheckboxWidget, "show_all_samples",
- title="Show All Samples")
- form.add(quixote.form.CheckboxWidget, "show_sample_counts",
- title="Show Sample Counts")
- form.add(quixote.form.IntWidget, "num_comparison_runs",
- title="Number of Comparison Runs")
- form.add(quixote.form.CheckboxWidget, "show_graphs",
- title="Show Report Graphs")
- form.add_submit("submit", "Update")
-
- request = quixote.get_request()
- show_graphs = bool(form['show_graphs'])
- show_delta = bool(form['show_delta'])
- show_stddev = bool(form['show_stddev'])
- show_mad = bool(form['show_mad'])
- show_all = bool(form['show_all'])
- show_all_samples = bool(form['show_all_samples'])
- show_sample_counts = bool(form['show_sample_counts'])
- show_graphs = bool(form['show_graphs'])
- try:
- num_comparison_runs = int(form['num_comparison_runs'])
- except:
- num_comparison_runs = 10
-
- self.renderPopupBegin('view_options', 'View Options', True)
- form.render()
- self.renderPopupEnd()
-
- _, text_report, html_report = NTEmailReport.getSimpleReport(
- None, db, run, str("%s/db_%s/") % (self.root.config.zorgURL,
- self.root.dbName),
- True, True, only_html_body = True, show_graphs = show_graphs,
- num_comparison_runs = num_comparison_runs)
- self.renderPopupBegin('text_report', 'Report (Text)', True)
- """
- <pre>%s</pre>""" % (text_report,)
- self.renderPopupEnd()
-
- self.renderPopupBegin('html_report', 'Report (HTML)', False)
- htmltext(html_report)
- self.renderPopupEnd()
-
- # Get the list of tests we are interested in.
- interesting_runs = [run.id]
- if compare_to:
- interesting_runs.append(compare_to.id)
- test_names = ts_summary.get_test_names_in_runs(db, interesting_runs)
-
- # Gather the runs to use for statistical data, if enabled.
- cur_id = run.id
- comparison_window = []
- for i in range(num_comparison_runs):
- cur_id = run_summary.get_previous_run_on_machine(cur_id)
- if not cur_id:
- break
- comparison_window.append(cur_id)
-
- # Render the page.
- def get_cell_value [html] (cr):
- test_status = cr.get_test_status()
- value_status = cr.get_value_status()
-
- run_cell_value = "-"
- if cr.current is not None:
- run_cell_value = "%.4f" % cr.current
-
- cell_color = None
- if test_status == runinfo.REGRESSED:
- cell_color = (233,128,128)
- elif test_status == runinfo.IMPROVED:
- cell_color = (143,223,95)
- elif test_status == runinfo.UNCHANGED_FAIL:
- cell_color = (255,195,67)
-
- if cell_color:
- """
- <td bgcolor="#%02x%02x%02x">%s</td>""" % (
- cell_color[0], cell_color[1], cell_color[2], run_cell_value)
- else:
- """
- <td>%s</td>""" % (run_cell_value,)
-
- if show_all or value_status in (runinfo.REGRESSED,
- runinfo.IMPROVED):
- Util.PctCell(cr.pct_delta).render()
- else:
- """<td>-</td>"""
-
- if show_delta:
- if cr.delta is not None:
- """<td>%.4f</td>""" % cr.delta
- else:
- """<td>-</td>"""
- if show_stddev:
- if cr.stddev is not None:
- """<td>%.4f</td>""" % cr.stddev
- else:
- """<td>-</td>"""
- if show_mad:
- if cr.MAD is not None:
- """<td>%.4f</td>""" % cr.MAD
- else:
- """<td>-</td>"""
-
- if show_all_samples:
- """<td>[%s]</td>""" % (", ".join("%.4f" % v
- for v in cr.get_samples()),)
-
- if show_sample_counts:
- """<td>%d</td>""" % len(cr.get_samples())
-
-
- """
- <h3>Parameter Sets</h3>
- <table border=1>
- <tr>
- <th rowspan=2>Name</th>
- <th colspan=%d>Parameters</th>
- </tr><tr>""" % len(ts_summary.parameter_sets)
- for key in ts_summary.parameter_keys:
- """
- <th>%s</th>""" % key
- """
- </tr>"""
- for (i,pset) in enumerate(ts_summary.parameter_sets):
- """
- <tr>
- <td>P%s</td>""" % (i,)
- pmap = dict(pset)
- for key in ts_summary.parameter_keys:
- item = pmap.get(key)
- if item is None:
- item = "-"
- """
- <td>%s</td>""" % item
- """
- </tr>"""
- """
- </table>"""
-
- """
- <h3>Tests</h3>"""
-
- pset_cols = (2 + show_delta + show_stddev + show_mad +
- show_all_samples + show_sample_counts)
- """
- <form method="GET" action="graph">
- <table class="sortable" border=1>
- <thead>
- <tr>
- <th rowspan="1"></th><th rowspan="1">Name</th>"""
- for i in range(len(ts_summary.parameter_sets)):
- """<th colspan=%d>P%d</th>
- """ % (pset_cols, i)
- """
- </tr><tr><th></th><th></th>"""
- for i in range(len(ts_summary.parameter_sets)):
- """
- <th><input type="checkbox" name="pset.%d" value="on" checked></th>
- <th>%%</th>""" % i
- if show_delta:
- """
- <th>Δ</th>"""
- if show_stddev:
- """
- <th>σ</th>"""
- if show_mad:
- """
- <th>MAD</th>"""
- if show_all_samples:
- """
- <th>Samples</th>"""
- if show_sample_counts:
- """
- <th>N</th>"""
- """
- </tr>
- </thead>"""
- for name in test_names:
- """
- <tr>
- <td><input type="checkbox" name="test.%s"></td>
- <td>%s</td>""" % (name, name)
- for pset in ts_summary.parameter_sets:
- cr = sri.get_run_comparison_result(
- run, run_status_kind, compare_to, compare_to_status_kind,
- name, pset, comparison_window)
- get_cell_value(cr)
- """
- </tr>"""
- """
- </table>
- <input type="submit" value="Graph">
- </form>"""
-
-class MachineUI(Directory):
- _q_exports = [""]
-
- def __init__(self, root, parent, idstr):
- self.root = root
- self.parent = parent
- try:
- self.id = int(idstr)
- except ValueError, exc:
- raise TraversalError(str(exc))
- self.popupDepth = 0
-
- def renderPopupBegin [html] (self, id, title, hidden):
- self.popupDepth += 1
- """\
- <p>
- <a href="javascript://" onclick="toggleLayer('%s')"; id="%s_">(%s) %s</a>
- <div id="%s" style="display: %s;" class="hideable_%d">
- """ % (id, id, ("+","-")[hidden], title, id, ("","none")[hidden],
- self.popupDepth)
-
- def renderPopupEnd [html] (self):
- """
- </div>"""
- self.popupDepth -= 1
-
- def _q_index [html] (self):
- # Get a DB connection.
- db = self.root.getDB()
-
- machine = db.getMachine(self.id)
-
- self.root.getHeader("Machine: %s:%d" % (machine.name,machine.number),
- "%s/../.." % self.parent.root_path,
- components=self.parent.components,
- addPopupJS=True)
-
- # Get the run summary which has run ordering information.
- run_summary = perfdbsummary.SimpleSuiteRunSummary.get_summary(
- db, self.parent.tag)
-
- """
- <table width="100%%" border=1>
- <tr>
- <td valign="top" width="200">
- <a href="../..">Homepage</a>
- <h4>Relatives:</h4>
- <ul>
- """
- # List all machines with this name.
- for m in db.machines(name=machine.name):
- """<li><a href="../%d">%s:%d</a></li>""" % (m.id, m.name, m.number)
- """
- </ul>
- </td>
- <td valign="top">
- <table border=1>
- <tr>
- <td> <b>Nickname</b> </td>
- <td> %s </td>
- </tr>
- <tr>
- <td> <b>Machine ID</b> </td>
- <td> %d </td>
- </tr>
- </table>""" % (machine.name, machine.id)
- self.renderPopupBegin('machine_info', 'Machine Info', True)
- """
- <table border=1>"""
- info = machine.info.values()
- info.sort(key = lambda i: i.key)
- for mi in info:
- """
- <tr>
- <td> <b>%s</b> </td>
- <td>%s</td>
- </tr>""" % (mi.key, mi.value)
- """
- </table>"""
- self.renderPopupEnd()
-
- # List associated runs.
- run_info = db.session.query(Run.id, Run.start_time, Run.end_time).\
- filter(Run.machine_id == machine.id).\
- filter(Run.id.in_(run_summary.runs_in_order)).all()
- run_info_map = dict((id,(start_time,end_time))
- for id,start_time,end_time in run_info)
- """
- <p>
- <table class="sortable" border=1>
- <thead>
- <tr>
- <th>Run Order</th>
- <th>Start Time</th>
- <th>End Time</th>
- <th> </th>
- </tr>
- </thead>
- """
- for order in run_summary.run_orders:
- run_ids = [id for id in run_summary.runs_by_order[order]
- if id in run_info_map]
- if not run_ids:
- continue
-
- """
- <tr>
- <td rowspan="%d" align=right>%s</td>""" % (len(run_ids), order)
- for run_id in run_ids:
- start_time,end_time = run_info_map[run_id]
- if run_id != run_ids[0]:
- """<tr>"""
- """
- <td>%s</td>
- <td>%s</td>
- <td><a href="../../%d">View Results</a></td>
- </tr>""" % (start_time, end_time, run_id)
- """
- </table>"""
-
- """
- </td>
- </tr>
- </table>"""
-
- self.root.getFooter()
-
-class MachinesDirectory(Directory):
- _q_exports = [""]
-
- def __init__(self, parent):
- Directory.__init__(self)
- self.parent = parent
-
- def _q_index [plain] (self):
- """
- machine access
- """
-
- def _q_lookup(self, component):
- return MachineUI(self.parent.root, self.parent, component)
-
-
-class TagRootDirectory(Directory):
- _q_exports = [""]
-
- def __init__(self, root, tag):
- Directory.__init__(self)
- self.tag = tag
- self.root = root
- self.root_path = '../..'
- self.components = ((self.tag, '%s/%s' % ('simple',self.tag)),)
-
- def getTags(self):
- return (self.tag,)
-
- def _q_index [plain] (self):
- # Get a DB connection
- db = self.root.getDB()
-
- self.root.getHeader('Overview', self.root_path, self.components)
-
- # Find recent runs.
- """
- <center><h3>Submission Overview</h3></center>
- <table width="100%%">
- <tr>
- <td valign="top" width="50%">
- <center>
- <h3>Test Machines</h3>
- <table class="sortable" border=1>
- <thead>
- <tr>
- <th>Latest Submission</th>
- <th>Machine</th>
- <th>Results</th>
- </tr>
- </thead>
- """
-
- # Show the most recent entry for each machine.
- q = db.session.query(Machine.name).distinct().order_by(Machine.name)
- for name, in q:
- # Get the most recent run for this machine name.
- q = db.session.query(Run).join(Machine).filter(Machine.name == name)
- r = q.order_by(Run.start_time.desc()).first()
-
- # Limit by matching tags.
- if 'tag' in r.info:
- tag = r.info['tag'].value
- else:
- tag = None
- if tag not in self.getTags():
- continue
-
- """
- <tr>
- <td>%s</td>
- <td align=left><a href="machines/%d/">%s:%d</a></td>
- <td><a href="%d/">View Results</a></td>
- </tr>
- """ % (r.start_time, r.machine.id, r.machine.name,
- r.machine.number, r.id)
-
- """
- </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 20 most recent submissions, ordered by time.
- for r in db.session.query(Run).order_by(Run.start_time.desc())[:20]:
- # Limit by matching tags.
- if 'tag' not in r.info or 'run_order' not in r.info:
- continue
- if tag not in self.getTags():
- continue
-
- m = r.machine
- """
- <tr>
- <td>%s</td>
- <td>%s</td>
- <td>%s</td>
- <td align=left><a href="machines/%d/">%s:%d</a></td>
- <td><a href="%d/">View Results</a></td>
- </tr>
- """ % (r.info['run_order'].value, r.start_time, r.end_time, m.id,
- m.name, m.number, r.id)
-
- """
- </table>
- </center>
- </td>
- </tr>
- </table>
- """
-
- self.root.getFooter()
-
- def _q_lookup(self, component):
- if component == 'machines':
- return MachinesDirectory(self)
- return SimpleRunUI(self.root, self.tag, component)
-
-class RootDirectory(Directory):
- def __init__(self, root):
- Directory.__init__(self)
- self.root = root
-
- def _q_lookup(self, component):
- return TagRootDirectory(self.root, component)
Removed: zorg/trunk/lnt/lnt/viewer/zview/__init__.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/zview/__init__.py?rev=146401&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/zview/__init__.py (original)
+++ zorg/trunk/lnt/lnt/viewer/zview/__init__.py (removed)
@@ -1 +0,0 @@
-__all__ = []
Removed: zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl?rev=146401&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl (original)
+++ zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl (removed)
@@ -1,217 +0,0 @@
-# -*- python -*-
-
-"""
-Playground for AJAXy interface to nightly test data.
-"""
-
-from quixote.directory import Directory
-from quixote.html import htmltext
-
-from lnt.db.perfdb import Machine, Run, Sample, Test
-from lnt.viewer import NTUtil
-
-from sqlalchemy import func
-
-try:
- import json
-except ImportError:
- import simplejson as json
-
-class ZViewUI(Directory):
- _q_exports = ["", "get_machines", "get_tests", "get_test_data",
- "get_test_names"]
-
- def __init__(self, root):
- self.root = root
-
- def get_machines(self):
- db = self.root.getDB()
- q = db.session.query(Machine.name.distinct())
- q = q.order_by(Machine.name)
- return json.dumps(q.all())
-
- def get_tests(self):
- db = self.root.getDB()
- q = db.session.query(Test.id, Test.name)
- q = q.order_by([Test.name])
- return json.dumps(q.all())
-
- def get_test_data(self):
- import quixote, time
- from sqlalchemy import orm
-
- request = quixote.get_request()
- machine_name = str(request.form.get('machine_name'))
- test_name = str(request.form.get('test_name'))
- component = str(request.form.get('component'))
-
- full_test_name = 'nightlytest.' + test_name + '.' + component
-
- # FIXME: Return data about machine crossings.
- db = self.root.getDB()
- q = db.session.query(Test.id).filter(Test.name == full_test_name)
- q = db.session.query(Run.start_time, Sample.value)
- q = q.join(Sample).join(Test)
- q = q.filter(Test.name == full_test_name)
- q = q.join(Machine)
- q = q.filter(Machine.name == machine_name)
- q = q.order_by(Run.start_time.desc())
- return json.dumps([(time.mktime(run_time.timetuple()), value)
- for run_time,value in q])
-
- def get_test_names(self):
- # FIXME: We should fix the DB to be able to do this directly.
- left = NTUtil.kPrefix + '.'
- right = '.' + NTUtil.kSentinelKeyName
- f = func.substr(Test.name, len(left) + 1,
- func.length(Test.name) - len(left) - len(right))
-
- db = self.root.getDB()
- q = db.session.query(f)
- q = q.filter(Test.name.startswith(left))
- q = q.filter(Test.name.endswith(right))
- q = q.order_by(Test.name.desc())
- return json.dumps(q.all())
-
- def _q_index [html] (self):
- db = self.root.getDB()
-
- script = """
-machines = null;
-tests = null;
-graph = null;
-active_test_data = null;
-
-function update_machine_list(data, text) {
- machines = data;
-
- var elt = $('test_select_form_machine');
- elt.length = data.length;
- for (var i = 0; i != data.length; ++i) {
- elt[i].value = data[i];
- elt[i].text = data[i];
- }
-
- handle_test_change();
-}
-
-function update_test_list(data, text) {
- tests = data;
-
- var elt = $('test_select_form_test');
- elt.length = data.length;
- for (var i = 0; i != data.length; ++i) {
- elt[i].value = data[i];
- elt[i].text = data[i];
- }
-
- handle_test_change();
-}
-
-function update_graph() {
- update_selected_status();
-
- graph.clearPlots();
- if (active_test_data && active_test_data.length) {
- graph.clearColor = [1, 1, 1];
- graph.addPlot(active_test_data, new Graph2D_LinePlotStyle(1, [0,0,0]));
- } else {
- graph.clearColor = [1, .8, .8];
- }
- graph.draw();
-}
-
-function update_selected_status() {
- var machine_elt = $('test_select_form_machine');
- var test_elt = $('test_select_form_test');
- var machine = machines && machines[machine_elt.selectedIndex];
- var test = tests && tests[test_elt.selectedIndex];
- var numPts = active_test_data && active_test_data.length;
- $('log').innerHTML = "<b>Machine:</b> " + machine + "<br>" +
- "<b>Test:</b> " + test + "<br>" +
- "<b>Num Points:</b> " + numPts;
-}
-
-function handle_test_change() {
- if (machines === null || tests === null)
- return;
-
- var machine_elt = $('test_select_form_machine');
- var test_elt = $('test_select_form_test');
- var machine = machines[machine_elt.selectedIndex];
- var test = tests[test_elt.selectedIndex];
- var component = $('test_select_form_component').value;
-
- new Request.JSON({
- url: 'get_test_data',
- method: 'get',
- onSuccess: function(data, text) {
- active_test_data = data;
- update_graph();
- },
- data: "machine_name=" + encodeURIComponent(machine) + "&" +
- "test_name=" + encodeURIComponent(test) + "&" +
- "component=" + component,
- }).send();
-}
-
-function init() {
- // Initialize the graph object.
- graph = new Graph2D("graph");
- graph.xAxis.format = graph.xAxis.formats.day;
- update_graph();
-
- // Load the machine lists.
- new Request.JSON({
- url: 'get_machines',
- onSuccess: update_machine_list,
- }).send();
-
- // Load the test list.
- new Request.JSON({
- url: 'get_test_names',
- onSuccess: update_test_list,
- }).send();
-}
-""" % locals()
-
- self.root.getHeader("ZView", "..", components=(),
- addGraphJS=True, addJSScript=script,
- onload='init()')
-
- """
- <h3>Test Selection</h3>
- <form id="test_select_form">
- <p>Machine: <select id="test_select_form_machine"
- onChange="handle_test_change();">
- <option value="">Loading...</option>
- </select></p>
-
- <p>Test: <select id="test_select_form_test"
- onChange="handle_test_change();">
- <option value="">Loading...</option>
- </select></p>
-
- <p>Component: <select id="test_select_form_component"
- onChange="handle_test_change();">
- """
- for name,key in NTUtil.kComparisonKinds:
- if key is None:
- continue
- """<option value="%s">%s</option>""" % (key, name)
- """
- </select></p>
- </form>
-
- <h3>Selected Test</h3>
- <div id="log">
- <p>Waiting...</p>
- </div>
-
- <h3>Graph</h3>
- <div id="log">
- <canvas id="graph" width="600" height="400"></canvas>
- </div>
- """
-
- self.root.getFooter()
More information about the llvm-commits
mailing list