diff --git a/asystgrade/lib.php b/asystgrade/lib.php index 94cfceb736682d49a574ce63b6db2c84fa310e70..511d2f4ca2c002d1b102fe81534b2d09328efc6d 100755 --- a/asystgrade/lib.php +++ b/asystgrade/lib.php @@ -66,7 +66,7 @@ function local_asystgrade_before_footer() $apiendpoint = get_config('local_asystgrade', 'apiendpoint'); if (!$apiendpoint) { - $apiendpoint = 'http://127.0.0.1:5000/api/autograde'; // Default setting + $apiendpoint = 'http://flask:5000/api/autograde'; // Default setting, flask is the name of flask container } error_log('APIendpoint: ' . $apiendpoint); diff --git a/asystgrade/tests/fakedata/questions.php b/asystgrade/tests/fakedata/questions.php old mode 100644 new mode 100755 diff --git a/flask/Dockerfile b/flask/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5915a1efde05e25d9f9fe55a7164f33d13e9d09a --- /dev/null +++ b/flask/Dockerfile @@ -0,0 +1,32 @@ +FROM python:3.11-slim + +# Installing system dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + python3-venv \ + && rm -rf /var/lib/apt/lists/* + +# Creating and activating the virtual environment \ +RUN python3 -m venv /opt/myenv +ENV PATH="/opt/myenv/bin:$PATH" + +WORKDIR /app +RUN ls -la /app +COPY . /app + +# Installing dependencies +RUN /opt/myenv/bin/pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple -r /app/requirements.txt +#RUN /opt/myenv/bin/python3 -m pip install -r /app/requirements.txt +RUN /opt/myenv/bin/python3 -m pip install --upgrade setuptools wheel + +COPY ./asyst /app/asyst + +# Set permissions +RUN chown -R www-data:www-data /app/asyst +RUN chmod -R 755 /app/asyst + +# Open port for Flask API +EXPOSE 5000 + +# Launch application +CMD ["python", "/app/api.py"] \ No newline at end of file diff --git a/api.py b/flask/api.py similarity index 100% rename from api.py rename to flask/api.py diff --git a/asyst/DE_Demo_Daten.xlsx b/flask/asyst/DE_Demo_Daten.xlsx similarity index 100% rename from asyst/DE_Demo_Daten.xlsx rename to flask/asyst/DE_Demo_Daten.xlsx diff --git a/asyst/README.md b/flask/asyst/README.md similarity index 100% rename from asyst/README.md rename to flask/asyst/README.md diff --git a/asyst/README_DE.md b/flask/asyst/README_DE.md similarity index 100% rename from asyst/README_DE.md rename to flask/asyst/README_DE.md diff --git a/asyst/README_EN.md b/flask/asyst/README_EN.md similarity index 100% rename from asyst/README_EN.md rename to flask/asyst/README_EN.md diff --git a/asyst/Source/LICENSE b/flask/asyst/Source/LICENSE similarity index 100% rename from asyst/Source/LICENSE rename to flask/asyst/Source/LICENSE diff --git a/asyst/Source/Skript/german/models/clf_BERT.pickle b/flask/asyst/Source/Skript/german/models/clf_BERT.pickle similarity index 100% rename from asyst/Source/Skript/german/models/clf_BERT.pickle rename to flask/asyst/Source/Skript/german/models/clf_BERT.pickle diff --git a/asyst/Source/Skript/german/run_LR_SBERT.py b/flask/asyst/Source/Skript/german/run_LR_SBERT.py similarity index 93% rename from asyst/Source/Skript/german/run_LR_SBERT.py rename to flask/asyst/Source/Skript/german/run_LR_SBERT.py index c66c9e0415dc3849d9fc1679783c2e1baa3985a8..cd748f322e84a384a856f7e45a0a8f57bd1b9f4b 100755 --- a/asyst/Source/Skript/german/run_LR_SBERT.py +++ b/flask/asyst/Source/Skript/german/run_LR_SBERT.py @@ -36,7 +36,7 @@ def process_data(data): parser.add_argument( "--model_dir", - default="/var/www/html/moodle/asyst/Source/Skript/german/models", + default="/app/asyst/Source/Skript/german/models", type=str, required=False, help="The directory where the ML models are stored.", @@ -65,7 +65,7 @@ def process_data(data): X_test = computed_simis_test # UP: read pre-trained LR model - clf_log = pickle.load(open("/var/www/html/moodle/asyst/Source/Skript/german/models/clf_BERT.pickle", "rb")) + clf_log = pickle.load(open("/app/asyst/Source/Skript/german/models/clf_BERT.pickle", "rb")) predictions = clf_log.predict(X_test) diff --git a/requirements.txt b/flask/requirements.txt similarity index 100% rename from requirements.txt rename to flask/requirements.txt