diff --git a/app/app.py b/beflask/app.py
similarity index 87%
rename from app/app.py
rename to beflask/app.py
index e5a8aac..92e6f49 100644
--- a/app/app.py
+++ b/beflask/app.py
@@ -1,9 +1,10 @@
#!/usr/bin/env python
+import os
from flask import Flask
from flask_bootstrap import Bootstrap5
from flask_login import LoginManager
from flask_socketio import SocketIO
-from .config import Config
+from .config import config, load_env
from .models import User, db
from .results.main_results import results
@@ -28,8 +29,9 @@ def make_shell_context():
def create_app():
app = Flask(__name__)
bootstrap.init_app(app)
- # app.register_blueprint(results)
- app.config.from_object(Config)
+ load_env()
+ config_object = config[os.getenv("BEFLASK_ENV", "development")]
+ app.config.from_object(config_object)
db.init_app(app)
login_manager.init_app(app)
login_manager.login_view = "main.login"
diff --git a/beflask/config.py b/beflask/config.py
new file mode 100644
index 0000000..25ceca0
--- /dev/null
+++ b/beflask/config.py
@@ -0,0 +1,68 @@
+import os
+from dotenv import load_dotenv
+import benchmark
+from beflask import __version__
+
+
+def get_base_dir():
+ return os.path.abspath(os.path.dirname(__file__))
+
+
+def load_env():
+ dotenv_file = ".env"
+ file_name = os.path.join(get_base_dir(), dotenv_file)
+ load_dotenv(file_name)
+
+
+class Config(object):
+ COMPARE = os.environ.get("COMPARE") == "True" or False
+ TEMPLATES_AUTO_RELOAD = True
+ SECRET_KEY = os.environ.get("SECRET_KEY") or "really-hard-to-guess-key"
+ SQLALCHEMY_DATABASE_URI = os.environ.get(
+ "DATABASE_URL"
+ ) or "sqlite:///" + os.path.join(get_base_dir(), "app.db")
+ SQLALCHEMY_TRACK_MODIFICATIONS = False
+ INDEX = "main.index"
+ APP_VERSION = __version__
+ BENCHMARK_VERSION = benchmark.__version__
+ DEBUG = os.environ.get("DEBUG") == "True" or False
+ TESTING = False
+
+
+class DevelopmentConfig(Config):
+ DEBUG = True
+
+
+class ProductionConfig(Config):
+ pass
+
+
+class TestingConfig(Config):
+ TESTING = True
+ SQLALCHEMY_DATABASE_URI = "sqlite://"
+ SOCKETIO_MESSAGE_QUEUE = None
+
+
+# class Config(object):
+# DEBUG = False
+# TESTING = False
+# SECRET_KEY = os.environ.get(
+# "SECRET_KEY", "51f52814-0071-11e6-a247-000ec6c2372c"
+# )
+# SQLALCHEMY_DATABASE_URI = os.environ.get(
+# "DATABASE_URL", "sqlite:///" + os.path.join(basedir, "db.sqlite")
+# )
+# SQLALCHEMY_TRACK_MODIFICATIONS = False
+# REQUEST_STATS_WINDOW = 15
+# CELERY_CONFIG = {}
+# SOCKETIO_MESSAGE_QUEUE = os.environ.get(
+# "SOCKETIO_MESSAGE_QUEUE",
+# os.environ.get("CELERY_BROKER_URL", "redis://"),
+# )
+
+
+config = {
+ "development": DevelopmentConfig,
+ "production": ProductionConfig,
+ "testing": TestingConfig,
+}
diff --git a/beflask/env.dist b/beflask/env.dist
new file mode 100644
index 0000000..e8bf39c
--- /dev/null
+++ b/beflask/env.dist
@@ -0,0 +1,5 @@
+COMPARE=True
+DEBUG=True
+SECRET_KEY=Really-hard-to-guess-string
+# possible values: development, testing, productions
+BEFLASK_ENV=development
diff --git a/app/forms.py b/beflask/forms.py
similarity index 100%
rename from app/forms.py
rename to beflask/forms.py
diff --git a/app/interactive/forms.py b/beflask/interactive/forms.py
similarity index 100%
rename from app/interactive/forms.py
rename to beflask/interactive/forms.py
diff --git a/app/interactive/main_interactive.py b/beflask/interactive/main_interactive.py
similarity index 100%
rename from app/interactive/main_interactive.py
rename to beflask/interactive/main_interactive.py
diff --git a/app/interactive/templates/iobase.html b/beflask/interactive/templates/iobase.html
similarity index 100%
rename from app/interactive/templates/iobase.html
rename to beflask/interactive/templates/iobase.html
diff --git a/app/interactive/templates/ranking.html b/beflask/interactive/templates/ranking.html
similarity index 100%
rename from app/interactive/templates/ranking.html
rename to beflask/interactive/templates/ranking.html
diff --git a/app/main.py b/beflask/main.py
similarity index 100%
rename from app/main.py
rename to beflask/main.py
diff --git a/app/models.py b/beflask/models.py
similarity index 100%
rename from app/models.py
rename to beflask/models.py
diff --git a/app/results/main_results.py b/beflask/results/main_results.py
similarity index 100%
rename from app/results/main_results.py
rename to beflask/results/main_results.py
diff --git a/app/results/templates/_table_dataset.html b/beflask/results/templates/_table_dataset.html
similarity index 100%
rename from app/results/templates/_table_dataset.html
rename to beflask/results/templates/_table_dataset.html
diff --git a/app/results/templates/_table_datasets.html b/beflask/results/templates/_table_datasets.html
similarity index 100%
rename from app/results/templates/_table_datasets.html
rename to beflask/results/templates/_table_datasets.html
diff --git a/app/results/templates/_table_report.html b/beflask/results/templates/_table_report.html
similarity index 100%
rename from app/results/templates/_table_report.html
rename to beflask/results/templates/_table_report.html
diff --git a/app/results/templates/_table_select.html b/beflask/results/templates/_table_select.html
similarity index 100%
rename from app/results/templates/_table_select.html
rename to beflask/results/templates/_table_select.html
diff --git a/app/results/templates/best.html b/beflask/results/templates/best.html
similarity index 100%
rename from app/results/templates/best.html
rename to beflask/results/templates/best.html
diff --git a/app/results/templates/dataset.html b/beflask/results/templates/dataset.html
similarity index 100%
rename from app/results/templates/dataset.html
rename to beflask/results/templates/dataset.html
diff --git a/app/results/templates/datasets.html b/beflask/results/templates/datasets.html
similarity index 100%
rename from app/results/templates/datasets.html
rename to beflask/results/templates/datasets.html
diff --git a/app/results/templates/error.html b/beflask/results/templates/error.html
similarity index 100%
rename from app/results/templates/error.html
rename to beflask/results/templates/error.html
diff --git a/app/results/templates/macros.html b/beflask/results/templates/macros.html
similarity index 100%
rename from app/results/templates/macros.html
rename to beflask/results/templates/macros.html
diff --git a/app/results/templates/report.html b/beflask/results/templates/report.html
similarity index 100%
rename from app/results/templates/report.html
rename to beflask/results/templates/report.html
diff --git a/app/results/templates/report_tables.html b/beflask/results/templates/report_tables.html
similarity index 100%
rename from app/results/templates/report_tables.html
rename to beflask/results/templates/report_tables.html
diff --git a/app/results/templates/select.html b/beflask/results/templates/select.html
similarity index 100%
rename from app/results/templates/select.html
rename to beflask/results/templates/select.html
diff --git a/app/static/.gitignore b/beflask/static/.gitignore
similarity index 100%
rename from app/static/.gitignore
rename to beflask/static/.gitignore
diff --git a/app/static/css/main.css b/beflask/static/css/main.css
similarity index 100%
rename from app/static/css/main.css
rename to beflask/static/css/main.css
diff --git a/app/static/excel/.gitignore b/beflask/static/excel/.gitignore
similarity index 100%
rename from app/static/excel/.gitignore
rename to beflask/static/excel/.gitignore
diff --git a/app/static/img/robert-lukeman-_RBcxo9AU-U-unsplash.jpg b/beflask/static/img/robert-lukeman-_RBcxo9AU-U-unsplash.jpg
similarity index 100%
rename from app/static/img/robert-lukeman-_RBcxo9AU-U-unsplash.jpg
rename to beflask/static/img/robert-lukeman-_RBcxo9AU-U-unsplash.jpg
diff --git a/app/static/js/excelFiles.js b/beflask/static/js/excelFiles.js
similarity index 100%
rename from app/static/js/excelFiles.js
rename to beflask/static/js/excelFiles.js
diff --git a/app/static/js/report.js b/beflask/static/js/report.js
similarity index 100%
rename from app/static/js/report.js
rename to beflask/static/js/report.js
diff --git a/app/static/js/select.js b/beflask/static/js/select.js
similarity index 100%
rename from app/static/js/select.js
rename to beflask/static/js/select.js
diff --git a/app/templates/_benchmarks.html b/beflask/templates/_benchmarks.html
similarity index 100%
rename from app/templates/_benchmarks.html
rename to beflask/templates/_benchmarks.html
diff --git a/app/templates/_nav.html b/beflask/templates/_header.html
similarity index 100%
rename from app/templates/_nav.html
rename to beflask/templates/_header.html
diff --git a/app/templates/base.html b/beflask/templates/base.html
similarity index 96%
rename from app/templates/base.html
rename to beflask/templates/base.html
index 060311a..8f2a376 100644
--- a/app/templates/base.html
+++ b/beflask/templates/base.html
@@ -19,7 +19,7 @@
{% endblock %}
-
{% include "_nav.html" %}
+
{% include "_header.html" %}
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
diff --git a/app/templates/config.html b/beflask/templates/config.html
similarity index 100%
rename from app/templates/config.html
rename to beflask/templates/config.html
diff --git a/app/templates/index.html b/beflask/templates/index.html
similarity index 100%
rename from app/templates/index.html
rename to beflask/templates/index.html
diff --git a/app/templates/login.html b/beflask/templates/login.html
similarity index 100%
rename from app/templates/login.html
rename to beflask/templates/login.html
diff --git a/beflask/templates/status.html b/beflask/templates/status.html
new file mode 100644
index 0000000..fdf4297
--- /dev/null
+++ b/beflask/templates/status.html
@@ -0,0 +1,12 @@
+
diff --git a/dbseed.py b/dbseed.py
index 452d51b..c301d59 100644
--- a/dbseed.py
+++ b/dbseed.py
@@ -1,5 +1,5 @@
-from app.models import Benchmark, db, User
-from app import app
+from beflask.models import Benchmark, db, User
+from beflask import app
app = app.create_app()
diff --git a/dbseed_docker.py b/dbseed_docker.py
index 0e8859c..0c9dc0d 100644
--- a/dbseed_docker.py
+++ b/dbseed_docker.py
@@ -1,5 +1,5 @@
-from app.models import Benchmark, db, User
-from app import app
+from beflask.models import Benchmark, db, User
+from beflask import app
app = app.create_app()
diff --git a/pyproject.toml b/pyproject.toml
index 9bd6669..0731e17 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,5 +1,53 @@
+[build-system]
+requires = ["setuptools", "setuptools-scm", "wheel"]
+build-backend = "setuptools.build_meta"
+
+[tool.setuptools]
+packages = ["beflask"]
+license-files = ["LICENSE"]
+
+[tool.setuptools.dynamic]
+version = { attr = "beflask.__version__" }
+dependencies = {file = ["requirements.txt"]}
+
+[project]
+name = "beflask"
+description = "Flask application to manage benchmarking experiments"
+readme = "README.md"
+authors = [
+ { name = "Ricardo Montañana", email = "ricardo.montanana@alu.uclm.es" },
+]
+dynamic = ['version', 'dependencies']
+
+requires-python = ">=3.8"
+classifiers = [
+ "Development Status :: 3 - Alpha",
+ "Intended Audience :: Science/Research",
+ "Intended Audience :: Developers",
+ "Topic :: Software Development",
+ "Topic :: Scientific/Engineering",
+ "License :: OSI Approved :: MIT License",
+ "Natural Language :: English",
+ "Operating System :: OS Independent",
+ "Programming Language :: Python",
+ "Programming Language :: Python",
+ "Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.9",
+ "Programming Language :: Python :: 3.10",
+]
+
+[project.optional-dependencies]
+dev = ["black", "pre-commit", "flake8", "mypy"]
+
+[project.urls]
+Home = "https://github.com/doctorado-ml/beflask"
+
+[tool.coverage.run]
+source = ["beflask"]
+
[tool.black]
line-length = 79
+target_version = ['py38', 'py39', 'py310']
include = '\.pyi?$'
exclude = '''
/(
diff --git a/requirements.txt b/requirements.txt
index 59fb6ed..0718fd5 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,4 @@
+benchmark
flask
flask-login
bootstrap-flask
diff --git a/run.py b/run.py
old mode 100644
new mode 100755
index b714525..2461be8
--- a/run.py
+++ b/run.py
@@ -1,4 +1,5 @@
-from app import app
+#!/usr/bin/env python
+from beflask import app
socketio, app = app.create_app()
-socketio.run(app, debug=True)
+socketio.run(app, debug=app.config["DEBUG"])