Skip to content

Running Locally

Amy Boyer edited this page Aug 22, 2019 · 4 revisions

Required services

Make sure that you have an entry in your /etc/hosts file that looks like this:

127.0.0.1 postgres

so that we can find the postgres server when the app is running locally

Install the correct version of postgres:

brew install [email protected]

If you already had a postgres install, you should be able to select your postgres version this way:

brew switch postgresql 9.4

If not, you can also use this keg-only formula by force-linking it:

brew link [email protected] --force

Add the user theia with password theia:

createuser theia -d -P

Make sure that you have an entry in your /etc/hosts file that looks like this:

127.0.0.1 redis

so that we can find the redis server when the app is running locally

Install the current version of redis:

brew install redis

Required Libraries

Install GIS related dependencies:

brew install postgis gdal

Install other related dependencies:

brew install libtiff

Language and dependencies

Ensure that you have a modern python (note, you can also use pyenv for this but it's a little trickier to set up):

brew install python

and follow the installation notes to put python3 as python in your $PATH. You may also wish to upgrade pip if it prompts you.

Then use pip to install pipenv package and virtual environment manager

pip install pipenv

Then use pipenv in the source directory to install dependencies:

pipenv install --dev

To drop or create the local DB that theia will be using:

pipenv run create_local_db

pipenv run drop_local_db

How to Run

Run Django app locally (applying migrations if necessary):

pipenv run server

Run the Celery worker locally (does not apply migrations):

pipenv run worker

Run the tests locally, including coverage calculation:

pipenv run migrate && pipenv run tests

Run a test marked with @pytest.mark.focus:

pipenv shell

pytest -m focus