Repository: rasahq/rasa
Issue: rasa run --enable-api without model

<!-- THIS INFORMATION IS MANDATORY - YOUR ISSUE WILL BE CLOSED IF IT IS MISSING. If you don't know your Rasa Core version, use `pip list | grep rasa`. Removing the below information is allowed for FEATURE REQUESTS. --> 

**Rasa version**: 1.0.1

**Python version**: Python 3.6.8

**Operating system** (windows, osx, ...): Linux/Docker

**Issue**: When executing `rasa run --enable-api ` without any model passed as argument or provided in the default models directory, the programm shows the following error message and exits:
```
No model found. Train a model before running the server using `rasa train`.
```
In my use case, I only want to start rasa without an initial model, because I want to train models using the http api `http://localhost:5005/model/train` and later load a trained model with `http://localhost:5005/model`. Would be nice to be able to start the rasa http server without any model.

My workaround for now is to check at first, if there exists a model in the `models` directory and run `rasa init` if there is no model existing. After that I can run `rasa run --enable-api`.


**Content of configuration file (config.yml)**:
```yml
                    language: "de"
                    pipeline:
                    - name: "WhitespaceTokenizer"
                    - name: "CRFEntityExtractor"
                    - name: "EntitySynonymMapper"
                    - name: "CountVectorsFeaturizer"
                    - name: "EmbeddingIntentClassifier"
```




Changed files:
rasa/core/agent.py, rasa/cli/run.py, rasa/run.py, rasa/core/run.py, rasa/model.py

diff --git a/rasa/cli/run.py b/rasa/cli/run.py
index 0af1e55a2db..be3580eb66b 100644
--- a/rasa/cli/run.py
+++ b/rasa/cli/run.py
@@ -1,10 +1,10 @@
 import argparse
 import logging
 import os
-from typing import List
+from typing import List, Text, Optional
 
 from rasa.cli.arguments import run as arguments
-from rasa.cli.utils import get_validated_path
+from rasa.cli.utils import get_validated_path, print_error
 from rasa.constants import (
     DEFAULT_ACTIONS_PATH,
     DEFAULT_CREDENTIALS_PATH,
@@ -56,10 +56,41 @@ def run_actions(args: argparse.Namespace):
     sdk.main_from_args(args)
 
 
+def _validate_model_path(model_path: Text, parameter: Text, default: Text):
+
+    if model_path is not None and not os.path.exists(model_path):
+        reason_str = "'{}' not found.".format(model_path)
+        if model_path is None:
+            reason_str = "Parameter '{}' not set.".format(parameter)
+
+        logger.debug(
+            "{} Using default location '{}' instead.".format(reason_str, default)
+        )
+
+        os.makedirs(default, exist_ok=True)
+        model_path = default
+
+    return model_path
+
+
 def run(args: argparse.Namespace):
     import rasa.run
 
-    args.model = get_validated_path(args.model, "model", DEFAULT_MODELS_PATH)
+    args.model = _validate_model_path(args.model, "model", DEFAULT_MODELS_PATH)
+
+    if not args.enable_api:
+        # if the API is enabled you can start without a model as you can train a
+        # model via the API once the server is up and running
+        from rasa.model import get_model
+
+        model_path = get_model(args.model)
+        if not model_path:
+            print_error(
+                "No model found. Train a model before running the "
+                "server using `rasa train`."
+            )
+            return
+
     args.endpoints = get_validated_path(
         args.endpoints, "endpoints", DEFAULT_ENDPOINTS_PATH, True
     )
diff --git a/rasa/core/agent.py b/rasa/core/agent.py
index 0a90b003566..725c5482e74 100644
--- a/rasa/core/agent.py
+++ b/rasa/core/agent.py
@@ -258,7 +258,7 @@ async def load_agent(
             )
 
         else:
-            logger.error("No valid configuration given to load agent.")
+            logger.warning("No valid configuration given to load agent.")
             return None
 
     except Exception as e:
diff --git a/rasa/core/run.py b/rasa/core/run.py
index 150faf76960..69111c9ebde 100644
--- a/rasa/core/run.py
+++ b/rasa/core/run.py
@@ -208,8 +208,8 @@ async def load_agent_on_start(
     )
 
     if not app.agent:
-        logger.error(
-            "Agent could not be loaded with the provided configuration."
+        logger.warning(
+            "Agent could not be loaded with the provided configuration. "
             "Load default agent without any model."
         )
         app.agent = Agent(
diff --git a/rasa/model.py b/rasa/model.py
index 8ec14eeb084..64926e0e6b3 100644
--- a/rasa/model.py
+++ b/rasa/model.py
@@ -49,6 +49,8 @@ def get_model(model_path: Text = DEFAULT_MODELS_PATH) -> Optional[Text]:
     """
     if not model_path:
         return None
+    elif not os.path.exists(model_path):
+        return None
     elif os.path.isdir(model_path):
         model_path = get_latest_model(model_path)
 
diff --git a/rasa/run.py b/rasa/run.py
index 80c49de9c9e..c9c0b70bb52 100644
--- a/rasa/run.py
+++ b/rasa/run.py
@@ -38,12 +38,6 @@ def run(
     from rasa.core.utils import AvailableEndpoints
 
     model_path = get_model(model)
-    if not model_path:
-        print_error(
-            "No model found. Train a model before running the "
-            "server using `rasa train`."
-        )
-        return
 
     _endpoints = AvailableEndpoints.read_endpoints(endpoints)
 
@@ -65,7 +59,8 @@ def run(
         **kwargs
     )
 
-    shutil.rmtree(model_path)
+    if model_path is not None:
+        shutil.rmtree(model_path)
 
 
 def create_agent(model: Text, endpoints: Text = None) -> "Agent":