Density estimates how full different parts of Columbia are, based on the number of devices connected to the WiFi (data graciously provided by CUIT in coordination with ESC).
Density currently runs on Python 3.6.3 and PostgreSQL 9.6. Our Python dependencies are managed via Pipenv. If you have Python 3.6 already installed, just run:
pip install -U pipenv
pipenv install --dev
./scripts/bootstrap.sh
If you don't know how to install Python 3.6.3 and PostgreSQL 9.6 yourself, we also have a Vagrant setup. Go to Vagrant Downloads to download Vagrant, and then in the terminal run:
vagrant up
vagrant ssh
This should ssh
you into vagrant@vagrant
virtualmachine. Go to
/vagrant
and then run pipenv install --dev
.
We use .env
file (automatically loaded by pipenv
) to handle
configuration. This should automatically be created for you when you run
./scripts/bootstrap.sh
(or when Vagrant provisions itself).
In production, we use a different set of environment variables.
pipenv run flask run
to start the server. If you're using Vagrant, you'll have to run:
pipenv run flask run --host=0.0.0.0
We use py.test
for testing and flake8
for linting. All tests are defined
in density/tests
. To run tests locally, in the app root directory you should
run:
pipenv run flake8
pipenv run py.test
We have Travis CI set-up to enforce passing tests.
Density is currently deployed on ADI's server via Docker (defined in the
Dockerfile
). To build the Docker image locally, install Docker and run:
docker build -t density .
docker run --net=host -d density
To deploy new changes or features on the server, first push your changes to the master branch and check that it builds on Travis CI. Afterwards push your changes to the deploy branch.
.
├── API.md -- API documentation
├── density
│ ├── config.py -- Load configuration from `.env` file
│ ├── data.py -- Raw data for rooms
│ ├── db.py -- Handle all database access
│ ├── graphics.py -- Build graphs for predictions
│ ├── __init__.py -- Bulk of the app logic
│ ├── librarytimes.py -- Handle building hour display
│ ├── predict.py -- Predictions for current day
│ ├── static/ -- Static assets for Flask
│ ├── templates/ -- Jinja2 templates for Flask
│ └── tests/ -- various tests
├── Dockerfile
├── Pipfile -- List of Python dependencies
├── Pipfile.lock
├── README.md
├── scripts
│ ├── bootstrap.sh -- Set-up PostgreSQL logic and `.env`
│ ├── drop.sql -- Drop database
│ ├── dump.sql -- Dump of database for development
│ ├── schema.sql -- Database schema (for reference)
│ └── vagrant.sh -- Script to setup Vagrant
├── setup.cfg -- Setup for CI
└── Vagrantfile