Пример #1
0
    def test_save_load_experiment_and_generation_strategy(self):
        experiment, generation_strategy = self.init_experiment_and_generation_strategy(
            save_generation_strategy=False)
        db_exp, db_gs = self.with_db_settings._load_experiment_and_generation_strategy(
            experiment.name)
        self.assertIsNotNone(db_exp)
        self.assertIsNone(db_gs)

        experiment, generation_strategy = self.init_experiment_and_generation_strategy(
            save_experiment=False, save_generation_strategy=False)
        (
            exp_saved,
            gs_saved,
        ) = self.with_db_settings._maybe_save_experiment_and_generation_strategy(
            experiment, generation_strategy)
        self.assertTrue(exp_saved)
        self.assertTrue(gs_saved)

        db_exp, db_gs = self.with_db_settings._load_experiment_and_generation_strategy(
            experiment.name)
        self.assertIsNotNone(db_exp)
        self.assertEqual(db_exp, experiment)
        self.assertIsNotNone(db_gs)
        self.assertEqual(db_gs.name, generation_strategy.name)

        simple_experiment = get_simple_experiment()
        _save_experiment(simple_experiment,
                         encoder=self.with_db_settings.db_settings.encoder)
        with self.assertRaisesRegex(ValueError, "Service API only"):
            self.with_db_settings._load_experiment_and_generation_strategy(
                simple_experiment.name)
Пример #2
0
 def test_save_load_experiment(self):
     load_experiment(self.exp.name, self.db_settings)
     simple_experiment = get_simple_experiment()
     save_experiment(simple_experiment, self.db_settings)
     with self.assertRaisesRegex(ValueError, "Service API only"):
         load_experiment(simple_experiment.name, self.db_settings)