Skip to content

Commit

Permalink
_model.py: avoid before_first_request decorator
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pjonsson authored and omad committed Dec 10, 2023
1 parent 34daed4 commit e8e6704
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions cubedash/_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

0 comments on commit e8e6704

Please sign in to comment.