[llvm-commits] [zorg] r110924 - in /zorg/trunk/lnt/lnt: lnttool/import_data.py util/ImportData.py viewer/root.ptl
Daniel Dunbar
daniel at zuster.org
Thu Aug 12 09:03:50 PDT 2010
Author: ddunbar
Date: Thu Aug 12 11:03:50 2010
New Revision: 110924
URL: http://llvm.org/viewvc/llvm-project?rev=110924&view=rev
Log:
LNT: Change submission to return the result as an unstructured dictionary of
results, which we send back as JSON when submitting remotely.
Modified:
zorg/trunk/lnt/lnt/lnttool/import_data.py
zorg/trunk/lnt/lnt/util/ImportData.py
zorg/trunk/lnt/lnt/viewer/root.ptl
Modified: zorg/trunk/lnt/lnt/lnttool/import_data.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/lnttool/import_data.py?rev=110924&r1=110923&r2=110924&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/lnttool/import_data.py (original)
+++ zorg/trunk/lnt/lnt/lnttool/import_data.py Thu Aug 12 11:03:50 2010
@@ -1,4 +1,4 @@
-import os, sys, time
+import os, pprint, sys, time
from lnt import formats
from lnt.viewer import Config, PerfDB
@@ -49,7 +49,9 @@
# Load the database.
db = PerfDB.PerfDB(db_entry.path, echo=opts.showSQL)
for file in args:
- success, run = ImportData.import_and_report(
- config, opts.database, db, file, sys.stdout,
+ result = ImportData.import_and_report(
+ config, opts.database, db, file,
opts.format, opts.commit, opts.showSampleCount,
opts.noEmail)
+
+ pprint.pprint(result)
Modified: zorg/trunk/lnt/lnt/util/ImportData.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/ImportData.py?rev=110924&r1=110923&r2=110924&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/util/ImportData.py (original)
+++ zorg/trunk/lnt/lnt/util/ImportData.py Thu Aug 12 11:03:50 2010
@@ -4,17 +4,20 @@
from lnt.viewer import PerfDB
from lnt.util import NTEmailReport
-def import_and_report(config, db_name, db, file, log, format, commit=False,
+def import_and_report(config, db_name, db, file, format, commit=False,
show_sample_count=False, disable_email=False):
"""
- import_and_report(config, db_name, db, file, log, format,
+ import_and_report(config, db_name, db, file, format,
[commit], [show_sample_count],
- [disable_email]) -> (success, run)
+ [disable_email]) -> ... object ...
Import a test data file into an LNT server and generate a test report. On
success, run is the newly imported run. Note that success is uneffected by
the value of commit, this merely changes whether the run (on success) is
committed to the database.
+
+ The result object is a dictionary containing information on the imported run
+ and its comparison to the previous run.
"""
numMachines = db.getNumMachines()
numRuns = db.getNumRuns()
@@ -24,7 +27,11 @@
if show_sample_count:
numSamples = db.getNumSamples()
- print >>log, 'IMPORT: %s' % file
+ result = {}
+ result['success'] = False
+ result['error'] = None
+ result['import_file'] = file
+
startTime = time.time()
try:
data = formats.read_any(file, format)
@@ -32,10 +39,10 @@
raise
except:
import traceback
- print >>log, 'ERROR: %r: load failed' % file
- print >>log, traceback.format_exc()
- return (False, None)
- print >>log, ' LOAD TIME: %.2fs' % (time.time() - startTime,)
+ result['error'] = "load failure: %s" % traceback.format_exc()
+ return result
+
+ result['load_time'] = time.time() - startTime
# Find the email address for this machine's results.
toAddress = None
@@ -45,9 +52,9 @@
machineName = str(data.get('Machine',{}).get('Name'))
toAddress = email_config.get_to_address(machineName)
if toAddress is None:
- print >>log,("ERROR: unable to match machine name "
- "for test results email address!")
- return (False, None)
+ result['error'] = ("unable to match machine name "
+ "for test results email address!")
+ return result
importStartTime = time.time()
try:
@@ -56,41 +63,34 @@
raise
except:
import traceback
- print >>log, 'ERROR: %r: import failed' % file
- print >>log, traceback.format_exc()
- return (False, None)
+ result['error'] = "import failure: %s" % traceback.format_exc()
+ return result
- print >>log, ' IMPORT TIME: %.2fs' % (time.time() - importStartTime,)
+ result['db_import_time'] = time.time() - importStartTime
if not success:
- print >>log, " IGNORING DUPLICATE RUN"
- print >>log, " MACHINE: %d" % (run.machine_id, )
- print >>log, " START : %s" % (run.start_time, )
- print >>log, " END : %s" % (run.end_time, )
- for ri in run.info.values():
- print >>log, " INFO : %r = %r" % (ri.key, ri.value)
+ # Record the original run this is a duplicate of.
+ result['original_run'] = run.id
if not disable_email and toAddress is not None:
- print >>log, "\nMAILING RESULTS TO: %r\n" % toAddress
+ result['report_to_address'] = toAddress
NTEmailReport.emailReport(db, run,
"%s/db_%s/" % (config.zorgURL, db_name),
email_config.host, email_config.from_address,
toAddress, success, commit)
- print >>log, "ADDED: %d machines" % (db.getNumMachines() - numMachines,)
- print >>log, "ADDED: %d runs" % (db.getNumRuns() - numRuns,)
- print >>log, "ADDED: %d tests" % (db.getNumTests() - numTests,)
+ result['added_machines'] = db.getNumMachines() - numMachines
+ result['added_runs'] = db.getNumRuns() - numRuns
+ result['added_tests'] = db.getNumTests() - numTests
if show_sample_count:
- print >>log, "ADDED: %d samples" % (db.getNumSamples() - numSamples)
+ result['added_samples'] = db.getNumSamples() - numSamples
+ result['committed'] = commit
if commit:
- print >>log, 'COMMITTING RESULT:',
db.commit()
- print >>log, 'DONE'
else:
- print >>log, 'DISCARDING RESULT:',
db.rollback()
- print >>log, 'DONE'
- print >>log, 'TOTAL IMPORT TIME: %.2fs' % (time.time() - startTime,)
+ result['import_time'] = time.time() - startTime
- return (success, run)
+ result['success'] = True
+ return result
Modified: zorg/trunk/lnt/lnt/viewer/root.ptl
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/root.ptl?rev=110924&r1=110923&r2=110924&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/root.ptl (original)
+++ zorg/trunk/lnt/lnt/viewer/root.ptl Thu Aug 12 11:03:50 2010
@@ -18,6 +18,7 @@
import lnt
from lnt.db import perfdbsummary
+from lnt.util import json
from lnt.viewer import PerfDB, Util
from lnt.viewer.PerfDB import Machine, Run
@@ -298,14 +299,6 @@
form.render()
self.getFooter()
- def result [plain] (success, run, log):
- """\
-STATUS: %d
-
-OUTPUT:
-%s
-""" % (not run, log.getvalue())
-
if not form.is_submitted() or form.has_errors():
return render()
@@ -347,11 +340,10 @@
#
# FIXME: Gracefully handle formats failures and DOS attempts. We
# should at least reject overly large inputs.
- log = StringIO()
- success, run = ImportData.import_and_report(
- self.config, self.dbName, db, path, log, '<auto>', commit)
+ result = ImportData.import_and_report(
+ self.config, self.dbName, db, path, '<auto>', commit)
- return result(success, run, log)
+ return json.dumps(result)
def favicon_ico(self):
response = get_response()
More information about the llvm-commits
mailing list