From 0a0fa3e51783e4e1c42eab959f9d9eb5365a6f40 Mon Sep 17 00:00:00 2001 From: Radovan Zivkovic Date: Mon, 31 Jul 2023 21:41:03 +0200 Subject: [PATCH] Move test_model_not_retrained_if_only_new_responses to acceptance tests --- tests/acceptance_tests/test_training.py | 35 +++++++++++++++++++++++++ tests/test_model_training.py | 33 ----------------------- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/tests/acceptance_tests/test_training.py b/tests/acceptance_tests/test_training.py index f4602d140236..47540d85de82 100644 --- a/tests/acceptance_tests/test_training.py +++ b/tests/acceptance_tests/test_training.py @@ -4,6 +4,8 @@ from typing import Text import rasa +from rasa.shared.core.domain import Domain +from rasa.shared.utils.io import write_yaml def _new_model_path_in_same_dir(old_model_path: Text) -> Text: @@ -27,3 +29,36 @@ def test_models_not_retrained_if_no_new_data( ) assert result.code == 0 + + +def test_dry_run_model_will_not_be_retrained_if_only_new_responses( + trained_e2e_model: Text, + moodbot_domain_path: Path, + e2e_bot_config_file: Path, + e2e_stories_path: Text, + nlu_data_path: Text, + trained_e2e_model_cache: Path, + tmp_path: Path, +): + domain = Domain.load(moodbot_domain_path) + domain_with_extra_response = """ + version: '2.0' + responses: + utter_greet: + - text: "Hi from Rasa" + """ + domain_with_extra_response = Domain.from_yaml(domain_with_extra_response) + + new_domain = domain.merge(domain_with_extra_response) + new_domain_path = tmp_path / "domain.yml" + write_yaml(new_domain.as_dict(), new_domain_path) + + result = rasa.train( + str(new_domain_path), + str(e2e_bot_config_file), + [e2e_stories_path, nlu_data_path], + output=str(tmp_path), + dry_run=True, + ) + + assert result.code == 0 diff --git a/tests/test_model_training.py b/tests/test_model_training.py index 310bd3921480..5c7d3ac9027d 100644 --- a/tests/test_model_training.py +++ b/tests/test_model_training.py @@ -883,39 +883,6 @@ def test_model_finetuning_with_invalid_model_nlu( assert "No model for finetuning found" in capsys.readouterr().out -def test_models_not_retrained_if_only_new_responses( - trained_e2e_model: Text, - moodbot_domain_path: Path, - e2e_bot_config_file: Path, - e2e_stories_path: Text, - nlu_data_path: Text, - trained_e2e_model_cache: Path, - tmp_path: Path, -): - domain = Domain.load(moodbot_domain_path) - domain_with_extra_response = """ - version: '2.0' - responses: - utter_greet: - - text: "Hi from Rasa" - """ - domain_with_extra_response = Domain.from_yaml(domain_with_extra_response) - - new_domain = domain.merge(domain_with_extra_response) - new_domain_path = tmp_path / "domain.yml" - rasa.shared.utils.io.write_yaml(new_domain.as_dict(), new_domain_path) - - result = rasa.train( - str(new_domain_path), - str(e2e_bot_config_file), - [e2e_stories_path, nlu_data_path], - output=str(tmp_path), - dry_run=True, - ) - - assert result.code == 0 - - def test_models_not_retrained_if_only_new_action( trained_e2e_model: Text, moodbot_domain_path: Path,