rycus86 / prometheus_flask_exporter

Prometheus exporter for Flask applications
https://pypi.python.org/pypi/prometheus-flask-exporter
MIT License
634 stars 162 forks source link

ImportError: cannot import name 'MethodViewType' from 'flask.views' #138

Closed harupy closed 2 years ago

harupy commented 2 years ago

We encountered the following issue:

Traceback:
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/server/test_prometheus_exporter.py:7: in <module>
    from mlflow.server.prometheus_exporter import activate_prometheus_exporter
mlflow/server/prometheus_exporter.py:1: in <module>
    from prometheus_flask_exporter.multiprocess import GunicornInternalPrometheusMetrics
/opt/hostedtoolcache/Python/3.7.12/x[64](https://github.com/mlflow/mlflow/runs/7622639194?check_suite_focus=true#step:9:65)/lib/python3.7/site-packages/prometheus_flask_exporter/__init__.py:12: in <module>
    from flask.views import MethodViewType
E   ImportError: cannot import name 'MethodViewType' from 'flask.views' (/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/flask/views.py)

https://github.com/mlflow/mlflow/runs/7622639194?check_suite_focus=true#step:9:62

It looks like flask replaced MethodViewType with MethodView in 2.2.0:

https://github.com/pallets/flask/commit/45174bf9a1e96e51ce589c7aa2c151249d1fdf11

Package versions:

Flask                                2.2.0
prometheus-flask-exporter            0.20.2
rycus86 commented 2 years ago

Thanks for reporting it @harupy ! Let me see if I can push a fix.

rycus86 commented 2 years ago

OK, the Flask bump broke a surprising number of things in our unit and integration tests, but I managed to work through them now. I've released the fix in version 0.20.3 that should be backwards compatible to pre-v1 Flask versions too. https://pypi.org/project/prometheus-flask-exporter/0.20.3/

harupy commented 2 years ago

@rycus86 Thanks for the quick fix!

hynek commented 2 years ago

Wow that was super fast – thank you so much!