From c9ef80d58a7134bd32bdbd386447b2c53e82f611 Mon Sep 17 00:00:00 2001 From: Nikolai Date: Tue, 10 Sep 2019 15:03:36 +0200 Subject: [PATCH 1/5] fix checking for mapping policy --- rasa/core/policies/ensemble.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/rasa/core/policies/ensemble.py b/rasa/core/policies/ensemble.py index 2bd8a98796e3..941658ef0ba8 100644 --- a/rasa/core/policies/ensemble.py +++ b/rasa/core/policies/ensemble.py @@ -53,17 +53,20 @@ def __init__( self._check_for_important_policies() def _check_for_important_policies(self): - if "MappingPolicy" not in self.policies: - logger.info( - "MappingPolicy not included in policy ensemble. Default intents " - "'{} and {} will not trigger actions '{}' and '{}'." - "".format( - USER_INTENT_RESTART, - USER_INTENT_BACK, - ACTION_RESTART_NAME, - ACTION_BACK_NAME, - ) + for policy in self.policies: + if "MappingPolicy" in type(policy).__name__: + return + # if the mapping policy is not in the enemble print this message + logger.info( + "MappingPolicy not included in policy ensemble. Default intents " + "'{} and {} will not trigger actions '{}' and '{}'." + "".format( + USER_INTENT_RESTART, + USER_INTENT_BACK, + ACTION_RESTART_NAME, + ACTION_BACK_NAME, ) + ) @staticmethod def _training_events_from_trackers(training_trackers): From f1e3bd8d99ef56886754c0a787814e7c8b34f475 Mon Sep 17 00:00:00 2001 From: Nikolai Date: Tue, 10 Sep 2019 15:27:20 +0200 Subject: [PATCH 2/5] updated changelog --- CHANGELOG.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8c87ca645667..6c31c62c93c5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,14 @@ Rasa Change Log All notable changes to this project will be documented in this file. This project adheres to `Semantic Versioning`_ starting with version 1.0. +[1.3.3] - Unreleased +^^^^^^^^^^^^^^^^^^^^ + +Fixed +----- +- Policy ensemble no longer incorrectly wrings "missing mapping policy" when + mapping policy is present. + [1.3.2] - 2019-09-10 ^^^^^^^^^^^^^^^^^^^^ From 709c383607183db75a9e909eeeb10b480689200e Mon Sep 17 00:00:00 2001 From: Nikolai Date: Tue, 10 Sep 2019 15:38:04 +0200 Subject: [PATCH 3/5] more readable check --- rasa/core/policies/ensemble.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/rasa/core/policies/ensemble.py b/rasa/core/policies/ensemble.py index 941658ef0ba8..6588214c292e 100644 --- a/rasa/core/policies/ensemble.py +++ b/rasa/core/policies/ensemble.py @@ -25,6 +25,7 @@ from rasa.core.exceptions import UnsupportedDialogueModelError from rasa.core.featurizers import MaxHistoryTrackerFeaturizer from rasa.core.policies.policy import Policy +from rasa.core.policies.mapping_policy import MappingPolicy from rasa.core.policies.fallback import FallbackPolicy from rasa.core.policies.memoization import MemoizationPolicy, AugmentedMemoizationPolicy from rasa.core.trackers import DialogueStateTracker @@ -53,20 +54,18 @@ def __init__( self._check_for_important_policies() def _check_for_important_policies(self): - for policy in self.policies: - if "MappingPolicy" in type(policy).__name__: - return - # if the mapping policy is not in the enemble print this message - logger.info( - "MappingPolicy not included in policy ensemble. Default intents " - "'{} and {} will not trigger actions '{}' and '{}'." - "".format( - USER_INTENT_RESTART, - USER_INTENT_BACK, - ACTION_RESTART_NAME, - ACTION_BACK_NAME, + if not any([isinstance(policy, MappingPolicy) for policy in + self.policies]): + logger.info( + "MappingPolicy not included in policy ensemble. Default intents " + "'{} and {} will not trigger actions '{}' and '{}'." + "".format( + USER_INTENT_RESTART, + USER_INTENT_BACK, + ACTION_RESTART_NAME, + ACTION_BACK_NAME, + ) ) - ) @staticmethod def _training_events_from_trackers(training_trackers): From cdff4a0b16829ddfa3796292ba8bcd743c7c5fe4 Mon Sep 17 00:00:00 2001 From: Nikolai Date: Tue, 10 Sep 2019 15:51:15 +0200 Subject: [PATCH 4/5] style --- rasa/core/policies/ensemble.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rasa/core/policies/ensemble.py b/rasa/core/policies/ensemble.py index 6588214c292e..cf7616a2ef8a 100644 --- a/rasa/core/policies/ensemble.py +++ b/rasa/core/policies/ensemble.py @@ -54,8 +54,7 @@ def __init__( self._check_for_important_policies() def _check_for_important_policies(self): - if not any([isinstance(policy, MappingPolicy) for policy in - self.policies]): + if not any([isinstance(policy, MappingPolicy) for policy in self.policies]): logger.info( "MappingPolicy not included in policy ensemble. Default intents " "'{} and {} will not trigger actions '{}' and '{}'." From 189f9a4b63fcdc7de74cb3d48225b40221dbea27 Mon Sep 17 00:00:00 2001 From: Nikolai Date: Fri, 13 Sep 2019 11:10:18 +0200 Subject: [PATCH 5/5] remove some empty lines --- CHANGELOG.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ccb3247bc838..7ce78fd0f5ec 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -16,17 +16,13 @@ Fixed - Policy ensemble no longer incorrectly wrings "missing mapping policy" when mapping policy is present. - [1.3.3] - 2019-09-11 - ^^^^^^^^^^^^^^^^^^^^ Fixed ----- - Added a check to avoid training CountVectorizer for a particular attribute of a message if no text is provided for that attribute across the training data. - - [1.3.2] - 2019-09-10 ^^^^^^^^^^^^^^^^^^^^