def _initialize_experiment_in_db(experiment: str, git_hash: str, trials: List[models.Trial]): """Initializes |experiment| in the database by creating the experiment entity and entities for each trial in the experiment.""" db_utils.add_all([ db_utils.get_or_create(models.Experiment, name=experiment, git_hash=git_hash) ]) # TODO(metzman): Consider doing this without sqlalchemy. This can get # slow with SQLalchemy (it's much worse with add_all). db_utils.bulk_save(trials)
def _initialize_experiment_in_db(experiment: str, benchmarks: List[str], fuzzers: List[str], num_trials: int): """Initializes |experiment| in the database by creating the experiment entity and entities for each trial in the experiment.""" db_utils.add_all( [db_utils.get_or_create(models.Experiment, name=experiment)]) trials_args = itertools.product(sorted(benchmarks), range(num_trials), sorted(fuzzers)) trials = [ models.Trial(fuzzer=fuzzer, experiment=experiment, benchmark=benchmark) for benchmark, _, fuzzer in trials_args ] # TODO(metzman): Consider doing this without sqlalchemy. This can get # slow with SQLalchemy (it's much worse with add_all). db_utils.bulk_save(trials)
def _initialize_experiment_in_db(experiment_config: dict): """Initializes |experiment| in the database by creating the experiment entity.""" experiment_exists = db_utils.query(models.Experiment).filter( models.Experiment.name == experiment_config['experiment']).first() if experiment_exists: raise Exception('Experiment already exists in database.') db_utils.add_all([ db_utils.get_or_create( models.Experiment, name=experiment_config['experiment'], git_hash=experiment_config['git_hash'], private=experiment_config.get('private', True), experiment_filestore=experiment_config['experiment_filestore']) ])