Example #1
0
    def __init__(self, xml_path, simulationdir=None):
        self.job = job.fromConfigurationFile(xml_path,
                                             simulationdir=simulationdir)

        reporter = report.fromConfigurationFile(xml_path, '')
        for tp in reporter.transports:
            if isinstance(tp, transport.MySQL):
                import mysqlinfo
                self.db = mysqlinfo.connect(mysqlinfo.select)
            elif isinstance(tp, transport.SQLite):
                import sqlite3
                if not os.path.isfile(tp.path):
                    raise Exception('SQLite database %s does not exist.' %
                                    tp.path)
                self.db = sqlite3.connect(tp.path)
Example #2
0
parser.add_option('-i',
                  '--index',
                  type='int',
                  help='index of bad result (>=0)')
parser.set_defaults(index=0)
(options, args) = parser.parse_args()

if len(args) < 1:
    print 'No job identifier provided.'
    sys.exit(2)
jobid = int(args[0])

print 'Looking for bad result %i of job %i.' % (options.index, jobid)

# Connect to database and retrieve best parameter set.
db = mysqlinfo.connect(mysqlinfo.select)
c = db.cursor()
c.execute(
    "SELECT `parameters`,`lnlikelihood` FROM `runs`,`results` WHERE (`runs`.`id`=`results`.`run` AND `runs`.`job`=%i AND `lnlikelihood` IS NULL) LIMIT %i,1"
    % (jobid, options.index))
parameters = None
for strpars, lnlikelihood in c:
    parameters = map(float, strpars.split(';'))
db.close()
if parameters == None:
    print 'No bad results found. Exiting...'
    sys.exit(0)

job = acpy.run.getJob(jobid)

# Show best parameter set
Example #3
0
#!/usr/bin/env python

import optparse, sys

import mysqlinfo

parser = optparse.OptionParser()
parser.add_option('-r', '--run', type='int', help='run identifier')
parser.add_option('-j', '--job', type='int', help='job identifier')
parser.add_option('--emptyrows',
                  action='store_true',
                  help='delete empty rows only')
parser.set_defaults(emptyrows=False)
(options, args) = parser.parse_args()

db = mysqlinfo.connect(mysqlinfo.admin)

c = db.cursor()

addedwhere = ''
selection = 'all'
if options.emptyrows:
    addedwhere = ' AND (`parameters`=\'\' OR `parameters`=NULL)'
    selection = 'empty'


def delRun(run):
    print 'Removing %s records for run %i from the database...' % (selection,
                                                                   run)
    c.execute('DELETE FROM `results` WHERE (`run`=%i%s);' % (run, addedwhere))
    print '%i records removed from "results" table.' % db.affected_rows()