def test_save_load_experiment_and_generation_strategy(self): exp, gs = load_experiment_and_generation_strategy( self.exp.name, self.db_settings) self.assertIsNone(gs) gs = get_generation_strategy() gs._experiment = self.exp save_experiment(self.exp, self.db_settings) save_generation_strategy(gs, self.db_settings) exp, gs = load_experiment_and_generation_strategy( self.exp.name, self.db_settings) self.assertIsNotNone(gs)
def _save_generation_strategy_to_db_if_possible( self, suppress_all_errors: bool = False) -> bool: """Saves attached experiment and generation strategy if DB settings are set on this AxClient instance. Returns: bool: Whether the experiment was saved. """ if self.db_settings is not None: save_generation_strategy( generation_strategy=self.generation_strategy, db_settings=self.db_settings, ) return True return False
def _save_generation_strategy_to_db_if_possible( self, generation_strategy: GenerationStrategy, suppress_all_errors: bool = False) -> bool: """Saves attached experiment and generation strategy if DB settings are set on this `WithDBSettingsBase` instance. Returns: bool: Whether the experiment was saved. """ if self.db_settings_set: save_generation_strategy(generation_strategy=generation_strategy, db_settings=self.db_settings) return True return False
def _save_generation_strategy_to_db_if_possible( self, generation_strategy: GenerationStrategy, suppress_all_errors: bool = False ) -> bool: """Saves given generation strategy if DB settings are set on this `WithDBSettingsBase` instance. Args: generation_strategy: Generation strategy to save in DB. suppress_all_errors: Flag for `retry_on_exception` that makes the decorator suppress the thrown exception even if it occurred in all the retries (exception is still logged). Returns: bool: Whether the experiment was saved. """ if self.db_settings_set: save_generation_strategy( generation_strategy=generation_strategy, db_settings=self.db_settings ) return True return False