From 68aa13034890a25ebffa82a43e517c6a9263444c Mon Sep 17 00:00:00 2001 From: "stu126940@mail.uni-kiel.de" <stu126940@mail.uni-kiel.de> Date: Fri, 12 Mar 2021 18:34:13 +0100 Subject: [PATCH] Add execution instructions and Dockerfile --- slope-evaluator/Dockerfile | 7 +++++ slope-evaluator/README.md | 26 +++++++++++++++++++ slope-evaluator/{api.py => app/main.py} | 2 ++ .../{ => app}/trend_slope_computer.py | 0 slope-evaluator/requirements.txt | 3 +++ 5 files changed, 38 insertions(+) create mode 100644 slope-evaluator/Dockerfile create mode 100644 slope-evaluator/README.md rename slope-evaluator/{api.py => app/main.py} (96%) rename slope-evaluator/{ => app}/trend_slope_computer.py (100%) create mode 100644 slope-evaluator/requirements.txt diff --git a/slope-evaluator/Dockerfile b/slope-evaluator/Dockerfile new file mode 100644 index 000000000..4d9df3682 --- /dev/null +++ b/slope-evaluator/Dockerfile @@ -0,0 +1,7 @@ +FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7 + +COPY ./app /app +COPY requirements.txt requirements.txt + +COPY requirements.txt requirements.txt +RUN pip install -r requirements.txt \ No newline at end of file diff --git a/slope-evaluator/README.md b/slope-evaluator/README.md new file mode 100644 index 000000000..c8bc9dad9 --- /dev/null +++ b/slope-evaluator/README.md @@ -0,0 +1,26 @@ +# Slope Evaluator + +## Execution + +For development: + +```sh +uvicorn main:app --reload +``` + +Build the docker image: + +```sh +docker build . -t theodolite-evaluator +``` + +Run the Docker image: + +```sh + docker run -p 80:80 -e PORT="9999" theodolite-evaluator +``` + +## Configuration + +You can set the `HOST` and the `PORT` (and a lot of more parameters) via environment variablen. +For more information see [here](https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker#advanced-usage). diff --git a/slope-evaluator/api.py b/slope-evaluator/app/main.py similarity index 96% rename from slope-evaluator/api.py rename to slope-evaluator/app/main.py index 3d31c9c09..47cb57725 100644 --- a/slope-evaluator/api.py +++ b/slope-evaluator/app/main.py @@ -42,3 +42,5 @@ async def evaluate_slope(request: Request): data = json.loads(await request.body()) logger.info("Request received") return execute(data['total_lag'], data['threshold'],data['warmup']) + +logger.info("Slope evaluator is online") \ No newline at end of file diff --git a/slope-evaluator/trend_slope_computer.py b/slope-evaluator/app/trend_slope_computer.py similarity index 100% rename from slope-evaluator/trend_slope_computer.py rename to slope-evaluator/app/trend_slope_computer.py diff --git a/slope-evaluator/requirements.txt b/slope-evaluator/requirements.txt new file mode 100644 index 000000000..ca77b6c89 --- /dev/null +++ b/slope-evaluator/requirements.txt @@ -0,0 +1,3 @@ +fastapi==0.55.1 +scikit-learn==0.20.3 +pandas==1.0.3 -- GitLab