From fc080dcdd80118dfbf0be47dff617d382f9d74f5 Mon Sep 17 00:00:00 2001 From: Nikolai Date: Tue, 19 Nov 2019 17:46:46 +0100 Subject: [PATCH 01/12] change some warnings to debug messages, add stacklevel=2 to warnings --- rasa/core/validator.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/rasa/core/validator.py b/rasa/core/validator.py index b866b34cd2e8..f5d484abd8f4 100644 --- a/rasa/core/validator.py +++ b/rasa/core/validator.py @@ -43,9 +43,9 @@ def verify_intents(self, ignore_warnings: bool = True) -> bool: for intent in self.domain.intents: if intent not in nlu_data_intents: - warnings.warn( + logger.debug( f"The intent '{intent}' is listed in the domain file, but " - "is not found in the NLU training data." + "is not found in the NLU training data.", ) everything_is_alright = ignore_warnings and everything_is_alright @@ -53,7 +53,8 @@ def verify_intents(self, ignore_warnings: bool = True) -> bool: if intent not in self.domain.intents: warnings.warn( f"The intent '{intent}' is in the NLU training data, but " - f"is not listed in the domain." + f"is not listed in the domain.", + stack=2, ) everything_is_alright = False @@ -77,7 +78,9 @@ def verify_example_repetition_in_intents( everything_is_alright = ignore_warnings and everything_is_alright intents_string = ", ".join(sorted(intents)) warnings.warn( - f"The example '{text}' was found in these multiples intents: {intents_string }" + f"The example '{text}' was found in these multiples intents: " + "{intents_string }", + stacklevel=2, ) return everything_is_alright @@ -100,13 +103,16 @@ def verify_intents_in_stories(self, ignore_warnings: bool = True) -> bool: if story_intent not in self.domain.intents: warnings.warn( f"The intent '{story_intent}' is used in stories, but is not " - f"listed in the domain file." + f"listed in the domain file.", + stacklevel=2, ) everything_is_alright = False for intent in self.domain.intents: if intent not in stories_intents: - warnings.warn(f"The intent '{intent}' is not used in any story.") + logger.debug( + f"The intent '{intent}' is not used in any story." + ) everything_is_alright = ignore_warnings and everything_is_alright return everything_is_alright @@ -128,16 +134,18 @@ def verify_utterances(self, ignore_warnings: bool = True) -> bool: for utterance in utterance_templates: if utterance not in actions: - warnings.warn( + logger.debug( f"The utterance '{utterance}' is not listed under 'actions' in the " - "domain file. It can only be used as a template." + "domain file. It can only be used as a template.", ) everything_is_alright = ignore_warnings and everything_is_alright for action in actions: if action.startswith(UTTER_PREFIX): if action not in utterance_templates: - warnings.warn(f"There is no template for utterance '{action}'.") + warnings.warn( + f"There is no template for utterance " "'{action}'.", stack=2 + ) everything_is_alright = False return everything_is_alright @@ -168,14 +176,17 @@ def verify_utterances_in_stories(self, ignore_warnings: bool = True) -> bool: if event.action_name not in utterance_actions: warnings.warn( f"The utterance '{event.action_name}' is used in stories, but is not a " - f"valid utterance." + f"valid utterance.", + stack=2, ) everything_is_alright = False stories_utterances.add(event.action_name) for utterance in utterance_actions: if utterance not in stories_utterances: - warnings.warn(f"The utterance '{utterance}' is not used in any story.") + logger.debug( + f"The utterance '{utterance}' is not used in any story." + ) everything_is_alright = ignore_warnings and everything_is_alright return everything_is_alright From 95edfdb19507a5e18d7ad60b25a99815568c2b4c Mon Sep 17 00:00:00 2001 From: Nikolai Date: Tue, 19 Nov 2019 17:49:59 +0100 Subject: [PATCH 02/12] formatting --- rasa/core/validator.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/rasa/core/validator.py b/rasa/core/validator.py index f5d484abd8f4..e2e5423b1d45 100644 --- a/rasa/core/validator.py +++ b/rasa/core/validator.py @@ -110,9 +110,7 @@ def verify_intents_in_stories(self, ignore_warnings: bool = True) -> bool: for intent in self.domain.intents: if intent not in stories_intents: - logger.debug( - f"The intent '{intent}' is not used in any story." - ) + logger.debug(f"The intent '{intent}' is not used in any story.") everything_is_alright = ignore_warnings and everything_is_alright return everything_is_alright @@ -184,9 +182,7 @@ def verify_utterances_in_stories(self, ignore_warnings: bool = True) -> bool: for utterance in utterance_actions: if utterance not in stories_utterances: - logger.debug( - f"The utterance '{utterance}' is not used in any story." - ) + logger.debug(f"The utterance '{utterance}' is not used in any story.") everything_is_alright = ignore_warnings and everything_is_alright return everything_is_alright From 8574be6bed0c925ff842644e07c2a2bbc8258f03 Mon Sep 17 00:00:00 2001 From: Nikolai Date: Tue, 19 Nov 2019 18:24:45 +0100 Subject: [PATCH 03/12] fix spelling and f strings --- rasa/core/validator.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/rasa/core/validator.py b/rasa/core/validator.py index e2e5423b1d45..d7f14ad782c0 100644 --- a/rasa/core/validator.py +++ b/rasa/core/validator.py @@ -45,7 +45,7 @@ def verify_intents(self, ignore_warnings: bool = True) -> bool: if intent not in nlu_data_intents: logger.debug( f"The intent '{intent}' is listed in the domain file, but " - "is not found in the NLU training data.", + f"is not found in the NLU training data.", ) everything_is_alright = ignore_warnings and everything_is_alright @@ -54,7 +54,7 @@ def verify_intents(self, ignore_warnings: bool = True) -> bool: warnings.warn( f"The intent '{intent}' is in the NLU training data, but " f"is not listed in the domain.", - stack=2, + stacklevel=2, ) everything_is_alright = False @@ -79,7 +79,7 @@ def verify_example_repetition_in_intents( intents_string = ", ".join(sorted(intents)) warnings.warn( f"The example '{text}' was found in these multiples intents: " - "{intents_string }", + f"{intents_string}.", stacklevel=2, ) return everything_is_alright @@ -134,7 +134,7 @@ def verify_utterances(self, ignore_warnings: bool = True) -> bool: if utterance not in actions: logger.debug( f"The utterance '{utterance}' is not listed under 'actions' in the " - "domain file. It can only be used as a template.", + f"domain file. It can only be used as a template.", ) everything_is_alright = ignore_warnings and everything_is_alright @@ -142,7 +142,8 @@ def verify_utterances(self, ignore_warnings: bool = True) -> bool: if action.startswith(UTTER_PREFIX): if action not in utterance_templates: warnings.warn( - f"There is no template for utterance " "'{action}'.", stack=2 + f"There is no template for utterance '{action}'.", + stacklevel=2 ) everything_is_alright = False @@ -175,7 +176,7 @@ def verify_utterances_in_stories(self, ignore_warnings: bool = True) -> bool: warnings.warn( f"The utterance '{event.action_name}' is used in stories, but is not a " f"valid utterance.", - stack=2, + stacklevel=2, ) everything_is_alright = False stories_utterances.add(event.action_name) From 80fde788d561be62a3d62e7acbe8e8f354a8fe9e Mon Sep 17 00:00:00 2001 From: Nikolai Date: Tue, 19 Nov 2019 18:25:51 +0100 Subject: [PATCH 04/12] formatting --- rasa/core/validator.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rasa/core/validator.py b/rasa/core/validator.py index d7f14ad782c0..b4482fcb4ebf 100644 --- a/rasa/core/validator.py +++ b/rasa/core/validator.py @@ -142,8 +142,7 @@ def verify_utterances(self, ignore_warnings: bool = True) -> bool: if action.startswith(UTTER_PREFIX): if action not in utterance_templates: warnings.warn( - f"There is no template for utterance '{action}'.", - stacklevel=2 + f"There is no template for utterance '{action}'.", stacklevel=2 ) everything_is_alright = False From 27a8bbb7b472487c6506a03150425cf0af5b49be Mon Sep 17 00:00:00 2001 From: Nikolai Date: Thu, 28 Nov 2019 14:15:02 +0100 Subject: [PATCH 05/12] Update rasa/core/validator.py Co-Authored-By: Ella Rohm-Ensing --- rasa/core/validator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rasa/core/validator.py b/rasa/core/validator.py index b4482fcb4ebf..8a3337b0a212 100644 --- a/rasa/core/validator.py +++ b/rasa/core/validator.py @@ -78,7 +78,7 @@ def verify_example_repetition_in_intents( everything_is_alright = ignore_warnings and everything_is_alright intents_string = ", ".join(sorted(intents)) warnings.warn( - f"The example '{text}' was found in these multiples intents: " + f"The example '{text}' was found in multiple intents: " f"{intents_string}.", stacklevel=2, ) From ccee5f72a225c4f3181e119f6dc482ab0099c562 Mon Sep 17 00:00:00 2001 From: !whoami Date: Tue, 3 Dec 2019 13:46:22 +0100 Subject: [PATCH 06/12] added changelog entry --- changelog/4759.misc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/4759.misc.rst diff --git a/changelog/4759.misc.rst b/changelog/4759.misc.rst new file mode 100644 index 000000000000..ae7e183a3cf1 --- /dev/null +++ b/changelog/4759.misc.rst @@ -0,0 +1 @@ +Replaced the warnings about missing templates, intents etc. in validator.py by debug messages. From 2085102d423031abbf3d66c787d937a18d17f7fb Mon Sep 17 00:00:00 2001 From: !whoami Date: Tue, 3 Dec 2019 13:55:06 +0100 Subject: [PATCH 07/12] update the docs abouts --debug in validator --- docs/user-guide/validate-files.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/user-guide/validate-files.rst b/docs/user-guide/validate-files.rst index 90a07c03a882..a8e732e1498f 100644 --- a/docs/user-guide/validate-files.rst +++ b/docs/user-guide/validate-files.rst @@ -23,6 +23,11 @@ the script: .. program-output:: rasa data validate --help +By default the validator searches only for errors in the data (e.g. the same +example being listed as an example for two intents), but does not report other +minor issues (such as unused intents, utterances that are not listed as +actions). To also report the later use the ``-debug`` flag. + You can also run these validations through the Python API by importing the `Validator` class, which has the following methods: From c865c03fe1e60c4122ac4c0ad56a4ce0fa46e120 Mon Sep 17 00:00:00 2001 From: !whoami Date: Tue, 3 Dec 2019 13:55:56 +0100 Subject: [PATCH 08/12] formatting --- rasa/core/events/__init__.py | 5 +---- rasa/core/validator.py | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/rasa/core/events/__init__.py b/rasa/core/events/__init__.py index 212bd28ab773..d88057092683 100644 --- a/rasa/core/events/__init__.py +++ b/rasa/core/events/__init__.py @@ -144,10 +144,7 @@ def _from_story_string(cls, parameters: Dict[Text, Any]) -> Optional[List["Event return [cls(parameters.get("timestamp"), parameters.get("metadata"))] def as_dict(self) -> Dict[Text, Any]: - d = { - "event": self.type_name, - "timestamp": self.timestamp, - } + d = {"event": self.type_name, "timestamp": self.timestamp} if self.metadata: d["metadata"] = self.metadata diff --git a/rasa/core/validator.py b/rasa/core/validator.py index 8a3337b0a212..c6463df8aa4e 100644 --- a/rasa/core/validator.py +++ b/rasa/core/validator.py @@ -45,7 +45,7 @@ def verify_intents(self, ignore_warnings: bool = True) -> bool: if intent not in nlu_data_intents: logger.debug( f"The intent '{intent}' is listed in the domain file, but " - f"is not found in the NLU training data.", + f"is not found in the NLU training data." ) everything_is_alright = ignore_warnings and everything_is_alright @@ -134,7 +134,7 @@ def verify_utterances(self, ignore_warnings: bool = True) -> bool: if utterance not in actions: logger.debug( f"The utterance '{utterance}' is not listed under 'actions' in the " - f"domain file. It can only be used as a template.", + f"domain file. It can only be used as a template." ) everything_is_alright = ignore_warnings and everything_is_alright From 39ec457cbdc5da3c2c165c52330bdaf78144fe31 Mon Sep 17 00:00:00 2001 From: !whoami Date: Tue, 3 Dec 2019 14:10:20 +0100 Subject: [PATCH 09/12] fix changelog name --- changelog/{4759.misc.rst => 4795.feature.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{4759.misc.rst => 4795.feature.rst} (100%) diff --git a/changelog/4759.misc.rst b/changelog/4795.feature.rst similarity index 100% rename from changelog/4759.misc.rst rename to changelog/4795.feature.rst From eafc77e375e73eb7989df9513df4f40999f109e0 Mon Sep 17 00:00:00 2001 From: !whoami Date: Tue, 3 Dec 2019 15:10:48 +0100 Subject: [PATCH 10/12] fix test --- tests/core/test_validator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/test_validator.py b/tests/core/test_validator.py index 4e098fbdfd13..fe1aa17e2b63 100644 --- a/tests/core/test_validator.py +++ b/tests/core/test_validator.py @@ -82,7 +82,7 @@ async def test_verify_logging_message_for_repetition_in_intents(caplog): validator.verify_example_repetition_in_intents(False) assert len(record) == 1 assert ( - "The example 'good afternoon' was found in these " + "The example 'good afternoon' was found " "multiples intents: goodbye, greet" in record[0].message.args[0] ) From ecfde98003307f35b5c3068ecaf261efc2ffa2e9 Mon Sep 17 00:00:00 2001 From: !whoami Date: Tue, 3 Dec 2019 16:08:30 +0100 Subject: [PATCH 11/12] fix another typo in test --- tests/core/test_validator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/test_validator.py b/tests/core/test_validator.py index fe1aa17e2b63..6313025ecbc1 100644 --- a/tests/core/test_validator.py +++ b/tests/core/test_validator.py @@ -82,7 +82,7 @@ async def test_verify_logging_message_for_repetition_in_intents(caplog): validator.verify_example_repetition_in_intents(False) assert len(record) == 1 assert ( - "The example 'good afternoon' was found " + "The example 'good afternoon' was found in " "multiples intents: goodbye, greet" in record[0].message.args[0] ) From cf82823a36fcc68ace10640ad3f3ad1b984a2899 Mon Sep 17 00:00:00 2001 From: !whoami Date: Tue, 3 Dec 2019 16:10:09 +0100 Subject: [PATCH 12/12] and another typo --- tests/core/test_validator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/test_validator.py b/tests/core/test_validator.py index 6313025ecbc1..f9ccc6b77fb2 100644 --- a/tests/core/test_validator.py +++ b/tests/core/test_validator.py @@ -83,7 +83,7 @@ async def test_verify_logging_message_for_repetition_in_intents(caplog): assert len(record) == 1 assert ( "The example 'good afternoon' was found in " - "multiples intents: goodbye, greet" in record[0].message.args[0] + "multiple intents: goodbye, greet" in record[0].message.args[0] )