def _create_run(parameters, model, experiment):
    run = database.Run(parameters=parameters,
                       model=model,
                       experiment=experiment)
    for bind in experiment.objective_list:
        database.Objective(parameters={}, bind=bind, run=run)
    return run
Exemple #2
0
    def test_experiment_relationship(self):
        e = database.Experiment(name='test expt name')
        e.session_id = 0

        r = database.Run(experiment=e)
        r.model_id = 0

        self.db_session.add(r)
        self.db_session.commit()

        r2 = self.db_session.query(database.Run).first()
        self.assertEqual(r, r2)
        self.assertEqual(e, r2.experiment)
        self.assertTrue(r2.experiment.id >= 1)
Exemple #3
0
    def test_experiment_relationship(self):
        m = database.Model(name='test expt name')
        m.session_id = 0

        r = database.Run(experiment=m)
        r.experiment_id = 0

        self.db_session.add(r)
        self.db_session.commit()

        r2 = self.db_session.query(database.Run).first()
        self.assertEqual(r, r2)
        self.assertEqual(m, r2.model)
        self.assertTrue(r2.experiment.id >= 1)
Exemple #4
0
    def test_run_relationship(self):
        r = database.Run()
        r.experiment_id = 0
        r.model_id = 0

        a = database.Analysis(run=r)

        self.db_session.add(a)
        self.db_session.commit()

        a2 = self.db_session.query(database.Analysis).first()
        self.assertEqual(a, a2)
        self.assertEqual(r, a2.run)
        self.assertTrue(a2.run.id >= 1)
Exemple #5
0
    def test_run_relationship(self):
        r = database.Run()
        r.experiment_id = 0
        r.model_id = 0

        j = database.Job(run=r)
        j.creator_id = 0

        self.db_session.add(j)
        self.db_session.commit()

        j2 = self.db_session.query(database.Job).first()
        self.assertEqual(j, j2)
        self.assertEqual(r, j2.run)
        self.assertTrue(j2.run.id >= 1)
    def test_run_relationship(self):
        r = database.Run()
        r.experiment_id = 0
        r.model_id = 0

        o = database.Objective(run=r)
        o.objective_bind_id = 0

        self.db_session.add(o)
        self.db_session.commit()

        o2 = self.db_session.query(database.Objective).first()
        self.assertEqual(o, o2)
        self.assertEqual(r, o2.run)
        self.assertTrue(o2.run.id >= 1)
Exemple #7
0
    def test_parameters(self):
        test_data = {'par_name_1': 7.2, 'par_name_2': 61.3}

        r = database.Run()
        r.experiment_id = 0
        r.model_id = 0

        r.parameters = test_data

        self.db_session.add(r)
        self.db_session.commit()

        del r

        r2 = self.db_session.query(database.Run).first()
        for par_name, value in test_data.iteritems():
            self.assertEqual(value, r2.parameters[par_name])
Exemple #8
0
    def test_analysis_relationship(self):
        a = database.Analysis(name='test_name')
        a.bind_id = 0

        r = database.Run(analysis_list=[a])
        r.model_id = 0
        r.experiment_id = 0

        a2 = database.Analysis(name='test_name2', run=r)
        a2.bind_id = 0

        a2.measurement = range(3), [2, 1, 3], [0.1, 1.2, 0.3]

        self.db_session.add(r)
        self.db_session.commit()

        r2 = self.db_session.query(database.Run).first()
        self.assertEqual(r, r2)

        self.assertEqual(a2.measurement, r2.analyses['test_name2'])
        self.assertTrue(r2.analysis_list[0].id >= 1)
        self.assertTrue(r2.analysis_list[1].id >= 1)