From d6b7aa913923fffef59bd062cabe0bc8fa98d183 Mon Sep 17 00:00:00 2001 From: Tobias Wochinger Date: Wed, 18 Dec 2019 10:32:26 +0100 Subject: [PATCH 1/3] use empty domain in case Domain is None (e.g. if it's a NLU only model) --- rasa/core/agent.py | 2 +- tests/core/test_agent.py | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/rasa/core/agent.py b/rasa/core/agent.py index e75cb03fdc64..cac664589a87 100644 --- a/rasa/core/agent.py +++ b/rasa/core/agent.py @@ -336,7 +336,7 @@ def update_model( interpreter: Optional[NaturalLanguageInterpreter] = None, model_directory: Optional[Text] = None, ) -> None: - self.domain = domain + self.domain = self._create_domain(domain) self.policy_ensemble = policy_ensemble if interpreter: diff --git a/tests/core/test_agent.py b/tests/core/test_agent.py index d5e836edeb0b..0fe3a5c3e17d 100644 --- a/tests/core/test_agent.py +++ b/tests/core/test_agent.py @@ -250,13 +250,10 @@ def test_two_stage_fallback_without_deny_suggestion(domain, policy_config): async def test_agent_update_model_none_domain(trained_model: Text): agent = await load_agent(model_path=trained_model) agent.update_model( - Domain.empty(), - None, - agent.fingerprint, - agent.interpreter, - agent.model_directory, + None, None, agent.fingerprint, agent.interpreter, agent.model_directory ) + assert agent.domain is not None sender_id = "test_sender_id" message = UserMessage("hello", sender_id=sender_id) await agent.handle_message(message) From a2e6804bd901a9aa0820ee57d032559e88bb274c Mon Sep 17 00:00:00 2001 From: Tobias Wochinger Date: Wed, 18 Dec 2019 10:36:36 +0100 Subject: [PATCH 2/3] add changelog entry for bugfix --- changelog/4989.bugfix.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelog/4989.bugfix.rst diff --git a/changelog/4989.bugfix.rst b/changelog/4989.bugfix.rst new file mode 100644 index 000000000000..5cefcf1d8c70 --- /dev/null +++ b/changelog/4989.bugfix.rst @@ -0,0 +1,2 @@ +Use an empty domain in case a model is loaded which has no domain +(avoids errors when accessing ``agent.doman.``. From dcf65caa4e65e9b771568ada5650b0c0a594d3de Mon Sep 17 00:00:00 2001 From: Tobias Wochinger Date: Wed, 18 Dec 2019 11:04:18 +0100 Subject: [PATCH 3/3] implement review comments --- changelog/4989.bugfix.rst | 2 +- rasa/core/agent.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog/4989.bugfix.rst b/changelog/4989.bugfix.rst index 5cefcf1d8c70..f27401fab993 100644 --- a/changelog/4989.bugfix.rst +++ b/changelog/4989.bugfix.rst @@ -1,2 +1,2 @@ Use an empty domain in case a model is loaded which has no domain -(avoids errors when accessing ``agent.doman.``. +(avoids errors when accessing ``agent.doman.``). diff --git a/rasa/core/agent.py b/rasa/core/agent.py index cac664589a87..891c315dacba 100644 --- a/rasa/core/agent.py +++ b/rasa/core/agent.py @@ -845,7 +845,7 @@ def create_processor( ) @staticmethod - def _create_domain(domain: Union[Domain, Text]) -> Domain: + def _create_domain(domain: Union[Domain, Text, None]) -> Domain: if isinstance(domain, str): domain = Domain.load(domain)