[llvm-commits] [zorg] r130215 - in /zorg/trunk/lnt: lnt/db/perfdb.py lnt/db/perfdbsummary.py lnt/db/runinfo.py lnt/lnttool/__init__.py lnt/lnttool/create.py lnt/lnttool/import_data.py lnt/server/ui/app.py lnt/util/ImportData.py lnt/util/NTEmailReport.py lnt/viewer/GraphUtil.py lnt/viewer/NTStyleBrowser.ptl lnt/viewer/NTUtil.py lnt/viewer/PerfDB.py lnt/viewer/nightlytest.ptl lnt/viewer/root.ptl lnt/viewer/simple.ptl lnt/viewer/zview/zviewui.ptl tests/DB/Create.py tests/DB/Import.py
Daniel Dunbar
daniel at zuster.org
Tue Apr 26 10:48:05 PDT 2011
Author: ddunbar
Date: Tue Apr 26 12:48:04 2011
New Revision: 130215
URL: http://llvm.org/viewvc/llvm-project?rev=130215&view=rev
Log:
LNT: Move viewer.PerfDB -> db.perfdb.
Added:
zorg/trunk/lnt/lnt/db/perfdb.py
- copied, changed from r130214, zorg/trunk/lnt/lnt/viewer/PerfDB.py
Removed:
zorg/trunk/lnt/lnt/viewer/PerfDB.py
Modified:
zorg/trunk/lnt/lnt/db/perfdbsummary.py
zorg/trunk/lnt/lnt/db/runinfo.py
zorg/trunk/lnt/lnt/lnttool/__init__.py
zorg/trunk/lnt/lnt/lnttool/create.py
zorg/trunk/lnt/lnt/lnttool/import_data.py
zorg/trunk/lnt/lnt/server/ui/app.py
zorg/trunk/lnt/lnt/util/ImportData.py
zorg/trunk/lnt/lnt/util/NTEmailReport.py
zorg/trunk/lnt/lnt/viewer/GraphUtil.py
zorg/trunk/lnt/lnt/viewer/NTStyleBrowser.ptl
zorg/trunk/lnt/lnt/viewer/NTUtil.py
zorg/trunk/lnt/lnt/viewer/nightlytest.ptl
zorg/trunk/lnt/lnt/viewer/root.ptl
zorg/trunk/lnt/lnt/viewer/simple.ptl
zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl
zorg/trunk/lnt/tests/DB/Create.py
zorg/trunk/lnt/tests/DB/Import.py
Copied: zorg/trunk/lnt/lnt/db/perfdb.py (from r130214, zorg/trunk/lnt/lnt/viewer/PerfDB.py)
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/db/perfdb.py?p2=zorg/trunk/lnt/lnt/db/perfdb.py&p1=zorg/trunk/lnt/lnt/viewer/PerfDB.py&r1=130214&r2=130215&rev=130215&view=diff
==============================================================================
(empty)
Modified: zorg/trunk/lnt/lnt/db/perfdbsummary.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/db/perfdbsummary.py?rev=130215&r1=130214&r2=130215&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/db/perfdbsummary.py (original)
+++ zorg/trunk/lnt/lnt/db/perfdbsummary.py Tue Apr 26 12:48:04 2011
@@ -2,7 +2,7 @@
Classes for caching metadata about a PerfDB instance.
"""
-from lnt.viewer.PerfDB import Run, RunInfo, Sample, Test
+from lnt.db.perfdb import Run, RunInfo, Sample, Test
class SuiteSummary:
def __init__(self, name, path):
Modified: zorg/trunk/lnt/lnt/db/runinfo.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/db/runinfo.py?rev=130215&r1=130214&r2=130215&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/db/runinfo.py (original)
+++ zorg/trunk/lnt/lnt/db/runinfo.py Tue Apr 26 12:48:04 2011
@@ -1,6 +1,6 @@
from lnt.util import stats
from lnt.viewer import Util
-from lnt.viewer.PerfDB import Sample
+from lnt.db.perfdb import Sample
from lnt.testing import PASS, FAIL, XFAIL
REGRESSED = 'REGRESSED'
Modified: zorg/trunk/lnt/lnt/lnttool/__init__.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/lnttool/__init__.py?rev=130215&r1=130214&r2=130215&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/lnttool/__init__.py (original)
+++ zorg/trunk/lnt/lnt/lnttool/__init__.py Tue Apr 26 12:48:04 2011
@@ -6,6 +6,7 @@
import StringIO
from lnt import testing
+from lnt.db import perfdb
def action_runserver(name, args):
"""start a new development server"""
@@ -78,10 +79,8 @@
if len(args) != 1:
parser.error("incorrect number of argments")
- from lnt.viewer import PerfDB
-
path, = args
- db = PerfDB.PerfDB('sqlite:///%s' % path)
+ db = perfdb.PerfDB('sqlite:///%s' % path)
db.commit()
def action_checkformat(name, args):
@@ -102,12 +101,11 @@
input = StringIO.StringIO(sys.stdin.read())
from lnt import formats
- from lnt.viewer import PerfDB
- db = PerfDB.PerfDB('sqlite:///:memory:')
+ db = perfdb.PerfDB('sqlite:///:memory:')
data = formats.read_any(input, '<auto>')
- PerfDB.importDataFromDict(db, data)
+ perfdb.importDataFromDict(db, data)
def action_runtest(name, args):
"""run a builtin test application"""
@@ -159,7 +157,7 @@
tmp.flush()
# Construct a temporary database and import the result.
- db = lnt.viewer.PerfDB.PerfDB("sqlite:///:memory:")
+ db = lnt.db.perfdb.PerfDB("sqlite:///:memory:")
result = ImportData.import_and_report(
None, None, db, tmp.name, 'json', commit = True)
ImportData.print_report_result(result, sys.stdout, opts.verbose)
@@ -203,8 +201,7 @@
ServerUtil.submitFiles(args[0], args[1:], opts.commit, opts.verbose)
from lnt.db import perfdbsummary, runinfo
-from lnt.viewer import PerfDB
-from lnt.viewer.PerfDB import Run, Machine, Sample, Test
+from lnt.db.perfdb import Run, Machine, Sample, Test
from lnt.util import stats
def print_table(rows):
@@ -238,7 +235,7 @@
parser.error("incorrect number of argments")
path,machine = args
- db = PerfDB.PerfDB('sqlite:///%s' % path)
+ db = perfdb.PerfDB('sqlite:///%s' % path)
# FIXME: Argument
tag = "nts"
Modified: zorg/trunk/lnt/lnt/lnttool/create.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/lnttool/create.py?rev=130215&r1=130214&r2=130215&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/lnttool/create.py (original)
+++ zorg/trunk/lnt/lnt/lnttool/create.py Tue Apr 26 12:48:04 2011
@@ -73,6 +73,8 @@
###
+import lnt.db.perfdb
+
def action_create(name, args):
"""create an LLVM nightly test installation"""
@@ -137,8 +139,7 @@
wsgi_file.write(kWSGITemplate % locals())
wsgi_file.close()
- from lnt.viewer import PerfDB
- db = PerfDB.PerfDB('sqlite:///' + db_path)
+ db = lnt.db.perfdb.PerfDB('sqlite:///' + db_path)
db.commit()
print 'created LNT configuration in %r' % basepath
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=130215&r1=130214&r2=130215&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/lnttool/import_data.py (original)
+++ zorg/trunk/lnt/lnt/lnttool/import_data.py Tue Apr 26 12:48:04 2011
@@ -1,7 +1,8 @@
import os, pprint, sys, time
+import lnt.db.perfdb
from lnt import formats
-from lnt.viewer import Config, PerfDB
+from lnt.viewer import Config
from lnt.util import ImportData
def action_import(name, args):
@@ -52,7 +53,7 @@
parser.error("invalid database name")
# Load the database.
- db = PerfDB.PerfDB(db_entry.path, echo=opts.show_sql)
+ db = lnt.db.perfdb.PerfDB(db_entry.path, echo=opts.show_sql)
for file in args:
result = ImportData.import_and_report(
config, opts.database, db, file,
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=130215&r1=130214&r2=130215&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/ui/app.py (original)
+++ zorg/trunk/lnt/lnt/server/ui/app.py Tue Apr 26 12:48:04 2011
@@ -15,7 +15,7 @@
# FIXME: Redesign this.
import lnt.viewer.Config
from lnt.db import perfdbsummary
-from lnt.viewer import PerfDB
+from lnt.db import perfdb
class Request(flask.Request):
def __init__(self, *args, **kwargs):
@@ -32,7 +32,7 @@
def get_db(self):
if self.db is None:
- self.db = PerfDB.PerfDB(g.db_info.path)
+ self.db = perfdb.PerfDB(g.db_info.path)
# Enable SQL logging with db_log.
#
@@ -93,7 +93,7 @@
self.jinja_env.globals.update(
app=current_app,
db_url_for=db_url_for,
- perfdb=PerfDB,
+ perfdb=perfdb,
old_config=self.old_config)
def get_db_summary(self, db_name, db):
Modified: zorg/trunk/lnt/lnt/util/ImportData.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/ImportData.py?rev=130215&r1=130214&r2=130215&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/util/ImportData.py (original)
+++ zorg/trunk/lnt/lnt/util/ImportData.py Tue Apr 26 12:48:04 2011
@@ -1,9 +1,9 @@
import os, re, time
+import lnt.db.perfdb
from lnt import formats
from lnt.db import runinfo
from lnt.util import NTEmailReport
-from lnt.viewer import PerfDB
def import_and_report(config, db_name, db, file, format, commit=False,
show_sample_count=False, disable_email=False):
@@ -60,7 +60,7 @@
importStartTime = time.time()
try:
- success,run = PerfDB.importDataFromDict(db, data)
+ success,run = perfdb.importDataFromDict(db, data)
except KeyboardInterrupt:
raise
except:
Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/NTEmailReport.py?rev=130215&r1=130214&r2=130215&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/util/NTEmailReport.py (original)
+++ zorg/trunk/lnt/lnt/util/NTEmailReport.py Tue Apr 26 12:48:04 2011
@@ -17,10 +17,10 @@
from lnt.db import perfdbsummary
from lnt.viewer import GraphUtil
from lnt.viewer import Util
-from lnt.viewer import PerfDB
+from lnt.db import perfdb
from lnt.viewer.NTUtil import *
-from lnt.viewer.PerfDB import Run, Sample
+from lnt.db.perfdb import Run, Sample
def main():
global opts
@@ -33,7 +33,7 @@
dbpath,runID,baseurl,host,from_,to = args
- db = PerfDB.PerfDB(dbpath)
+ db = lnt.db.perfdb.PerfDB(dbpath)
run = db.getRun(int(runID))
emailReport(db, run, baseurl, host, from_, to)
@@ -485,7 +485,7 @@
# user we are crosses machines.
if compareTo is None:
compareCrossesMachine = True
- q = db.session.query(PerfDB.Run).join(PerfDB.Machine)
+ q = db.session.query(perfdb.Run).join(perfdb.Machine)
q = q.filter_by(name=machine.name)
compareTo = findPreceedingRun(q, run)
Modified: zorg/trunk/lnt/lnt/viewer/GraphUtil.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/GraphUtil.py?rev=130215&r1=130214&r2=130215&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/GraphUtil.py (original)
+++ zorg/trunk/lnt/lnt/viewer/GraphUtil.py Tue Apr 26 12:48:04 2011
@@ -7,7 +7,7 @@
from lnt.util import stats
from lnt.external.stats import stats as ext_stats
-from PerfDB import Machine, Run, RunInfo, Sample, Test
+from lnt.db.perfdb import Machine, Run, RunInfo, Sample, Test
def get_test_plots(db, machine, test_ids, run_summary, ts_summary,
show_mad_error = False, show_points = False,
Modified: zorg/trunk/lnt/lnt/viewer/NTStyleBrowser.ptl
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/NTStyleBrowser.ptl?rev=130215&r1=130214&r2=130215&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/NTStyleBrowser.ptl (original)
+++ zorg/trunk/lnt/lnt/viewer/NTStyleBrowser.ptl Tue Apr 26 12:48:04 2011
@@ -15,9 +15,9 @@
from quixote.errors import TraversalError
import Util
-from NTUtil import *
+from lnt.db.NTUtil import *
-from PerfDB import Machine, Run, RunInfo
+from lnt.db.perfdb import Machine, Run, RunInfo
class TestRunUI(Directory):
def __init__(self, root, idstr):
Modified: zorg/trunk/lnt/lnt/viewer/NTUtil.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/NTUtil.py?rev=130215&r1=130214&r2=130215&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/NTUtil.py (original)
+++ zorg/trunk/lnt/lnt/viewer/NTUtil.py Tue Apr 26 12:48:04 2011
@@ -1,5 +1,5 @@
import Util
-from PerfDB import Run, Sample, Test
+from lnt.db.perfdb import Run, Sample, Test
kPrefix = 'nightlytest'
Removed: zorg/trunk/lnt/lnt/viewer/PerfDB.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/PerfDB.py?rev=130214&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/PerfDB.py (original)
+++ zorg/trunk/lnt/lnt/viewer/PerfDB.py (removed)
@@ -1,488 +0,0 @@
-#!/usr/bin/python
-
-###
-# SQLAlchemy database layer
-
-import sqlalchemy
-import sqlalchemy.ext.declarative
-import sqlalchemy.orm
-from sqlalchemy import *
-from sqlalchemy.schema import Index
-from sqlalchemy.orm import relation, backref
-from sqlalchemy.orm.collections import attribute_mapped_collection
-
-Base = sqlalchemy.ext.declarative.declarative_base()
-class Revision(Base):
- __tablename__ = 'Revision'
-
- id = Column("ID", Integer, primary_key=True)
- name = Column("Name", String(256))
- number = Column("Number", Integer)
-
- def __init__(self, name, number):
- self.name = name
- self.number = number
-
- def __repr__(self):
- return '%s%r' % (self.__class__.__name__, (self.name, self.number))
-
-class Machine(Base):
- __tablename__ = 'Machine'
-
- id = Column("ID", Integer, primary_key=True)
- name = Column("Name", String(256))
- number = Column("Number", Integer)
-
- info = relation('MachineInfo',
- collection_class=attribute_mapped_collection('key'),
- backref=backref('machine'))
-
- def __init__(self, name, number):
- self.name = name
- self.number = number
-
- def __repr__(self):
- return '%s%r' % (self.__class__.__name__, (self.name, self.number))
-
-class MachineInfo(Base):
- __tablename__ = 'MachineInfo'
-
- id = Column("ID", Integer, primary_key=True)
- machine_id = Column("Machine", Integer, ForeignKey('Machine.ID'))
- key = Column("Key", String(256))
- value = Column("Value", String(4096))
-
- def __init__(self, machine, key, value):
- self.machine = machine
- self.key = key
- self.value = value
-
- def __repr__(self):
- return '%s%r' % (self.__class__.__name__,
- (self.machine, self.key, self.value))
-
-class Run(Base):
- __tablename__ = 'Run'
-
- id = Column("ID", Integer, primary_key=True)
- machine_id = Column("MachineID", Integer, ForeignKey('Machine.ID'))
- start_time = Column("StartTime", DateTime)
- end_time = Column("EndTime", DateTime)
-
- machine = relation(Machine)
-
- info = relation('RunInfo',
- collection_class=attribute_mapped_collection('key'),
- backref=backref('run'))
-
- def __init__(self, machine, start_time, end_time):
- self.machine = machine
- self.start_time = start_time
- self.end_time = end_time
-
- def __repr__(self):
- return '%s%r' % (self.__class__.__name__,
- (self.machine, self.start_time, self.end_time))
-
-class RunInfo(Base):
- __tablename__ = 'RunInfo'
-
- id = Column("ID", Integer, primary_key=True)
- run_id = Column("Run", Integer, ForeignKey('Run.ID'))
- key = Column("Key", String(256))
- value = Column("Value", String(4096))
-
- def __init__(self, run, key, value):
- self.run = run
- self.key = key
- self.value = value
-
- def __repr__(self):
- return '%s%r' % (self.__class__.__name__,
- (self.run, self.key, self.value))
-
-class Test(Base):
- __tablename__ = 'Test'
-
- id = Column("ID", Integer, primary_key=True)
- name = Column("Name", String(512))
-
- info = relation('TestInfo',
- collection_class=attribute_mapped_collection('key'),
- backref=backref('test'))
-
- def __init__(self, name):
- self.name = name
-
- def __repr__(self):
- return '%s%r' % (self.__class__.__name__,
- (self.name,))
-
- def get_parameter_set(self):
- items = [(k,v.value) for k,v in self.info.items()]
- items.sort()
- return tuple(items)
-
-class TestInfo(Base):
- __tablename__ = 'TestInfo'
-
- id = Column("ID", Integer, primary_key=True)
- test_id = Column("Test", Integer, ForeignKey('Test.ID'))
- key = Column("Key", String(256))
- value = Column("Value", String(4096))
-
- def __init__(self, test, key, value):
- self.test = test
- self.key = key
- self.value = value
-
- def __repr__(self):
- return '%s%r' % (self.__class__.__name__,
- (self.test, self.key, self.value))
-
-class Sample(Base):
- __tablename__ = 'Sample'
-
- id = Column("ID", Integer, primary_key=True)
- run_id = Column("RunID", Integer, ForeignKey('Run.ID'), index=True)
- test_id = Column("TestID", Integer, ForeignKey('Test.ID'), index=True)
- value = Column("Value", Float)
-
- run = relation(Run)
- test = relation(Test)
-
- def __init__(self, run, test, value):
- self.run = run
- self.test = test
- self.value = value
-
- def __repr__(self):
- return '%s%r' % (self.__class__.__name__,
- (self.run, self.test, self.value))
-
-# Define an additonal index on (RunID, TestID).
-Index("ix_Sample_RunID_TestID", Sample.run_id, Sample.test_id)
-
-###
-# PerfDB wrapper, to avoid direct SA dependency when possible.
-
-def info_eq(a, b):
- a = list(a)
- b = list(b)
- a.sort()
- b.sort()
- return a == b
-
-class PerfDB:
- def __init__(self, path, echo=False):
- if (not path.startswith('mysql://') and
- not path.startswith('sqlite://')):
- path = 'sqlite:///' + path
- self.path = path
- self.engine = sqlalchemy.create_engine(path, echo=echo)
-
- # Create the tables in case this is a new database.
- Base.metadata.create_all(self.engine)
-
- self.session = sqlalchemy.orm.sessionmaker(self.engine)()
- self.modified_machine = self.modified_run = self.modified_test = False
-
- # Make sure revision numbers exists.
- for r in ("Machine","MachineInfo","Run","RunInfo","Test","TestInfo"):
- self.get_revision(r)
- self.commit()
-
- # Add shortcut alias.
- self.query = self.session.query
-
- def get_revision(self, name):
- for r in self.session.query(Revision).filter_by(name=name):
- return r
- r = Revision(name, 0)
- self.session.add(r)
- return r
- def get_revision_number(self, name):
- return self.get_revision(name).number
-
- def machines(self, name=None):
- q = self.session.query(Machine)
- if name:
- q = q.filter_by(name=name)
- return q
-
- def tests(self, name=None):
- q = self.session.query(Test)
- if name:
- q = q.filter_by(name=name)
- return q
-
- def runs(self, machine=None):
- q = self.session.query(Run)
- if machine:
- q = q.filter_by(machine=machine)
- return q
-
- def samples(self, run=None, test=None):
- q = self.session.query(Sample)
- if run:
- q = q.filter_by(run_id=run.id)
- if test:
- q = q.filter_by(test_id=test.id)
- return q
-
- def getNumMachines(self):
- return self.machines().count()
-
- def getNumRuns(self):
- return self.runs().count()
-
- def getNumTests(self):
- return self.tests().count()
-
- def getNumSamples(self):
- return self.samples().count()
-
- def getMachine(self, id):
- return self.session.query(Machine).filter_by(id=id).one()
-
- def getRun(self, id):
- return self.session.query(Run).filter_by(id=id).one()
-
- def getTest(self, id):
- return self.session.query(Test).filter_by(id=id).one()
-
- def getOrCreateMachine(self, name, info):
- # FIXME: Not really the right way...
- number = 1
- for m in self.machines(name=name):
- if info_eq([(i.key, i.value) for i in m.info.values()], info):
- return m,False
- number += 1
-
- # Make a new record
- m = Machine(name, number)
- m.info = dict((k,MachineInfo(m,k,v)) for k,v in info)
- self.session.add(m)
- self.modified_machine = True
- return m,True
-
- def getOrCreateTest(self, name, info):
- # FIXME: Not really the right way...
- for t in self.tests(name):
- if info_eq([(i.key, i.value) for i in t.info.values()], info):
- return t,False
-
- t = Test(name)
- t.info = dict((k,TestInfo(t,k,v)) for k,v in info)
- self.session.add(t)
- self.modified_test = True
- return t,True
-
- def getOrCreateRun(self, machine, start_time, end_time, info):
- from datetime import datetime
- start_time = datetime.strptime(start_time,
- "%Y-%m-%d %H:%M:%S")
- end_time = datetime.strptime(end_time,
- "%Y-%m-%d %H:%M:%S")
-
- # FIXME: Not really the right way...
- for r in self.session.query(Run).filter_by(machine=machine):
- # FIXME: Execute this filter in SQL, but resolve the
- # normalization issue w.r.t. SQLAlchemy first. I think we
- # may be running afoul of SQLite not normalizing the
- # datetime. If I don't do this then sqlalchemy issues a
- # query in the format YYYY-MM-DD HH:MM:SS.ssss which
- # doesn't work.
- if r.start_time != start_time or r.end_time != end_time:
- continue
- if info_eq([(i.key, i.value) for i in r.info.values()], info):
- return r,False
-
- # Make a new record
- r = Run(machine, start_time, end_time)
- r.info = dict((k,RunInfo(r,k,v)) for k,v in info)
- self.session.add(r)
- self.modified_run = True
- return r,True
-
- def addSample(self, run, test, value):
- s = Sample(run, test, value)
- self.session.add(s)
- return s
-
- def addSamples(self, samples):
- """addSamples([(run_id, test_id, value), ...]) -> None
-
- Batch insert a list of samples."""
-
- # Flush to keep session consistent.
- self.session.flush()
-
- for run_id,test_id,value in samples:
- q = Sample.__table__.insert().values(RunID = run_id,
- TestID = test_id,
- Value = value)
- self.session.execute(q)
-
- def commit(self):
- if self.modified_machine:
- self.get_revision("Machine").number += 1
- self.get_revision("MachineInfo").number += 1
- if self.modified_run:
- self.get_revision("Run").number += 1
- self.get_revision("RunInfo").number += 1
- if self.modified_test:
- self.get_revision("Test").number += 1
- self.get_revision("TestInfo").number += 1
- self.session.commit()
- self.modified_machine = self.modified_test = self.modified_run = False
-
- def rollback(self):
- self.session.rollback()
- self.modified_machine = self.modified_test = self.modified_run = False
-
-def importDataFromDict(db, data):
- # FIXME: Validate data
- machineData = data['Machine']
- runData = data['Run']
- testsData = data['Tests']
-
- # Get the machine
- # FIXME: Validate machine
- machine,_ = db.getOrCreateMachine(machineData['Name'],
- machineData['Info'].items())
-
- # Accept 'Time' as an alias for 'Start Time'
- if 'Start Time' not in runData and 'Time' in runData:
- import time
- t = time.strptime(runData['Time'],
- "%a, %d %b %Y %H:%M:%S -0700 (PDT)")
- runData['Start Time'] = time.strftime('%Y-%m-%d %H:%M', t)
-
- # Create the run.
- run,inserted = db.getOrCreateRun(machine,
- runData.get('Start Time',''),
- runData.get('End Time',''),
- runData.get('Info',{}).items())
- if not inserted:
- return False,run
-
- # Batch load the set of tests instead of repeatedly querying to unique.
- #
- # FIXME: Add explicit config object.
- test_info = {}
- for id,k,v in db.session.query(TestInfo.test_id, TestInfo.key,
- TestInfo.value):
- info = test_info[id] = test_info.get(id,{})
- info[str(k)] = str(v)
-
- testMap = {}
- for test_id,test_name in db.session.query(Test.id, Test.name):
- info = test_info.get(test_id,{}).items()
- info.sort()
- testMap[(str(test_name),tuple(info))] = test_id
-
- # Create the tests up front, so we can resolve IDs.
- test_ids = []
- late_ids = []
- for i,testData in enumerate(testsData):
- name = str(testData['Name'])
- info = [(str(k),str(v)) for k,v in testData['Info'].items()]
- info.sort()
- test_id = testMap.get((name,tuple(info)))
- if test_id is None:
- test,created = db.getOrCreateTest(testData['Name'],info)
- late_ids.append((i,test))
- test_ids.append(test_id)
-
- # Flush now to resolve test and run ids.
- #
- # FIXME: Surely there is a cleaner way to handle this?
- db.session.flush()
-
- if late_ids:
- for i,t in late_ids:
- test_ids[i] = t.id
-
- db.addSamples([(run.id, test_id, value)
- for test_id,testData in zip(test_ids, testsData)
- for value in testData['Data']])
- return True,run
-
-def test_sa_db(dbpath):
- if not dbpath.startswith('mysql://'):
- dbpath = 'sqlite:///' + dbpath
- engine = sqlalchemy.create_engine(dbpath)
-
- Session = sqlalchemy.orm.sessionmaker(engine)
- Session.configure(bind=engine)
-
- session = Session()
-
- m = session.query(Machine).first()
- print m
- print m.info
-
- r = session.query(Run).first()
- print r
- print r.info
-
- t = session.query(Test)[20]
- print t
- print t.info
-
- s = session.query(Sample)[20]
- print s
-
- import time
- start = time.time()
- print
- q = session.query(Sample)
- q = q.filter(Sample.run_id == 994)
- print
- res = session.execute(q)
- print res
- N = 0
- for row in res:
- if N == 1:
- print row
- N += 1
- print N, time.time() - start
- print
-
- start = time.time()
- N = 0
- for row in q:
- if N == 1:
- print row
- N += 1
- print N, time.time() - start
-
-def main():
- global opts
- from optparse import OptionParser
- parser = OptionParser("usage: %prog dbpath")
- opts,args = parser.parse_args()
-
- if len(args) != 1:
- parser.error("incorrect number of argments")
-
- dbpath, = args
-
- # Test the SQLAlchemy layer.
- test_sa_db(dbpath)
-
- # Test the PerfDB wrapper.
- db = PerfDB(dbpath)
-
- print "Opened %r" % dbpath
-
- for m in db.machines():
- print m
- for r in db.runs(m):
- print ' run - id:%r, start:%r,'\
- ' # samples: %d.' % (r.id, r.start_time,
- db.samples(run=r).count())
-
-if __name__ == '__main__':
- main()
Modified: zorg/trunk/lnt/lnt/viewer/nightlytest.ptl
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/nightlytest.ptl?rev=130215&r1=130214&r2=130215&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/nightlytest.ptl (original)
+++ zorg/trunk/lnt/lnt/viewer/nightlytest.ptl Tue Apr 26 12:48:04 2011
@@ -17,7 +17,7 @@
from Util import safediv
from NTUtil import *
-from PerfDB import Machine, Run
+from lnt.db.perfdb import Machine, Run
class NightlyTestRunUI(NTStyleBrowser.TestRunUI):
_q_exports = ["", "graphSingle"]
Modified: zorg/trunk/lnt/lnt/viewer/root.ptl
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/root.ptl?rev=130215&r1=130214&r2=130215&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/root.ptl (original)
+++ zorg/trunk/lnt/lnt/viewer/root.ptl Tue Apr 26 12:48:04 2011
@@ -19,8 +19,9 @@
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
+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",
@@ -41,7 +42,7 @@
self.db_summary = None
def getDB(self):
- db = PerfDB.PerfDB(self.dbInfo.path)
+ db = perfdb.PerfDB(self.dbInfo.path)
# Enable SQL logging with db_log.
#
Modified: zorg/trunk/lnt/lnt/viewer/simple.ptl
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/simple.ptl?rev=130215&r1=130214&r2=130215&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/simple.ptl (original)
+++ zorg/trunk/lnt/lnt/viewer/simple.ptl Tue Apr 26 12:48:04 2011
@@ -22,7 +22,7 @@
from Util import safediv
from NTUtil import *
-from PerfDB import Machine, Run, RunInfo, Test
+from lnt.db.perfdb import Machine, Run, RunInfo, Test
class SimpleRunUI(Directory):
_q_exports = ["", "graph", "report", "text_report"]
Modified: zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl?rev=130215&r1=130214&r2=130215&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl (original)
+++ zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl Tue Apr 26 12:48:04 2011
@@ -7,7 +7,7 @@
from quixote.directory import Directory
from quixote.html import htmltext
-from lnt.viewer.PerfDB import Machine, Run, Sample, Test
+from lnt.db.perfdb import Machine, Run, Sample, Test
from lnt.viewer import NTUtil
from sqlalchemy import func
Modified: zorg/trunk/lnt/tests/DB/Create.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/tests/DB/Create.py?rev=130215&r1=130214&r2=130215&view=diff
==============================================================================
--- zorg/trunk/lnt/tests/DB/Create.py (original)
+++ zorg/trunk/lnt/tests/DB/Create.py Tue Apr 26 12:48:04 2011
@@ -3,7 +3,7 @@
# RUN: python %s %t.db
import sys
-from lnt.viewer.PerfDB import PerfDB, Run
+from lnt.db.perfdb import PerfDB, Run
# Check creation.
Modified: zorg/trunk/lnt/tests/DB/Import.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/tests/DB/Import.py?rev=130215&r1=130214&r2=130215&view=diff
==============================================================================
--- zorg/trunk/lnt/tests/DB/Import.py (original)
+++ zorg/trunk/lnt/tests/DB/Import.py Tue Apr 26 12:48:04 2011
@@ -22,7 +22,7 @@
# RUN: python %s %t.install/data/lnt.db
import datetime, sys
-from lnt.viewer.PerfDB import PerfDB, Run, Test
+from lnt.db.perfdb import PerfDB, Run, Test
db = PerfDB(sys.argv[1])
More information about the llvm-commits
mailing list