Skip to content

openCONTRABASS/CONTRABASS-webservice

Repository files navigation

CONTRABASS RESTful API

License: GPL v3 CI-CD Quality Gate Status codecov Code style: black DOI

CONTRABASS RESTful API is a python asynchronous-tasks-based RESTful API intended for the computation and analysis of vulnerabilities in genome-scale metabolic models. These webservices are just a backend of CONTRABASS python tool.

Table of Contents

License

CONTRABASS-webservice is released under GPLv3 license.

Requirements

Install dependencies

pip install -r requirements.txt

or

python3 -m pip install -r requirements.txt

Run

  1. Change Redis and MySQL params on .env.
  2. Run celery worker
    celery -A src.restapi.celery_app.celery_app worker --loglevel=debug
    
  3. Run flower
    celery flower -A src.restapi.celery_app.celery_app -port=5555
    
  4. Run Flask application
    python -m src.restapi.app
    

See:

Run with docker-compose

First setup variables on .docker.env. Assuming you have Docker and docker-compose installed, run on terminal:

docker-compose up

In order to bring it down run:

docker-compose down

Test

pytest -v

Deployment

Requirements

Run

  1. Change Redis and MySQL params on .env.
  2. Run celery worker
    celery -A src.restapi.celery_app.celery_app worker --loglevel=info --concurrency=1 &> logs/celery.out
    
  3. Run flower
    celery flower -A src.restapi.celery_app.celery_app -port=5555
    
  4. Run Gunicorn app with unix socket bind and eventlet workers (See Flask-socketIO Deploy)
    gunicorn --worker-class eventlet -w 1 --bind unix:/tmp/gunicorn.sock src.restapi.wsgi:app
    
  5. Setup and run Nginx according to:
    1. Gunicorn Nginx deployment
    2. Flask-SocketIO deployment
    3. Flask-SocketIO Using nginx as a Websocket Reverse Proxy

Run with supervisor (recommended)

"Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems."

"The server piece of supervisor is named supervisord. It is responsible for starting child programs at its own invocation, responding to commands from clients, restarting crashed or exited subprocesseses, logging its subprocess stdout and stderr output, and generating and handling 'events' ". [Source]

To run CONTRABASS-webservice with Supervisor:

  1. Change Redis and MySQL params on .env.
    1. Note: Redis can also be run with Supervisor.
  2. Change the parameters on supervisor/dev/* config files accordingly.
  3. Run celery, flower and Gunicorn with supervisor:
    cd supervisor/dev/
    supervisord -c supervisor.conf
    supervisorctl can be executed with:
    supervisorctl -s unix:///tmp/supervisor.sock
    
  4. Setup and run Nginx as described previously.

For more info see:

Deployment with docker

Requirements

Run

See section Run with docker-compose

Maintainers

@alexOarga

About

Constraint-based model vulnerabilities analysis - Asynchronous tasks RESTful API

Resources

License

Stars

Watchers

Forks

Packages

No packages published