-
Notifications
You must be signed in to change notification settings - Fork 3
Development Environment Setup
Welcome to the Development Environment Setup page! This page is intended for those who desire step-by-step instructions to setup a development environment on their own machine. Most instructions will be for MacOS; other versions incoming.
- PostgreSQL > 9.6 (backend database)
- redis (asynchronous messaging for job queues)
- IntelliJ IDEA
- Our team uses this IDE internally, and the instructions will gear towards IDEA. Please adapt any IDEA-specific instructions to your preferred IDE/code editor/manual steps.
First, install the required software.
There are two options: you can either directly download the installing package, or get it through a package manager like Homebrew.
-
Direct download
- The official PostgreSQL download page will have links to download the installer according to your OS version.
- Install PostgreSQL once the installer is downloaded.
-
Package manager (Homebrew)
Instructions here are adapted from this tutorial.
$ brew install postgresql
Once the installation finishes, you can then simply run
$ postgres -D /usr/local/var/postgres
This will initialize a default database in the directory
/usr/local/var/postgres
. To have PostgreSQL run on system startup, do$ brew services start postgresql
Like PostgreSQL, you can either do a direct download or get it from a package manager.
- Direct download
- Package manager
$ brew install redis <install output...> $ brew services start redis
It is recommended that you get the Ultimate version if you can. If not, the Community version should suffice.
To check that both PostgreSQL and redis is running (or whether you already have them installed), do
$ brew services
This will list all services running through Homebrew, and you can check whether postgresql
and redis
are started or not. grep
if you have many Homebrew-managed services.
Please adapt the instructions if you don't use IDEA. Most modern IDEs will have similar functions.
- Install
pipenv
if not installed - Project settings -> SDK Setup, Use
pipenv
as SDK - Make sure module
forecast_repo
is usingpipenv
SDK - Get
local_postgres.env
andlocal_sqlite3.env
into root repo directory (acquire these files with the dev team) - Connect to PostgreSQL with default user, create
forecast-repo
database - (on MacOS) PostgreSQL should come with a superuser with your username; go to
forecast_repo/settings/local_postgres.py
, change username to your superuser username. If not, create a new user using thecreateuser
command and use that as your superuser username. - Install EnvFile plugin in IntelliJ IDEA
- Make several run configurations:
-
manage.py-migrate-postgres
- Script path:
<your local repository location>/manage.py
- Parameters:
migrate
- Python interpreter: use specified interpreter with the pipenv virtual environment
- Working directory:
<root repository directory>
- EnvFile tab (should show up after installing the plugin)
- Enable EnvFile, and add the local-postgres.env to the enabled list
- Script path:
-
manage.py-runserver-postgres
- Script path:
<your local repository location>/manage.py
- Parameters:
runserver
- Python interpreter: use specified interpreter with the pipenv virtual environment
- Working directory:
<root repository directory>
- EnvFile tab
- Enable EnvFile, and add the local-postgres.env to the enabled list
- Script path:
-
manage.py-rqworker-postgres
- Script path:
<your local repository location>/manage.py
- Parameters:
rqworker high default low --settings=forecast_repo.settings.local_postgres
- Python interpreter: use specified interpreter with the pipenv virtual environment
- Working directory:
<root repository directory>
- EnvFile tab
- Enable EnvFile, and add the local-postgres.env to the enabled list
- Script path:
-
manage.py-test-postgres
- Script path:
<your local repository location>/manage.py
- Parameters:
test --verbosity 2
- Python interpreter: use specified interpreter with the pipenv virtual environment
- Working directory:
<root repository directory>
- EnvFile tab
- Enable EnvFile, and add the local-postgres.env to the enabled list
- Script path:
-
manage.py-test-individual-postgres
(optional, for running individual tests)- Script path:
<your local repository location>/manage.py
- Parameters:
test <specify individual test method using dot notation> --verbosity 2
- Python interpreter: use specified interpreter with the pipenv virtual environment
- Working directory:
<root repository directory>
- EnvFile tab
- Enable EnvFile, and add the local-postgres.env to the enabled list
- Script path:
-
manage.py-test-individual-postgres
(optional, for running individual tests)- Script path:
<your local repository location>/manage.py
- Parameters:
test <specify individual test method using dot notation> --verbosity 2
- Python interpreter: use specified interpreter with the pipenv virtual environment
- Working directory:
<root repository directory>
- EnvFile tab
- Enable EnvFile, and add the local-postgres.env to the enabled list
- Script path:
-
manage.py-score-postgres
- Script path:
<your local repository location>/utils/score_util.py
- Parameters:
update --score-pk=<primary key of the score> --model-pk=<primary key of the model> --no-enqueue
- Python interpreter: use specified interpreter with the pipenv virtual environment
- Working directory:
<root repository directory>
- EnvFile tab
- Enable EnvFile, and add the local-postgres.env to the enabled list
- Script path:
-
manage.py-test-sqlite
- Script path:
<your local repository location>/utils/score_util.py
- Parameters:
test --verbosity 2
- Python interpreter: use specified interpreter with the pipenv virtual environment
- Working directory:
<root repository directory>
- EnvFile tab
- Enable EnvFile, and add the local-sqlite3.env to the enabled list
- Script path:
-
temp_app.py-postgres
(optional, if you want to try certain things out)- Script path:
<your local repository location>/temp_app.py
- Parameters: none
- Python interpreter: use specified interpreter with the pipenv virtual environment
- Working directory:
<root repository directory>
- EnvFile tab
- Enable EnvFile, and add the local-postgres.env to the enabled list
- Script path:
-
make_minimal_projects
- Script path:
<your local repository location>/utils/make_minimal_projects.py
- Parameters: none
- Python interpreter: use specified interpreter with the pipenv virtual environment
- Working directory:
<root repository directory>
- EnvFile tab
- Enable EnvFile, and add the local-postgres.env to the enabled list
- Script path:
-
- Create a superuser:
then follow the prompts to create a super user. This will allow you to login as a super user on your local instance of Zoltar.
$ python3 manage.py createsuperuser --settings=forecast_repo.settings.local_postgres
- Run the
migrate
run configuration. This will setup theforecast_repo
database in PostgreSQL. - Run the
make_minimal_project
run configuration. This will setup an example project for Zoltar to show.
- Run the
runserver
andrqworker
run configuration to view a local Zoltar instance. - Run the
test
run configuration to run all tests. - Run the
test-individual
run configuration (specifying a test to run) to run an individual test.
You should be all set to develop! If you have any questions please contact the dev team.