Git Lab CI for docker build enabled! You can enable it using .gitlab-ci.yml in your project. Check file template at https://gitlab.bio.di.uminho.pt/snippets/5

Commit e89c5e50 authored by Davide Lagoa's avatar Davide Lagoa
Browse files

webserver major update

parent e0024456

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
FROM openjdk:10-slim
COPY ./code /home
WORKDIR /workdir
ADD ./requirements/system /workdir/system
ADD ./requirements/scraper /workdir/scraper
RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get -y install ncbi-blast+
......
from flask import Flask
from flask import Flask, request, send_file, jsonify
import subprocess
import os
import shutil
import datetime
import logging
app = Flask(__name__)
PROCESS_PATH = '/home/transyt.py'
SUBMISSIONS_PATH = '/workdir/workerSubmissions/'
RESULTS_PATH = '/workdir/resultsWorker/'
#RESULTS_PATH = "C:\\Users\\BioSystems\\Desktop\\testFolder\\resultsWorker\\"
#SUBMISSIONS_PATH = "C:\\Users\\BioSystems\\Desktop\\testFolder\\workerSubmissions\\"
if not os.path.exists(SUBMISSIONS_PATH):
os.makedirs(SUBMISSIONS_PATH)
if not os.path.exists(RESULTS_PATH):
os.makedirs(RESULTS_PATH)
start_time = datetime.datetime.now()
running = False
@app.route("/start", methods=["POST"])
def start():
global start_time
global running
start_time = datetime.datetime.now()
if os.path.exists(SUBMISSIONS_PATH):
shutil.rmtree(SUBMISSIONS_PATH, ignore_errors=True)
if os.path.exists(RESULTS_PATH):
shutil.rmtree(RESULTS_PATH, ignore_errors=True)
os.makedirs(SUBMISSIONS_PATH)
os.makedirs(RESULTS_PATH)
@app.route("/start/<processingPath>/<resultsPath>")
def start(processingPath, resultsPath):
try:
resultsPath = resultsPath.replace('$', '/')
processingPath = processingPath.replace('$', '/')
subprocess.Popen(["python", PROCESS_PATH, processingPath, resultsPath])
for file in request.files.values():
destination = "/".join([SUBMISSIONS_PATH, file.filename])
file.save(destination)
subprocess.Popen(["python", PROCESS_PATH, SUBMISSIONS_PATH, RESULTS_PATH])
running = True
return ('processing', 102)
......@@ -20,5 +54,27 @@ def start(processingPath, resultsPath):
print('An error occurred while processing the submission')
return ('error', 500)
@app.route('/status')
def display_msg():
files = os.listdir(RESULTS_PATH)
if not running:
return jsonify({"result": "Not running"}), 410
if abs(datetime.datetime.now() - start_time) > datetime.timedelta(hours=2):
return jsonify({"result": "Time out"}), 408
if "processComplete" in files:
return send_file(RESULTS_PATH + "results.zip", as_attachment=True,
attachment_filename='results.zip'), 200
return jsonify({"result": "running"}), 202
@app.route('/handshake')
def handshake():
return jsonify({"result": "alive"}), 200
if __name__ == "__main__":
app.run(host="0.0.0.0", port=80, threaded=False, debug=True)
app.run(host="0.0.0.0", port=80, threaded=False, debug=True)
familySpecificReactions_17h32m53s1922019.json
familySpecificReactions_16h38m48s2022019.json
familySpecificReactions_20h8m21s2522019.json
familySpecificReactions_23h22m59s2732019.json
familySpecificReactions_13h49m3s2832019.json
reactions_18h29m5s1922019.json
reactions_17h34m31s2022019.json
reactions_21h7m38s2522019.json
reactions_0h17m12s2832019.json
reactions_14h43m56s2832019.json
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment