Repository: opsdroid/opsdroid

Issue:
Use pre-trained Rasa model.
<!-- Before you post an issue or if you are unsure about something join our matrix channel https://app.element.io/#/room/#opsdroid-general:matrix.org and ask away! We are more than happy to help you. -->
# Description
There is no option to take a pre-trained Rasa model (perhaps trained on a more powerful machine) and use that for predictions instead of training a new model each time opsdroid is started.


## Expected Functionality
There should be a configuration option under something such as `parsers->rasanlu->no-train` which by default is false, but can be set to true in order to prevent opsdroid sending the request to re-train each time.


## Experienced Functionality
No such option exists.

## Versions
- **Opsdroid version:**0.23.0
- **Python version:**3.9.2
- **OS/Docker version:**Debian 11



<!-- Love opsdroid? Please consider supporting our collective:
 +👉  https://opencollective.com/opsdroid/donate -->



Discussion:
Thank you for raising this issue @DAMO238  is this still the case? I'm just catching up on the convo in our community channel
Yes, this is still an issue. I used a work around by commenting out the line of code responsible for training rasa in my installation, but this is more of a hacky work around than a solution. There seem to already be functions for loading a model and checking if rasa already has a model loaded. I propose that opsdroid should check if rasa has a model loaded, and then, only if there is no model, check the configuration to see if a model should be loaded and then finally, fallback to training the model (current functionality).
Ah gotcha thank you again for raising this and for the clarification 👍 
Can I ask you for an example on your configuration? Are you providing an intentions yaml file with your rasa config?

Looking at the docs it seems that we only train the model if you provide the intents yaml file.

Resolving patch:
diff --git a/opsdroid/core.py b/opsdroid/core.py
--- a/opsdroid/core.py
+++ b/opsdroid/core.py
@@ -1,39 +1,39 @@
 """Core components of OpsDroid."""
 
+import asyncio
+import contextlib
 import copy
+import inspect
 import logging
 import os
 import signal
 import sys
 import weakref
-import asyncio
-import contextlib
-import inspect
-from watchgod import awatch, PythonWatcher
+
+from watchgod import PythonWatcher, awatch
 
 from opsdroid import events
-from opsdroid.const import DEFAULT_CONFIG_LOCATIONS
-from opsdroid.memory import Memory
-from opsdroid.connector import Connector
 from opsdroid.configuration import load_config_file
+from opsdroid.connector import Connector
+from opsdroid.const import DEFAULT_CONFIG_LOCATIONS
 from opsdroid.database import Database, InMemoryDatabase
-from opsdroid.skill import Skill
+from opsdroid.helper import get_parser_config
 from opsdroid.loader import Loader
-from opsdroid.web import Web
+from opsdroid.memory import Memory
 from opsdroid.parsers.always import parse_always
 from opsdroid.parsers.catchall import parse_catchall
-from opsdroid.parsers.event_type import parse_event_type
-from opsdroid.parsers.regex import parse_regex
-from opsdroid.parsers.parseformat import parse_format
+from opsdroid.parsers.crontab import parse_crontab
 from opsdroid.parsers.dialogflow import parse_dialogflow
+from opsdroid.parsers.event_type import parse_event_type
 from opsdroid.parsers.luisai import parse_luisai
+from opsdroid.parsers.parseformat import parse_format
+from opsdroid.parsers.rasanlu import parse_rasanlu, train_rasanlu
+from opsdroid.parsers.regex import parse_regex
 from opsdroid.parsers.sapcai import parse_sapcai
-from opsdroid.parsers.witai import parse_witai
 from opsdroid.parsers.watson import parse_watson
-from opsdroid.parsers.rasanlu import parse_rasanlu, train_rasanlu
-from opsdroid.parsers.crontab import parse_crontab
-from opsdroid.helper import get_parser_config
-
+from opsdroid.parsers.witai import parse_witai
+from opsdroid.skill import Skill
+from opsdroid.web import Web
 
 _LOGGER = logging.getLogger(__name__)
 
@@ -351,7 +351,7 @@ async def train_parsers(self, skills):
         if "parsers" in self.modules:
             parsers = self.modules.get("parsers", {})
             rasanlu = get_parser_config("rasanlu", parsers)
-            if rasanlu and rasanlu["enabled"]:
+            if rasanlu and rasanlu["enabled"] and rasanlu.get("train", True):
                 await train_rasanlu(rasanlu, skills)
 
     async def setup_connectors(self, connectors):


Test patch: