def _save_new_trial_to_db_if_possible( self, experiment: Experiment, trial: BaseTrial, suppress_all_errors: bool = False, ) -> bool: """Saves new trial on given experiment if DB settings are set on this `WithDBSettingsBase` instance. Args: experiment: Experiment, on which to save new trial in DB. trials: Newly added trial to save. 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 trial was saved. """ if self.db_settings_set: save_new_trial( experiment=experiment, trial=trial, db_settings=self.db_settings ) return True return False
def test_save_load_new_trial(self): exp = load_experiment(self.exp.name, self.db_settings) trial = exp.new_trial() save_new_trial(exp, trial, self.db_settings) exp = load_experiment(self.exp.name, self.db_settings) self.assertEqual(len(exp.trials), 1) self.assertEqual(exp.trials[0].status, TrialStatus.CANDIDATE) trial.mark_running(True) save_updated_trial(exp, trial, self.db_settings) exp = load_experiment(self.exp.name, self.db_settings) self.assertEqual(exp.trials[0].status, TrialStatus.RUNNING)
def _save_new_trial_to_db_if_possible( self, trial: BaseTrial, suppress_all_errors: bool = False ) -> bool: """Saves given trial 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_new_trial( experiment=self.experiment, trial=trial, db_settings=self.db_settings ) return True return False
def _save_new_trial_to_db_if_possible( self, experiment: Experiment, trial: BaseTrial, suppress_all_errors: bool = False, ) -> bool: """Saves given trial 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_new_trial(experiment=experiment, trial=trial, db_settings=self.db_settings) return True return False