Skip to content

Commit

Permalink
Merge e62bb45 into 265bbd8
Browse files Browse the repository at this point in the history
  • Loading branch information
Mropat committed Feb 16, 2021
2 parents 265bbd8 + e62bb45 commit c37e67d
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 18 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
alembic
tests
trailblazer.egg-info
.pytest_cache
.github
.editorconfig
.gitignore
.gitlint.yaml
.pre-commit-config.yaml
.configs
DEPLOYMENT.md

2 changes: 1 addition & 1 deletion .github/workflows/production_install_clinical-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

- name: Test install on clinical-db
run: |
pip install pip==9.0.1
pip install pip==21.0.1
pip install .
pip check
- name: Test install dev on clinical-db
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/production_install_hasta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

- name: Test install on hasta
run: |
pip install pip==18.1
pip install pip==21.0.1
pip install .
pip check
- name: Test install dev on hasta
Expand Down
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM python:3.7-slim

ENV GUNICORN_WORKERS=1
ENV GUNICORN_TREADS=1
ENV GUNICORN_BIND="0.0.0.0:5000"
ENV GUNICORN_TIMEOUT=400

WORKDIR /home/src/app
COPY . /home/src/app

RUN pip install -r requirements.txt
RUN pip install -e .


CMD gunicorn \
--workers=$GUNICORN_WORKERS \
--bind=$GUNICORN_BIND \
--threads=$GUNICORN_TREADS \
--timeout=$GUNICORN_TIMEOUT \
trailblazer.server.app:app

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Trailblazer [![Coverage Status][coveralls-image]][coveralls-url]

### Automate, monitor, and simplify running the [MIP][mip] analysis pipeline
### Monitor the progress of analysis workflows submitted to SLURM

Trailblazer is a tool that aims to provide:

- a Python interface to interact with MIP in an automated fashion
- a limited command line interface to simplify running MIP using an opinionated setup

Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ Flask-SQLAlchemy==2.1
Flask-CORS
Flask-Reverse-Proxy
google-auth
gunicorn

# misc
pymysql
python-dateutil
cryptography
12 changes: 5 additions & 7 deletions trailblazer/cli/core.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging

import os
import click
import coloredlogs
import ruamel.yaml
from dateutil.parser import parse as parse_date

Expand All @@ -16,15 +15,14 @@
@click.group()
@click.option("-c", "--config", type=click.File())
@click.option("-d", "--database", help="path/URI of the SQL database")
@click.option("-l", "--log-level", default="INFO")
@click.version_option(trailblazer.__version__, prog_name=trailblazer.__title__)
@click.pass_context
def base(context, config, database, log_level):
def base(context, config, database):
"""Trailblazer - Monitor analyses"""
coloredlogs.install(level=log_level)

context.obj = ruamel.yaml.safe_load(config) if config else {}
context.obj["database"] = database or context.obj.get("database")
context.obj["database"] = database or os.environ.get(
"SQLALCHEMY_DATABASE_URI", "sqlite:///:memory:"
)
context.obj["trailblazer"] = Store(context.obj["database"])


Expand Down
5 changes: 4 additions & 1 deletion trailblazer/server/api.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import datetime
import os

from dateutil.parser import parse as parse_datestr
from flask import abort, g, Blueprint, jsonify, make_response, request
from google.auth import jwt
from typing import Dict
import subprocess
import multiprocessing

from trailblazer.server.ext import store
Expand All @@ -24,6 +25,8 @@ def before_request():
"""Authentication that is run before processing requests to the application"""
if request.method == "OPTIONS":
return make_response(jsonify(ok=True), 204)
if os.environ.get("SCOPE") == "DEVELOPMENT":
return
auth_header = request.headers.get("Authorization")
if auth_header:
jwt_token = auth_header.split("Bearer ")[-1]
Expand Down
9 changes: 3 additions & 6 deletions trailblazer/server/app.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
# -*- coding: utf-8 -*-
import os

import coloredlogs
from flask import Flask
from flask_cors import CORS
from flask_reverse_proxy import FlaskReverseProxied

from trailblazer.server import api, ext

coloredlogs.install(level="INFO")
app = Flask(__name__)

SECRET_KEY = "unsafe!!!"
TEMPLATES_AUTO_RELOAD = True
SQLALCHEMY_DATABASE_URI = os.environ["SQLALCHEMY_DATABASE_URI"]
SQLALCHEMY_POOL_RECYCLE = 7200
SQLALCHEMY_TRACK_MODIFICATIONS = "FLASK_DEBUG" in os.environ
SQLALCHEMY_DATABASE_URI = os.environ.get("SQLALCHEMY_DATABASE_URI", "sqlite:///:memory:")
SQLALCHEMY_POOL_RECYCLE = os.environ.get("SQLALCHEMY_POOL_RECYCLE", 7200)
SQLALCHEMY_TRACK_MODIFICATIONS = os.environ.get("FLASK_DEBUG", False)

app.config.from_object(__name__)

Expand Down

0 comments on commit c37e67d

Please sign in to comment.