This is a template for ADI Labs projects, using our default tech stack (Python / Flask / Postgres). It has automated testing, linting, and code coverage reports already set-up for you.
The TLDR is:
vagrant ssh
cd /vagrant
source config/settings.dev
flask develop
We use https://www.vagrantup.com/ and https://www.virtualbox.org/ to set up our development environment. After installing Vagrant, you'll want to navigate to the project directory and run:
vagrant up
which should automatically bootstrap the development environment for you.
We use environment variables to store our configuration. There are two
files you should care about: config/settings.dev
and
config/settings.test
, which store configuration for development and
testing. If you get a flask not found
error, you probably need to run:
source config/settings.dev
in order to load all our configuration variables. (When you've loaded
your configuration, you should see (app)
in front of your cursor).
For development, we ues the new Flask command-line interface. For
obscure technical reasons relating to IP addresses and VMs, you'll need
to run flask deploy
instead of flask run
to access your app on your
host (non-VM) computer.
We also provide convenient a flask pgcli
command that will open up a
pgcli shell to your postgres database (in case you
need to munge around for a little) and a flask setup
which will setup
the database for you.
For a full list of commands, you can always use the --help
flag (e.g.
flask --help
)
We use http://flake8.pycqa.org/en/latest/ for our Python linting and http://doc.pytest.org/en/latest/ for our test suite. To run them, you just need to:
flake8
or
source config/settings.test
py.test
Strictly speaking, you don't have to source settings.test
before
running py.test
, but you'll delete everything in your development
database if you don't.
.
├── app/ -- Your standard Flask app structure
├── config
│ ├── bootstrap.sh -- Script to bootstrap the Vagrant environment
│ ├── environment.yml -- Python dependencies
│ ├── settings.dev -- Configuration for the dev environment
│ ├── settings.test -- Configuration for the testing environment
│ └── setup.sql -- Needed to bootstrap the postgres database
├── run.py -- Magic needed for our `flask` commands
├── setup.cfg -- Configuration for pytest and flake8
└── Vagrantfile