From ad7f1d57b04f8131e10c517fd6632174b1ec6565 Mon Sep 17 00:00:00 2001 From: IPowerW Date: Wed, 8 Nov 2023 13:41:37 +0100 Subject: [PATCH] init flask integration --- Dockerfile | 12 +++++------- README.md | 35 ++++++++++++++++++++++++++++------- app.py | 11 +++++++++++ backend/app.py | 7 ------- backend/routes.py | 12 ------------ docker-compose.yaml | 18 +++++++++--------- entrypoint.sh | 4 +--- requirements.txt | 4 +++- 8 files changed, 57 insertions(+), 46 deletions(-) create mode 100644 app.py delete mode 100644 backend/app.py delete mode 100644 backend/routes.py diff --git a/Dockerfile b/Dockerfile index 2fb824b7..2a70bc15 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,11 +3,12 @@ FROM python:3.9 USER root RUN mkdir /home/wannadb WORKDIR /home/wannadb -COPY requirements.txt requirements.txt -# Install dependencies +# install torch RUN pip install --use-pep517 torch==1.10.0 +# Install dependencies +COPY requirements.txt requirements.txt RUN pip install --use-pep517 -r requirements.txt ################################## ## do not change above ## @@ -22,11 +23,8 @@ RUN pip install --use-pep517 pytest #copy the rest COPY . . -COPY entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh +RUN chmod +x entrypoint.sh -EXPOSE 8080 -EXPOSE 5000 # Define the entrypoint.sh -CMD ["/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT "/home/wannadb/entrypoint.sh" \ No newline at end of file diff --git a/README.md b/README.md index e9df914c..c3e922e0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,26 @@ +# Start the docker + +beim ersten mal + +``` +docker compose build +``` + +zum weiter arbeiten + +``` +docker compose up +``` + +danach sollte das backend gestartet sein + +ihr könnt mit `code` den container attachen und dann im docker arbeiten + +git functioniert erst wenn ihr gh installiert und gh auth macht +anschließend könnt ihr wie gewohn arbeiten + +ein docker rebuild ist nur nötig wenn sich dependencies geändert haben + # WannaDB: Ad-hoc SQL Queries over Text Collections ![Document collection and corresponding table.](header_image.svg) @@ -114,25 +137,23 @@ series = {SIGMOD '22} WannaDB is dually licensed under both AGPLv3 for the free usage by end users or the embedding in Open Source projects, and a commercial license for the integration in industrial projects and closed-source tool chains. More details can be found in [our licence agreement](LICENSE.md). - ## Availability of Code & Datasets We publish the source code four our system as discussed in the papers here. Additionally, we publish code to reproduce our experiments in a separate repository (coming soon). Unfortunately, we cannot publish the datasets online due to copyright issues. We will send them via email on request to everyone interested and hope they can be of benefit for other research, too. - ## Implementation details -The core of WannaDB (extraction and matching) was previously developed by us under the name [ASET (Ad-hoc Structured Exploration of Text Collections)](https://link.tuda.systems/aset). To better reflect the whole application cycle vision we present with this paper, we switchted the name to WannaDB. +The core of WannaDB (extraction and matching) was previously developed by us under the name [ASET (Ad-hoc Structured Exploration of Text Collections)](https://link.tuda.systems/aset). To better reflect the whole application cycle vision we present with this paper, we switchted the name to WannaDB. ### Repository structure This repository is structured as follows: -* `wannadb`, `wannadb_parsql`, and `wannadb_ui` contain the implementation of ASET and the GUI. -* `scripts` contains helpers, like a stand-alone preprocessing script. -* `tests` contains pytest tests. +- `wannadb`, `wannadb_parsql`, and `wannadb_ui` contain the implementation of ASET and the GUI. +- `scripts` contains helpers, like a stand-alone preprocessing script. +- `tests` contains pytest tests. ### Architecture: Core @@ -140,7 +161,7 @@ The core implementation of WannaDB is in the `wannadb` package and implemented a **Data model** -`data` contains WannaDB's data model. The entities are `InformationNugget`s, `Attribute`s, `Document`s, and the `DocumentBase`. +`data` contains WannaDB's data model. The entities are `InformationNugget`s, `Attribute`s, `Document`s, and the `DocumentBase`. A nugget is an information piece obtained from a document. An attribute is a table column that gets populated with information from the documents. A document is a textual document, and the document base is a collection of documents and provides facilities for `BSON` serialization, consistency checks, and data access. diff --git a/app.py b/app.py new file mode 100644 index 00000000..14e2c17c --- /dev/null +++ b/app.py @@ -0,0 +1,11 @@ +from flask import Flask +from flask_cors import CORS + + +app = Flask(__name__) +CORS(app) + + +@app.route('/') +def hello_world(): # put application's code here + return 'Hello World!' diff --git a/backend/app.py b/backend/app.py deleted file mode 100644 index 05b62393..00000000 --- a/backend/app.py +++ /dev/null @@ -1,7 +0,0 @@ -from flask import Flask - -app = Flask(__name__) - -@app.route("/") -def hello_world(): - return "

Hello, World!

" diff --git a/backend/routes.py b/backend/routes.py deleted file mode 100644 index bb07eb12..00000000 --- a/backend/routes.py +++ /dev/null @@ -1,12 +0,0 @@ -import sys - -# Add a dummy package to sys.modules to force Flask to be imported as a package -sys.modules['flask'] = sys.modules[__name__] - -from flask import Flask - -app = Flask(__name__) - -@app.route("/") -def hello_world(): - return "

Hello, World!

" diff --git a/docker-compose.yaml b/docker-compose.yaml index 480c7ea5..2f434142 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,10 +1,10 @@ -version: '3.6' +version: "3.6" services: - wannadb: - build: - context: . - dockerfile: Dockerfile - restart: always - tty: true - ports: - - 8080:8080 + wannadb: + build: + context: . + dockerfile: Dockerfile + restart: always + tty: true + ports: + - "8000:8000" diff --git a/entrypoint.sh b/entrypoint.sh index c5830315..4126afb1 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,6 +7,4 @@ export PYTHONPATH="." pytest -flask --app backend/app.py run - -sleep infinity +gunicorn -w 4 --bind 0.0.0.0:8000 app:app \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index aec66f44..ad992121 100644 --- a/requirements.txt +++ b/requirements.txt @@ -232,4 +232,6 @@ wasabi==0.10.1 # The following packages are considered to be unsafe in a requirements file: # setuptools -flask==3.0.0 \ No newline at end of file +flask==3.0.0 +Flask_Cors==4.0.0 +gunicorn==21.2.0 \ No newline at end of file