-
Notifications
You must be signed in to change notification settings - Fork 1
Setup
You can run Convo and its services all separately by running each server in a separate terminal or by using Docker. If you run into any errors during the setup process, please first try consulting the Common Errors page.
The first thing you need to do is clone the Convo repository.
Before running the Convo servers, you need to create a database for storing user information and programs. You can do so with the following steps
- Go to
backend/serverdirectory in the Convo repository you cloned, and install all required Python packages usingpip
cd backend/server
pip install -r requirements.txt- Start a Python shell using
python3(or justpython, if it's aliased to Python 3), and in the shell environment and execute the lines
from db_manage import db
db.create_all()- Exit the Python environment (with
exit()) and go to thebackend/server/dbdirectory. You should see aconvo.dbfile inside. This is the file containing the SQL database for Convo. If you havesqlite3installed, you can access the file and query through it.
To be able to use Google's Speech-to-Text API, you must create an account and a project on Google Cloud Platform (GCP). Go to Google's Quickstart for instructions on setting everything up and getting a private key. Download your private key as a JSON file and name it gcpkey.json (or another name that you can remember).
Once you obtain your private key, move your key gcpkey.json to api. Copy the file .env.sample from api and rename it .env. Set the value of the environment variable GOOGLE_APPLICATION_CREDENTIALS in .env to the relative path of the key. For example, if you named the key gcpkey.json, the contents of the .env file should be
GOOGLE_APPLICATION_CREDENTIALS="gcpkey.json"If you run into issues with this method, we recommend creating a service account, following the instructions here. Like before, download your service account key as a JSON file and name it servicekey.json (or another name that you can remember). Then, move servicekey.json to the api directory and the contents of the .env file should be
GOOGLE_APPLICATION_CREDENTIALS="servicekey.json"Currently, the Node modules won't automatically install (even with Docker), so you will have to manually do this. Before you can do so, ensure you have Node.js and npm installed on your machine. Next, go to the frontend directory and run
npm installFor the unconstrained NL to work, you have to train a model. To do so:
- Enter the Docker container for Rasa:
# In a new terminal, go to the convo directory and start docker:
# (You'll see a warning, "UserWarning: Could not load local model in 'models'.", but that's okay)
cd convo
docker-compose -f docker-compose.local.yml up
# In a different terminal, find the Rasa container's ID:
docker container list
# Take note of CONTAINER ID next to the "convo_rasa" IMAGE
# Now, using that CONTAINER ID, run the following command to enter the container:
docker exec -it RASA_CONTAINER_ID /bin/bash # where RASA_CONTAINER_ID is something like 4c0d64d7e54e- Train the NLU model:
# Within the rasa container (in the /app directory — you can check by running `pwd`), train the model:
rasa trainOnce training is completed, you should see a message like NLU model training completed. Your Rasa model is trained and saved at '/app/models/nlu-20210202-162725.tar.gz'.
-
Exit the Docker container with the exit command (literally,
exit) and close this terminal. -
Stop the Docker containers by going back to the first terminal (where you ran docker-compose) and hitting Control+C. You should now have a model in the
models/directory:
ls backend/rasa/models # if you run this command...
nlu-20210202-162725.tar.gz # you should see something like this
On the master branch, the pages served by the UI connect via WebSockets to the Node and Python servers on your local computer by default. On different branches or older commits, the WebSockets may connect to the production servers on userstudy.appinventor.mit.edu by default (and in this case, if you make any changes to the servers on your local computer, these changes won't be reflected when you run docker-compose).
To ensure the UI is connecting to your local Node and Python servers, check that the following files have the lines with http://localhost:5000 uncommented and the lines with https://... commented out.
- In
frontend/public/js/experiment.js:- Ensure line 2 (
const server = 'https://userstudy.appinventor.mit.edu/api';) is commented out - Ensure line 4 (
const server = 'http://localhost:5000';) is uncommented
- Ensure line 2 (
- In
frontend/public/js/socket.js:- Ensure lines 2-3 (
const socket = io.connect("https://...andconst socketApi = io.connect("https:...) are commented out - Ensure lines 5-6 (
const socket = io.connect('http://localhost:8080');andconst socketApi = io.connect('http://localhost:5000');) are uncommented
- Ensure lines 2-3 (
On the master branch, the pages served by the UI connect via WebSockets to the Node and Python servers on your local computer by default. For running production, they should connect to the production servers.
To ensure the UI is connecting to your production Node and Python servers, check that the following files have the lines with http://localhost:5000 commented out and the lines with https://... uncommented.
- In
frontend/public/js/experiment.js:- Ensure line 2 (
const server = 'https://userstudy.appinventor.mit.edu/api';) is uncommented - Ensure line 4 (
const server = 'http://localhost:5000';) is commented out
- Ensure line 2 (
- In
frontend/public/js/socket.js:- Ensure lines 2-3 (
const socket = io.connect("https://...andconst socketApi = io.connect("https:...) are uncommented - Ensure lines 5-6 (
const socket = io.connect('http://localhost:8080');andconst socketApi = io.connect('http://localhost:5000');) are commented out
- Ensure lines 2-3 (
Docker is the recommended setup for local and remote development. In addition, the production servers are run using Docker.
To setup with Docker, make sure you have Docker and Docker Compose installed on the machine. To install both, install Docker for Mac or Docker for Windows and Docker Compose should be included. (Note that Docker runs natively on Mac and Linux systems, but may not run on Windows machines, unless you have the most up-to-date version of Windows, which you can find on the official Microsoft website. Once your Windows is up to date, try following the instructions here to set up Docker for Windows. If this doesn't work, you can also consider partitioning your machine and installing Docker for Linux.)
Once you have Docker, you should be able to run
docker -v && docker-compose -vand output should be similar to
Docker version 19.03.2, build 6a30dfc
docker-compose version 1.24.1, build 4667896bDocker Compose automatically runs the web, server and rasa services that are defined in the docker-compose*.yml.
-
server- Convo Core or the backend server -
web- Convo VUI or frontend that allows clients to interface with Convo Core -
rasa- Rasa server containing a trained model
There are actually three YAML files that can be used with docker-compose - docker-compose.yml and docker-compose.prod.yml and docker-compose.local.yml
-
docker-compose.prod.ymlis used in the case where an admin username and password is required to enter the website -
docker-compose.local.ymlis used for local development - main difference is no service is needed for a reverse-proxy and CertBot since everything is local
For example, to run Docker on your local machine, you can run
docker-compose -f docker-compose.local.yml up --build
(If you have previously built the docker container, you can just run, docker-compose -f docker-compose.local.yml up.)
If you are running Docker in the background (with the flag -d), to stop the system, use
docker-compose downOnce the Docker container is running, skip down to the After Setting Up section.
We recommend you setup with Docker, but if you would rather run each server manually, you can follow these instructions. You need to run three (one optional) servers to get Convo fully working.
Install Node through a package manager(recommended) or through an installer. Run
npm installin the frontend directory to install the necessary modules and lastly run
npm startto start the Node server.
Install Python 3.7, if not on machine. If on MacOS, I recommend installing through Homebrew
brew install pythonIn the backend/server directory, install the necessary packages
cd backend/server
pip install -r requirements.txtStart the server using
gunicorn --worker-class eventlet -w 1 --bind 0.0.0.0:5000 --log-level=info manage:appGo to the Rasa wiki page for information on Rasa and its setup.
After setting up and starting the servers (running either separately or through Docker), head to http://localhost:8080 (or http(s)://[host]:8080 for the remote server). You should see the user study website.
You can head to /debug (e.g., http://localhost:8080/debug) if you want to test the Convo UI and backend server. You may also want to head to one of the user study stages (e.g., the practice stage or voice and text sandbox) with both voice and text enabled to test the voice-based system too.
You can see urls for other pages in the frontend/app.js file. For example,
app.get('/voice-and-text', (req, res) => res.sendFile(path.resolve('public/html/experiment-templates/voice-and-text.html')));
corresponds to http://localhost:8080/voice-and-text.