How to use the opentuner.resultsdb.models 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 / examples / petabricks / import_old_result.py View on Github external
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',
  )
  session.add(tuningrun)

  for gen, line in enumerate(open(args.candidatelog)):
    if line[0] != '#':
      line = re.split('\t', line)
      date = tuningrun.start_date + timedelta(seconds=float(line[0]))
      cfg = os.path.normpath(
        os.path.join(os.path.dirname(args.candidatelog), '..', line[5]))
      result = run(args, cfg)
      result.was_new_best = True
      result.tuning_run = tuningrun
      result.collection_date = date
      session.add(result)
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',
  )
  session.add(tuningrun)

  for gen, line in enumerate(open(args.candidatelog)):
    if line[0] != '#':
      line = re.split('\t', line)
      date = tuningrun.start_date + timedelta(seconds=float(line[0]))
      cfg = os.path.normpath(
github GraphIt-DSL / graphit / autotune / graphit_autotuner.py View on Github external
if run_result['timeout'] == True:
            val = self.args.runtime_limit
        else:
            val = self.parse_running_time();
        
        self.call_program('rm test.out')
        print ("run result: " + str(run_result))
        print ("running time: " + str(val))

        if run_result['timeout'] == True:
            print ("Timed out after " + str(self.args.runtime_limit) + " seconds")
            return opentuner.resultsdb.models.Result(time=val)
        elif run_result['returncode'] != 0:
            if self.args.killed_process_report_runtime_limit == 1 and run_result['stderr'] == 'Killed\n':
                print ("process killed " + str(run_result))
                return opentuner.resultsdb.models.Result(time=self.args.runtime_limit)
            else:
                print (str(run_result))
                exit()
        else:
            return opentuner.resultsdb.models.Result(time=val)
github jbosboom / streamjit / lib / opentuner / streamjit / tuner2.py View on Github external
def run(self, desired_result, input, limit):
		cfg = dict.copy(desired_result.configuration.data)
		(st, t) = self.runApp(cfg)
		return opentuner.resultsdb.models.Result(state=st, time=t)
github jbosboom / streamjit / lib / opentuner / streamjit / tuner.py View on Github external
def run(self, desired_result, input, limit):
		self.trycount = self.trycount + 1
		cfg = desired_result.configuration.data
		self.niceprint(cfg)
		self.sdk.sendmsg("%s\n"%cfg)
		msg = self.sdk.recvmsg()
		exetime = float(msg)
		if exetime < 0:
			print "Error in execution"
			return opentuner.resultsdb.models.Result(state='ERROR', time=float('inf'))
		else:	
			print "Execution time is %f"%exetime
			return opentuner.resultsdb.models.Result(time=exetime)
github jbosboom / streamjit / lib / opentuner / streamjit / tuner3.py View on Github external
# cope with Java exceptions and JVM crashes
		try:
			if len(stderr) > 0 or len(stdout) == 0:
				raise ValueError
			stdout = stdout.strip(" \t\n\r")
			match = re.match(r"\d+/\d+/\d+/(\d+)#", stdout)
			if not match:
				raise ValueError
			time = float(match.group(1))
			print stdout
			return opentuner.resultsdb.models.Result(state='OK', time=time)
		except ValueError:
			print stderr.strip(" \t\n\r")
			if "TIMED OUT" in stderr:
				return opentuner.resultsdb.models.Result(state='TIMEOUT', time=float('inf'))
			else:
				with tempfile.NamedTemporaryFile(dir=os.getcwd(), prefix="error-{0}-{1}-".format(self.timestamp, self.program),
						suffix=".cfg", delete=False) as f:
					f.write(self.config.toJSON())
					f.write("\n")
					f.writelines(jvm_args)
					f.write("\n")
					f.write(stderr)
					if len(stdout) == 0:
						f.write("[stdout was empty]")
					f.flush()
				return opentuner.resultsdb.models.Result(state='ERROR', time=float('inf'))
github jansel / opentuner / examples / hpl / hpl.py View on Github external
def run(self, desired_result, input, limit):
        self.output_hpl_datfile(desired_result.configuration.data)
        import subprocess, os
        binary = self.args.xhpl
        subprocess.call(["mpirun", "-np", str(self.args.nprocs), binary])
        
        val = self.get_time_from_hpl_output()
        
        return opentuner.resultsdb.models.Result(time=val)