mlco2 / codecarbon

Track emissions from Compute and recommend ways to reduce their impact on the environment.
https://mlco2.github.io/codecarbon
MIT License
1.01k stars 158 forks source link

LuisBlanche/issue362 #461

Closed LuisBlanche closed 8 months ago

LuisBlanche commented 8 months ago
benoit-cty commented 8 months ago

Can you add the example config given in the issue to inform users that they can reduce verbosity ?

LuisBlanche commented 8 months ago

I think there is a problem with the Flake8 pre-commit hook. It raises a lot of : codecarbon/core/emissions.py:202:76: E231 missing whitespace after ':'. errors on files that were not changed.

And you can see from the following example that we cannot add a space after the ':' in that case.

logger.debug(
            f"We apply an energy mix of {emissions_per_kWh.kgs_per_kWh*1000:.0f}"
            + f" g.CO2eq/kWh for {geo.country_name}"
        )

Maybe something has changed with the Flake8 hook configuration ?

LuisBlanche commented 8 months ago

I had to ignore the following Flake8 error codes in .flake8 : E201 : Whitespace after "(" E231 : Missing whitespace after ',', ';', or ':' E226 : Missing whitespace around arithmetic operator

NB: these were only raising in the CI , not in local when running pre-commit run . E231 is raised at times it shouldn't be. The other ones are mostly raised because of line breaks introduced by black (which is acceptable imho)

LuisBlanche commented 8 months ago

@benoit-cty what do you think about the error codes i had to ignore ? seems ok to merge ?

benoit-cty commented 8 months ago

The problem was actions/setup-python@v3 that switch to Python 3.12, so I force it to 3.11.

I open a new issue for that : https://github.com/mlco2/codecarbon/issues/465

You could merge this PR :+1: