def test_does_model_improve( previous_best: Dict[Text, float], current_values: Dict[Text, float], improved: bool, tmpdir: Path, ): checkpoint = RasaModelCheckpoint(tmpdir) checkpoint.best_metrics_so_far = previous_best # true iff all values are equal or better and at least one is better assert checkpoint._does_model_improve(current_values) == improved
def test_on_epoch_end_saves_checkpoints_file( previous_best: Dict[Text, float], current_values: Dict[Text, float], improved: bool, tmp_path: Path, trained_ted: TEDPolicy, ): model_name = "checkpoint" best_model_file = tmp_path / model_name assert not best_model_file.exists() checkpoint = RasaModelCheckpoint(tmp_path) checkpoint.best_metrics_so_far = previous_best checkpoint.model = trained_ted.model checkpoint.on_epoch_end(1, current_values) if improved: assert best_model_file.exists() else: assert not best_model_file.exists()