cernopendata / opendata.cern.ch

Source code for the CERN Open Data portal
http://opendata.cern.ch/
GNU General Public License v2.0
666 stars 148 forks source link

app: reduce number of warning messages #3532

Closed tiborsimko closed 9 months ago

tiborsimko commented 9 months ago

Current behaviour

When loading a record in the development deployment mode, there are many warning messages related to Flask that are being printed out, which makes the output quite clumsy:

$ docker exec -i -t opendatacernch-web-1 cernopendata fixtures records --mode insert-or-replace -f cernopendata/modules/fixtures/data/records/cms-trigger-information-2016.json
'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.
'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.
[2024-01-23 13:22:25,762] DEBUG in entrypoint: Loading config for entry point cernopendata = cernopendata.config
[2024-01-23 13:22:26,118] DEBUG in ext: Flask-DebugToolbar extension not installed.
'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.
[2024-01-23 13:22:26,145] DEBUG in entrypoint: Loading config for entry point cernopendata = cernopendata.config
/opt/invenio/var/instance/python/lib/python3.9/site-packages/invenio_config/default.py:72: UserWarning: Set configuration variable SECRET_KEY with random string
  warnings.warn(

[2024-01-23 13:22:26,188] DEBUG in ext: Flask-DebugToolbar extension not installed.
/opt/invenio/var/instance/python/lib/python3.9/site-packages/invenio_accounts/ext.py:245: UserWarning: The setup method 'route' can no longer be called on the blueprint 'invenio_accounts'. It has already been registered at least once, any changes will not be applied consistently.
Make sure all imports, decorators, functions, etc. needed to set up the blueprint are done before registering it.
This warning will become an exception in Flask 2.3.
  blueprint.route("/security/", methods=["GET"])(security)

/opt/invenio/var/instance/python/lib/python3.9/site-packages/flask/scaffold.py:449: UserWarning: The setup method 'add_url_rule' can no longer be called on the blueprint 'invenio_accounts'. It has already been registered at least once, any changes will not be applied consistently.
Make sure all imports, decorators, functions, etc. needed to set up the blueprint are done before registering it.
This warning will become an exception in Flask 2.3.
  self.add_url_rule(rule, endpoint, f, **options)

/opt/invenio/var/instance/python/lib/python3.9/site-packages/flask/blueprints.py:493: UserWarning: The setup method 'record' can no longer be called on the blueprint 'invenio_accounts'. It has already been registered at least once, any changes will not be applied consistently.
Make sure all imports, decorators, functions, etc. needed to set up the blueprint are done before registering it.
This warning will become an exception in Flask 2.3.
  self.record(

/opt/invenio/var/instance/python/lib/python3.9/site-packages/invenio_accounts/ext.py:246: UserWarning: The setup method 'route' can no longer be called on the blueprint 'invenio_accounts'. It has already been registered at least once, any changes will not be applied consistently.
Make sure all imports, decorators, functions, etc. needed to set up the blueprint are done before registering it.
This warning will become an exception in Flask 2.3.
  blueprint.route("/sessions/revoke/", methods=["POST"])(revoke_session)

/opt/invenio/var/instance/python/lib/python3.9/site-packages/invenio_rest/ext.py:30: FutureWarning: CSRF validation will be enabled by default in the version 1.3.x
  self.init_app(app)

/opt/invenio/var/instance/python/lib/python3.9/site-packages/flask_caching/__init__.py:153: DeprecationWarning: Using the initialization functions in flask_caching.backend is deprecated.  Use the a full path to backend classes directly.
  warnings.warn(

/code/cernopendata/modules/records/serializers/schemas/schemaorg_schemas.py:36: RemovedInMarshmallow4Warning: The 'default' argument to fields is deprecated. Use 'dump_default' instead.
  context_ = fields.Field(default="https://schema.org/", data_key="@context")

'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.
Loading records from cernopendata/modules/fixtures/data/records/cms-trigger-information-2016.json ...
/opt/invenio/var/instance/python/lib/python3.9/site-packages/sqlalchemy_continuum/plugins/flask.py:36: DeprecationWarning: '_app_ctx_stack' is deprecated and will be removed in Flask 2.3. Use 'g' to store data, or 'app_ctx' to access the current context.
  if _app_ctx_stack.top is None or _request_ctx_stack.top is None:

/opt/invenio/var/instance/python/lib/python3.9/site-packages/sqlalchemy_continuum/plugins/flask.py:36: DeprecationWarning: '_request_ctx_stack' is deprecated and will be removed in Flask 2.3. Use 'g' to store data, or 'request_ctx' to access the current context.
  if _app_ctx_stack.top is None or _request_ctx_stack.top is None:

/opt/invenio/var/instance/python/lib/python3.9/site-packages/sqlalchemy_continuum/plugins/flask.py:46: DeprecationWarning: '_app_ctx_stack' is deprecated and will be removed in Flask 2.3. Use 'g' to store data, or 'app_ctx' to access the current context.
  if _app_ctx_stack.top is None or _request_ctx_stack.top is None:

/opt/invenio/var/instance/python/lib/python3.9/site-packages/sqlalchemy_continuum/plugins/flask.py:46: DeprecationWarning: '_request_ctx_stack' is deprecated and will be removed in Flask 2.3. Use 'g' to store data, or 'request_ctx' to access the current context.
  if _app_ctx_stack.top is None or _request_ctx_stack.top is None:

Record recid 30300 updated.
/usr/lib64/python3.9/site-packages/XRootD/client/finalize.py:46: DeprecationWarning: Importing 'itsdangerous.json' is deprecated and will be removed in ItsDangerous 2.1. Use Python's 'json' module instead.
  if isinstance(obj, File) and obj.is_open():

Expected behaviour

It would be good to hide away some of these messages in order to reach a cleaner appearance, ideally approaching:

$ docker exec -i -t opendatacernch-web-1 cernopendata fixtures records --mode insert-or-replace -f cernopendata/modules/fixtures/data/records/cms-trigger-information-2016.json
Record recid 30300 updated.
tiborsimko commented 8 months ago

Note that the situation after this commit is better, but still not ideal:

$ docker exec -i -t opendatacernch-web-1 cernopendata fixtures records --mode insert-or-replace -f cernopendata/modules/fixtures/data/records/cms-trigger-information-2016.json
[2024-02-19 17:12:11,119] DEBUG in entrypoint: Loading config for entry point cernopendata = cernopendata.config
/opt/invenio/var/instance/python/lib/python3.9/site-packages/flask_limiter/errors.py:12: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if LooseVersion(werkzeug_version) < LooseVersion("0.9"):  # pragma: no cover

[2024-02-19 17:12:11,332] DEBUG in ext: Flask-DebugToolbar extension not installed.
[2024-02-19 17:12:11,495] DEBUG in entrypoint: Loading config for entry point cernopendata = cernopendata.config
/opt/invenio/var/instance/python/lib/python3.9/site-packages/invenio_config/default.py:77: UserWarning: Set configuration variable SECRET_KEY with random string
  warnings.warn(

/opt/invenio/var/instance/python/lib/python3.9/site-packages/flask_caching/__init__.py:153: DeprecationWarning: Using the initialization functions in flask_caching.backend is deprecated.  Use the a full path to backend classes directly.
  warnings.warn(

[2024-02-19 17:12:11,551] DEBUG in ext: Flask-DebugToolbar extension not installed.
/opt/invenio/var/instance/python/lib/python3.9/site-packages/invenio_rest/ext.py:30: FutureWarning: CSRF validation will be enabled by default in the version 1.3.x
  self.init_app(app)

/code/cernopendata/modules/records/serializers/schemas/schemaorg_schemas.py:36: RemovedInMarshmallow4Warning: The 'default' argument to fields is deprecated. Use 'dump_default' instead.
  context_ = fields.Field(default="https://schema.org/", data_key="@context")

Loading records from cernopendata/modules/fixtures/data/records/cms-trigger-information-2016.json ...
/opt/invenio/var/instance/python/lib/python3.9/site-packages/sqlalchemy_continuum/plugins/flask.py:36: DeprecationWarning: '_app_ctx_stack' is deprecated and will be removed in Flask 2.3. Use 'g' to store data, or 'app_ctx' to access the current context.
  if _app_ctx_stack.top is None or _request_ctx_stack.top is None:

/opt/invenio/var/instance/python/lib/python3.9/site-packages/sqlalchemy_continuum/plugins/flask.py:36: DeprecationWarning: '_request_ctx_stack' is deprecated and will be removed in Flask 2.3. Use 'g' to store data, or 'request_ctx' to access the current context.
  if _app_ctx_stack.top is None or _request_ctx_stack.top is None:

/opt/invenio/var/instance/python/lib/python3.9/site-packages/sqlalchemy_continuum/plugins/flask.py:46: DeprecationWarning: '_app_ctx_stack' is deprecated and will be removed in Flask 2.3. Use 'g' to store data, or 'app_ctx' to access the current context.
  if _app_ctx_stack.top is None or _request_ctx_stack.top is None:

/opt/invenio/var/instance/python/lib/python3.9/site-packages/sqlalchemy_continuum/plugins/flask.py:46: DeprecationWarning: '_request_ctx_stack' is deprecated and will be removed in Flask 2.3. Use 'g' to store data, or 'request_ctx' to access the current context.
  if _app_ctx_stack.top is None or _request_ctx_stack.top is None:

Record recid 30300 inserted.
/usr/lib64/python3.9/site-packages/XRootD/client/finalize.py:46: DeprecationWarning: Importing 'itsdangerous.json' is deprecated and will be removed in ItsDangerous 2.1. Use Python's 'json' module instead.
  if isinstance(obj, File) and obj.is_open():