def test_session_relationship(self):
        s = database.Session('test session name')

        e = database.Experiment('test expt name', session=s)

        self.db_session.add(e)
        self.db_session.commit()

        e2 = self.db_session.query(database.Experiment).first()
        self.assertEqual(e, e2)
        self.assertEqual(s, e2.session)
        self.assertTrue(e2.session.id >= 1)
Exemplo n.º 2
0
def static_experiments(experiment_definitions, session_parameters):
    results = []
    log.info('Loading %s experiment definitions.' %
             len(experiment_definitions))
    for name, expt in experiment_definitions.iteritems():
        log.debug("Loading experiment: '%s'" % name)
        e = database.Experiment()
        e.name = name

        e.parameters = expt.get('parameters', {})
        log.debug('Found %s parameters.' % len(e.parameters))

        total_parameters = dict(e.parameters)
        total_parameters.update(session_parameters)

        sim = expt.get('simulation', {})

        e.filaments = make_binds(sim.get('filaments', {}),
                                 database.FilamentBind)
        log.debug('Found %s filament bindings.' % len(e.filaments))

        e.end_conditions = make_binds(sim.get('end_conditions', {}),
                                      database.EndConditionBind)
        log.debug('Found %s end_condition bindings.' % len(e.end_conditions))

        e.measurements = make_binds(sim.get('measurements', {}),
                                    database.MeasurementBind)
        log.debug('Found %s measurement bindings.' % len(e.measurements))

        e.transitions = make_binds(sim.get('transitions', {}),
                                   database.TransitionBind)
        log.debug('Found %s transition bindings.' % len(e.transitions))

        e.concentrations = make_binds(sim.get('concentrations', {}),
                                      database.ConcentrationBind)
        log.debug('Found %s concentration bindings.' % len(e.concentrations))

        # analysis configuration
        e.analysis_list = make_binds(expt.get('analyses', {}),
                                     database.AnalysisBind)
        log.debug('Found %s analysis bindings.' % len(e.analysis_list))

        # objective configuration
        obj_defs = expt.get('objectives', {})
        e.objective_list = make_binds(obj_defs.get('executors', {}),
                                      database.ObjectiveBind)
        log.debug('Found %s objective bindings.' % len(e.objective_list))

        load_data(e.objectives, total_parameters, obj_defs.get('loaders', {}))

        results.append(e)

    return results
Exemplo n.º 3
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)
    def test_parameters(self):
        test_data = {'par_name_1': 7.2,
                     'par_name_2': 61.3}

        e = database.Experiment('ses 1')
        e.session_id = 0

        e.parameters = test_data

        self.db_session.add(e)
        self.db_session.commit()

        del e

        e2 = self.db_session.query(database.Experiment).first()
        for par_name, value in test_data.iteritems():
            self.assertEqual(value, e2.parameters[par_name])
    def test_transition_binds(self):
        e = database.Experiment('test expt name')
        e.session_id = 0

        class_name = 'test_class_name'
        fixed_arguments = {'fixed a': 'literal 1'}
        variable_arguments = {'variable a': 'par name 1'}

        cb = database.TransitionBind(class_name=class_name,
                fixed_arguments=fixed_arguments,
                variable_arguments=variable_arguments)
        e.transitions.append(cb)

        self.db_session.add(e)
        self.db_session.commit()

        e2 = self.db_session.query(database.Experiment).first()
        self.assertEqual(cb, e2.transitions[0])