How to use the opentuner.resultsdb.connect function in opentuner

To help you get started, we’ve selected a few opentuner examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jansel / opentuner / opentuner / tuningrunmain.py View on Github external
os.mkdir('opentuner.db')
      args.database = 'sqlite:///' + os.path.join('opentuner.db',
                                                  socket.gethostname() + '.db')

    if '://' not in args.database:
      args.database = 'sqlite:///' + args.database

    if not args.label:
      args.label = 'unnamed'

    #self.fake_commit = ('sqlite' in args.database)
    self.fake_commit = True

    self.args = args

    self.engine, self.Session = resultsdb.connect(args.database)
    self.session = self.Session()
    self.tuning_run = None
    self.search_driver_cls = search_driver
    self.measurement_driver_cls = measurement_driver
    self.measurement_interface = measurement_interface
    self.input_manager = input_manager
    self.manipulator = manipulator
    self.objective = objective
    self.objective_copy = copy.copy(objective)
    self.last_commit_time = time.time()
github jansel / opentuner / opentuner / utils / stats_matplotlib.py View on Github external
def get_dbs(path, db_type='sqlite:///'):
  """
  Arguments,
    path: Path of directory containing .db files
  Returns,
    A list of (engine, session) pairs to the dbs pointed to by
    the db files
  """
  dbs = list()
  for f in os.listdir(path):
    if 'journal' in f:
      continue
    try:
      db_path = os.path.join(path, f)
      e, sm = resultsdb.connect(db_type + db_path)
      dbs.append(sm())
    except Exception as e:
      print(e)
      print("Error encountered while connecting to db")
  return dbs
github jansel / opentuner / opentuner / utils / stats.py View on Github external
def __init__(self, args):
    self.args = args
    path = args.stats_input
    self.dbs = list()
    for f in os.listdir(path):
      if 'journal' in f:
        continue
      try:
        e, sm = resultsdb.connect('sqlite:///'+os.path.join(path, f))
        self.dbs.append(sm())
      except:
        log.error('failed to load database: %s', 
                  os.path.join(path, f),
                  exc_info=True)
github jansel / opentuner / opentuner / utils / stats_matplotlib.py View on Github external
def get_dbs(path, db_type='sqlite:///'):
  """
  Arguments,
    path: Path of directory containing .db files
  Returns,
    A list of (engine, session) pairs to the dbs pointed to by
    the db files
  """
  dbs = list()
  for f in os.listdir(path):
    if 'journal' in f:
      continue
    try:
      db_path = os.path.join(path, f)
      e, sm = resultsdb.connect(db_type + db_path)
      dbs.append(sm())
    except Exception as e:
      print e
      print "Error encountered while connecting to db"
  return dbs
github jansel / opentuner / opentuner / utils / compactdb.py View on Github external
def main(args):
  if '://' not in args.database:
    args.database = "sqlite:///" + args.database
  engine, Session = opentuner.resultsdb.connect(args.database)
  session = Session()

  config_count = session.query(Configuration).count()
  # result_count = session.query(Result).count()
  # desired_result_count = session.query(DesiredResult).count()

  if args.level >= 1:
    q = (session.query(Configuration)
         .filter(~Configuration.id.in_(session.query(Result.configuration_id)
                                       .filter_by(was_new_best=True)
                                       .subquery()))
         .filter(Configuration.data != None))

    log.info("%s: compacted %d of %d Configurations",
             args.database,
             q.update({'data': None}, False),
github jansel / opentuner / examples / petabricks / import_old_result.py View on Github external
def main(args):
  if '://' not in args.database:
    args.database = 'sqlite:///' + args.database
  engine, Session = opentuner.resultsdb.connect(args.database)
  session = Session()

  program_settings = json.load(open(args.program + '.settings'))
  args.n = program_settings['n']
  args.technique = ['Imported']
  objective = ThresholdAccuracyMinimizeTime(program_settings['accuracy'])

  tuningrun = resultsdb.models.TuningRun(
    uuid=uuid.uuid4().hex,
    name='import',
    args=args,
    start_date=datetime.now(),
    objective=objective,
    program_version=resultsdb.models.ProgramVersion.get(
      session, 'PetaBricksInterface', args.program, 'imported'),
    state='COMPLETE',