From cf7d01362600446d231182860550e35e58767e8f Mon Sep 17 00:00:00 2001 From: Alessandro Berti Date: Wed, 10 Nov 2021 07:13:20 +0100 Subject: [PATCH 1/6] updates updates --- app.py | 2 +- requirements.txt | 2 +- templates/upload.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index ef11ee4..c381552 100644 --- a/app.py +++ b/app.py @@ -72,4 +72,4 @@ def upload(): os.mkdir(os.path.join("static", "temp")) logs_dictio["log1"] = os.path.join("SampleEventLogs&SimulatedER2021", "running-example.xes") logs_dictio["log2"] = os.path.join("SampleEventLogs&SimulatedER2021", "Running-example-simulated.csv") - app.run(host='0.0.0.0') + app.run(host='0.0.0.0', threaded=True) diff --git a/requirements.txt b/requirements.txt index f27f792..b3bfee6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ pyemd==0.5.1 plotly==5.3.1 matplotlib==3.4.3 pandas==1.3.3 -pm4py==2.2.15 +pm4py==2.2.15.1 numpy==1.21.2 multiset==2.1.1 pyfpgrowth==1.0 diff --git a/templates/upload.html b/templates/upload.html index cd032fa..2e0b01b 100644 --- a/templates/upload.html +++ b/templates/upload.html @@ -8,7 +8,7 @@ - Scenario-based Analysis of Processes + Interactive Business Process Comparison Using Conformance and Performance Insights - Upload Page From 4ffe3a9951fa8ee90a0f6817880098757703d26a Mon Sep 17 00:00:00 2001 From: Alessandro Berti Date: Thu, 13 Jan 2022 15:02:17 +0100 Subject: [PATCH 2/6] trying main.py --- main.py | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..c381552 --- /dev/null +++ b/main.py @@ -0,0 +1,75 @@ +from flask import Flask, render_template, request, make_response, jsonify, redirect, url_for +import base64, os +from tempfile import NamedTemporaryFile +import uuid +from copy import copy +from EMDMeasurment.ComparisonMethods import produce_visualizations_from_event_logs_paths +from flask_cors import CORS +import json +import traceback + + +app = Flask(__name__) +CORS(app, expose_headers=["x-suggested-filename"]) + + +logs_dictio = {} + + +@app.route('/') +def empty_path(): + return redirect(url_for('upload_page')) + + +@app.route('/index.html') +def index(): + return redirect(url_for('upload_page')) + + +@app.route("/comparison.html") +def comparison_page(): + return render_template("comparison.html") + + +@app.route("/upload.html") +def upload_page(): + return render_template("upload.html") + + +@app.route("/visualizationsService", methods=["GET"]) +def visualizationsService(): + uid1 = request.args.get("uuid1") + uid2 = request.args.get("uuid2") + if uid1 is None: + uid1 = "log1" + if uid2 is None: + uid2 = "log2" + + log_path1 = logs_dictio[uid1] + log_path2 = logs_dictio[uid2] + + resp = produce_visualizations_from_event_logs_paths(log_path1, log_path2) + + return jsonify(resp) + + +@app.route("/uploadService", methods=["POST"]) +def upload(): + uuids = [] + for file in request.files: + tmp_file = NamedTemporaryFile() + tmp_file.close() + fo = request.files[file] + fo.save(tmp_file.name) + this_uuid = str(uuid.uuid4()) + logs_dictio[this_uuid] = tmp_file.name + uuids.append(this_uuid) + return {"uuid1": uuids[0], "uuid2": uuids[1]} + + +if __name__ == "__main__": + if not os.path.exists(os.path.join("static", "temp")): + os.mkdir(os.path.join("static", "temp")) + logs_dictio["log1"] = os.path.join("SampleEventLogs&SimulatedER2021", "running-example.xes") + logs_dictio["log2"] = os.path.join("SampleEventLogs&SimulatedER2021", "Running-example-simulated.csv") + app.run(host='0.0.0.0', threaded=True) From d2e58fc900cb67370d129eb20f487bdb25daddb1 Mon Sep 17 00:00:00 2001 From: Alessandro Berti Date: Thu, 13 Jan 2022 15:40:35 +0100 Subject: [PATCH 3/6] attempt --- app.py | 10 +++++--- main.py | 75 --------------------------------------------------------- 2 files changed, 7 insertions(+), 78 deletions(-) delete mode 100644 main.py diff --git a/app.py b/app.py index c381552..797d668 100644 --- a/app.py +++ b/app.py @@ -67,9 +67,13 @@ def upload(): return {"uuid1": uuids[0], "uuid2": uuids[1]} +logs_dictio["log1"] = os.path.join("SampleEventLogs&SimulatedER2021", "running-example.xes") +logs_dictio["log2"] = os.path.join("SampleEventLogs&SimulatedER2021", "Running-example-simulated.csv") +port = os.environ.get("PORT") +if port is None: + port = "80" +port = int(port) if __name__ == "__main__": if not os.path.exists(os.path.join("static", "temp")): os.mkdir(os.path.join("static", "temp")) - logs_dictio["log1"] = os.path.join("SampleEventLogs&SimulatedER2021", "running-example.xes") - logs_dictio["log2"] = os.path.join("SampleEventLogs&SimulatedER2021", "Running-example-simulated.csv") - app.run(host='0.0.0.0', threaded=True) + app.run(port=port, threaded=True) diff --git a/main.py b/main.py deleted file mode 100644 index c381552..0000000 --- a/main.py +++ /dev/null @@ -1,75 +0,0 @@ -from flask import Flask, render_template, request, make_response, jsonify, redirect, url_for -import base64, os -from tempfile import NamedTemporaryFile -import uuid -from copy import copy -from EMDMeasurment.ComparisonMethods import produce_visualizations_from_event_logs_paths -from flask_cors import CORS -import json -import traceback - - -app = Flask(__name__) -CORS(app, expose_headers=["x-suggested-filename"]) - - -logs_dictio = {} - - -@app.route('/') -def empty_path(): - return redirect(url_for('upload_page')) - - -@app.route('/index.html') -def index(): - return redirect(url_for('upload_page')) - - -@app.route("/comparison.html") -def comparison_page(): - return render_template("comparison.html") - - -@app.route("/upload.html") -def upload_page(): - return render_template("upload.html") - - -@app.route("/visualizationsService", methods=["GET"]) -def visualizationsService(): - uid1 = request.args.get("uuid1") - uid2 = request.args.get("uuid2") - if uid1 is None: - uid1 = "log1" - if uid2 is None: - uid2 = "log2" - - log_path1 = logs_dictio[uid1] - log_path2 = logs_dictio[uid2] - - resp = produce_visualizations_from_event_logs_paths(log_path1, log_path2) - - return jsonify(resp) - - -@app.route("/uploadService", methods=["POST"]) -def upload(): - uuids = [] - for file in request.files: - tmp_file = NamedTemporaryFile() - tmp_file.close() - fo = request.files[file] - fo.save(tmp_file.name) - this_uuid = str(uuid.uuid4()) - logs_dictio[this_uuid] = tmp_file.name - uuids.append(this_uuid) - return {"uuid1": uuids[0], "uuid2": uuids[1]} - - -if __name__ == "__main__": - if not os.path.exists(os.path.join("static", "temp")): - os.mkdir(os.path.join("static", "temp")) - logs_dictio["log1"] = os.path.join("SampleEventLogs&SimulatedER2021", "running-example.xes") - logs_dictio["log2"] = os.path.join("SampleEventLogs&SimulatedER2021", "Running-example-simulated.csv") - app.run(host='0.0.0.0', threaded=True) From 0189c7ba8153d13214bcee80db594f83016e2e38 Mon Sep 17 00:00:00 2001 From: Alessandro Berti Date: Thu, 13 Jan 2022 16:00:02 +0100 Subject: [PATCH 4/6] fixed requirements --- requirements.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/requirements.txt b/requirements.txt index b3bfee6..4b53c76 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,14 @@ pyemd==0.5.1 -plotly==5.3.1 -matplotlib==3.4.3 -pandas==1.3.3 -pm4py==2.2.15.1 -numpy==1.21.2 -multiset==2.1.1 +plotly==5.5.0 +matplotlib==3.5.1 +pandas==1.3.5 +pm4py==2.2.18 +numpy==1.22.0 +multiset==3.0.1 pyfpgrowth==1.0 python_Levenshtein==0.12.2 seaborn==0.11.2 -frozendict==2.0.6 +frozendict==2.1.3 Flask==2.0.2 Flask-Cors==3.0.10 From 17e5bd163558d84f5aed83dd7c288620c3983e05 Mon Sep 17 00:00:00 2001 From: Alessandro Berti Date: Wed, 19 Jan 2022 09:41:19 +0100 Subject: [PATCH 5/6] Heroku --- Procfile | 1 + runtime.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 Procfile create mode 100644 runtime.txt diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..244c130 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: gunicorn app:app --log-file=- diff --git a/runtime.txt b/runtime.txt new file mode 100644 index 0000000..d9a16ae --- /dev/null +++ b/runtime.txt @@ -0,0 +1 @@ +python-3.8.12 From a7bda790922928010a7cd8d1691c92a098ffd11d Mon Sep 17 00:00:00 2001 From: Alessandro Berti Date: Wed, 19 Jan 2022 09:46:05 +0100 Subject: [PATCH 6/6] gunicorn --- requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 4b53c76..dd8c433 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,5 +11,4 @@ seaborn==0.11.2 frozendict==2.1.3 Flask==2.0.2 Flask-Cors==3.0.10 - - +gunicorn