Matchminer API written in python. This API utilizes the Eve framework and mongodb to build a lightweight and intuitive web app. Utilizing Eve's opinioned choices and direct integration with MongoDB enabled us to create a level 3 REST compliant application.
- Python2.7
- Virtualenv - Tool to create isolated Python environments.
- Eve - REST API framework.
- MongoDB - NoSQL document database for data storage.
- Docker - Container platform for deployment.
- nose - Python library for unit testing.
The following sections detail steps necessary to begin development on MatchMiner. Python2.7, Docker, Virtualenv, and MongoDB are expected to be already installed in order to execute these installation directions.
git clone THIS-REPO
virtualenv ENV-NAME
. ENV-NAME/bin/activate
cd matchminer-api
pip install -r requirements.txt
The following commands will start and test the mongo container. A local instance of mongo can also be used, by over-ridding the configuration variables for the DB host.
docker run --name match-mongo -d -p 27017:27017 mongo mongod --smallfiles --replSet=rs0
docker exec -it match-mongo mongo matchminer --eval "rs.initiate();"
python pymm_run.py restore
Due to the sensitive nature of the application test driven development is a must. Unit tests are located in the /tests folder and roughly correspond to the application structure itself.
nosetests tests
Specific test functions can be called by following the syntax in the second command. e.g.
nosetests tests/test_matchminer/test_filter.py:TestFiler.test_put_dirty
The root of the application is pymm_run.py. The API can be served in development mode by using the following command:
python pymm_run.py serve [--no-auth]
You'll notice there are several commands inside the application.
- debug loads default filter/match data and users into the database.
- restore rebuilds the clinical and genomic repositories from serialized files
- insert populates the clinical and genomic repositories from Pandas .pkl files
- dump creates the serialized database files used for restoring.
MatchMiner can be deployed in development or production mode. In development a built in webserver is used to host the API. In production Docker is used.
The production deployment process consists of several phases:
- building the Docker container locally
docker build -t DOCKER_IMAGE:VERSION .
- push the container to central repository
docker push DOCKER_IMAGE:VERSION
- log into remote repository
- pull the container from repository to production host
docker pull DOCKER_IMAGE:VERSION
- stoping existing containers and re-starting on deployment server
docker-compose down
docker-compose up -d
- dev: is used to development candidates (it will only ever contain simulated data)
- stage: is used for the staging enviroment
- latest: is the master or the production image