From e8e670406c12b1587a6f05513e96a13382c8f0b5 Mon Sep 17 00:00:00 2001 From: "Peter A. Jonsson" Date: Thu, 7 Dec 2023 22:48:56 +0100 Subject: [PATCH] _model.py: avoid before_first_request decorator This decorator is deprecated in Flask 2.2. Remove the check for schema compatibility, generate.py already performs that check, and conftest.py ensures the tables are freshly created. Fixes #547 --- cubedash/_model.py | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/cubedash/_model.py b/cubedash/_model.py index fa09f51a7..998e39ddc 100644 --- a/cubedash/_model.py +++ b/cubedash/_model.py @@ -295,22 +295,9 @@ def internal_server_error(error): return flask.render_template("500.html") -@app.before_first_request -def enable_prometheus(): - # Enable deployment specific code for Prometheus metrics - if os.environ.get("PROMETHEUS_MULTIPROC_DIR", False): - from prometheus_flask_exporter.multiprocess import ( - GunicornInternalPrometheusMetrics, - ) - - metrics = GunicornInternalPrometheusMetrics(app, group_by="endpoint") - _LOG.info("Prometheus metrics enabled : {metrics}", extra=dict(metrics=metrics)) - +# Enable deployment specific code for Prometheus metrics +if os.environ.get("PROMETHEUS_MULTIPROC_DIR", False): + from prometheus_flask_exporter.multiprocess import GunicornInternalPrometheusMetrics -@app.before_first_request -def check_schema_compatibility(): - if not STORE.is_schema_compatible(): - raise RuntimeError( - "Cubedash schema is out of date. " - "Please rerun `cubedash-gen -v --init` to apply updates." - ) + metrics = GunicornInternalPrometheusMetrics(app, group_by="endpoint") + _LOG.info("Prometheus metrics enabled : {metrics}", extra=dict(metrics=metrics))