FlexMeasures / flexmeasures

The intelligent & developer-friendly EMS to support real-time energy flexibility apps, rapidly and scalable.
https://flexmeasures.io
Apache License 2.0
143 stars 36 forks source link

Introduce FLEXMEASURES_JSON_COMPACT setting #1090

Closed nhoening closed 3 months ago

nhoening commented 3 months ago

Description

Happening in a move to deprecate JSONIFY_PRETTYPRINT_REGULAR. We saw this deprecation warning in our server logs a lot, so it's good to move on from it.

The new setting is so we can still control it (i.e. in production you might want to read nicely).

Per default, the setting is Trueas it saves on IO volume. It is only False for development. Should it also be False during testing?

How to test

In a development environment, the default should be to not compact the JSON:

± curl -H "Content-Type: application/json" localhost:5000/api/ping
{
  "message": "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.",
  "status": 404
}

We can enforce compact JSON:

± export FLEXMEASURES_JSON_COMPACT=True; flexmeasures run

± curl -H "Content-Type: application/json" localhost:5000/api/ping
{"message":"The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.","status":404}

And the other way around:

± export FLEXMEASURES_JSON_COMPACT=False; flexmeasures run

± curl -H "Content-Type: application/json" localhost:5000/api/ping
{
  "message": "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.",
  "status": 404
}

Remember to unset this in your bash session:

± unset FLEXMEASURES_JSON_COMPACT