This repository provides an easy deployable web application wrapper for the SISTR tool.
For demo purposes, a test version of this SISTR web-app running SISTR version 1.1.1 is also available at https://sistr-app.onrender.com/
NOTE: The Render.com web application might take up to 20 seconds to load on the first run and all submitted information is temporary stored for 15 min.
- Locally as a:
- Docker container: build image and deploy on local infrastructure
- Natively on a classical web-server: install all dependencies and deploy on dedicated hosting
- Remotely using
- Free Render.com Platform as a Service (PaaS): Deploy publicly on free web-hosting for testing, demo or lightweight usage (both Dockerfile and script deployment from a private and public repositories are supported)
- Cloud infrastructure: Deploy publicly or privately in Cloud Virtual Machine
- python >= 3
- flask
- Python libraries
- maxminddb (for optional usage monitoring)
- pandas
- sistr_cmd
- sendgrid
- uWSGI (application web-server)
- SISTR v. 1.1.1
- SISTR dependencies
- Flask Python web framework running on the production
uwsgiweb server - Workload job queue management allowing for concurrent job executions without server overload
- Easy deployment inside a container on local and remote settings with minimal or no configuration required
- Job completion notification via email with attached results
- Job queue monitoring via app for all submitted jobs
- Optional job queue management via SLURM or simple built-in Bash function
- Job submission history for easier results retrieval
The constants.py file contains on job queue and email notifications options.
- ALLOWED_EXTENSIONS controls the input file extensions which should be Salmonella genomes in FASTA format. The default values are
fastaandfa - JOBQUEUE allows to specify SLURM or simple bash script based job queue specified by
slurmanddirectvalues. - MAILSERVER defines the mail notification method for email notification and results delivery.
The
internalvalue will use thepostfixinternal SMTP server but requires open port 25.sendgridvalue uses the SendGrid email messaging API to send emails but requires email registration and valid API token,gmailuses Gmail SMTP server to send email - SENDGRID_APIKEY is the SendGrid API token with free accounts allowing for 1000 emails per day
- SENDGRID_SENDER_EMAIL is a validated email address to be used by SendGrid to identify the sender
SendGrid allows to easily send email notifications via API after email validation.
Obtain a SendGrid account, register email dedicated for email notifications, generate a custom token,
update SENDGRID_APIKEY and SENDGRID_SENDER_EMAIL values. The free tier allows for 1000 notifications per day.
As a second option, email notifications could be sent via existing Gmail account.
In constants.py set set MAILSERVER constant to gmail value and provide email login details in static/python_utils/send_gmail_notification.py.
Please modify the gmail_user and gmail_password values or import them as environmental variables os.environ.get('VAR_NAME').
This could be a nice option if SMTP port 25 is blocked by an ISP.
The configuration file is located at aux/SLURM/slurm.conf and could be customized.
The default configuration assumes the hostname is sistr-dev. Change the file accordingly to your context. If the hostname is different, SLURM would not run.
The supervisor launches /usr/sbin/slurmctld, /usr/sbin/slurmd and /usr/sbin/munged required for SLURM to run.
Finally, SLURM requires creation of series of directories specified in the Dockerfile under the SLURM section.
If you have difficulty deploying SLURM, use internal Bash queue management requiring no install.
Using a Dockerfile it is very easy to deploy a web-app in any context thanks to
the ease of the Docker image deployment thanks to minimal configuration requirements. This is the recommended deployment strategy
Simply customize the Dockerfile and build the default image:
docker build -f Dockerfile . -t sistr-server-dev:latest
Alternatively build a custom "lighter" image for Herou service (for a faster boot):
docker build -f Dockerfile.heroku . -t sistr-server-dev:latest
To run the web-app Docker image on say port 5010:
docker run -it --rm -h sistr-dev -p 5010:5010 -v `pwd`:/mnt sistr-server-dev:latest
Heroku is a wonderful free server allowing to publicly deploy Docker images as web containers (Dynos). The free tier assigned a VM with 512 MB RAM, 1 CPU and 30 GB of space with 550 working hours/month which is more than enough for light use. The VM with Docker image is booted on demand and automatically shuts down after 30 min of inactivity saving the monthly active hours allowance.
To deploy sist-web-app image on Heroku follow the following steps:
- Sign up with Heroku service at
- Install the Heroku CLI as per https://devcenter.heroku.com/articles/heroku-cli to control web-app via CLI
- Create app slot and name your web app (E.g.
sistr-app)heroku login APP_NAME="sistr-app" heroku create ${APP_NAME}
- Build and release the lighter image for Heroku from the
Dockerfile.herokufile and tag it according toregistry.heroku.com/<app_name>/webformulaAPP_NAME="sistr-app" docker build -f Dockerfile.heroku . -t registry.heroku.com/${APP_NAME}/web heroku container:login docker push registry.heroku.com/${APP_NAME}/web heroku container:release web -a ${APP_NAME}
- Alternatively, in terminal issue the following commands to build and release Docker container from the
Dockerfileheroku container:login heroku container:push web -a ${APP_NAME} heroku container:release web -a ${APP_NAME}
- At
https://dashboard.heroku.com/appscheck status of app and logs. The app should be accessible via<app_name>.hherokuapp.comURL - To connect to the VM shell run
heroku run bash -a ${APP_NAME}
- Access a dedicated machine running any Linux distribution (e.g. Ubuntu)
- Copy source code and install dependencies
- Configure application by editing
constants.pyfile and selecting the desired job queue management (SLURM or launch BASH scriptstatic/bash_templates/launch_template.sh) - Launch background services as required (SLURM, email server) via
/usr/bin/supervisord -c /etc/supervisord.confcommand - Launch web-app code via
uwsgion the desired open port (uwsgi --ini uwsgi.ini --http-socket :<port>) or, for testing purposes, launch using the Flask development web serverflask run --host=0.0.0.0 --port=<port>. Forflask runoptionally defineFLASK_APPglobal variable to point to theapp.pyfile.
Copyright 2020 Public Health Agency of Canada Distributed under the Apache 2.0 license.