How to run all servers from Python

I want to run the NLU and action server from Python (rasa run && rasa run actions). I have thought of writing a BASH script that does it but I don’t like that idea since it limits my possibilities.

I wasn’t able to find any documentation on how to run the servers from Python and not through the terminal. I was looking through github and after a while I came up with this code.

from rasa.model import get_model, get_latest_model, get_model_subdirectories
from rasa.exceptions import ModelNotFound
import rasa

    model_path = get_latest_model()
except ModelNotFound:
    print("No model found. Train a model before running the server using `rasa train nlu`."), endpoints=DEFAULT_ENDPOINTS_PATH, 
        connector="rest", credentials=DEFAULT_CREDENTIALS_PATH)

This runs the NLU server but I couldn’t find how to make the action server run as well and this function doesn’t return until the application exits. Is there a function that exists when the server has started and keeps it running on a separate thread? I don’t want to keep sending messages to check if the server is online already.

Is it recommended to use the Agent defined here Agent for this? If so, is there any sample code? Or, of course, any other sample code for what I am trying to do?

we have docs that describe how to run rasa from Jupyter Notebook: Jupyter Notebooks