Green-Software-Foundation/carbon-aware-sdk

[Bug]: Configuration for locations loads twice

vaughanknight opened this issue · 2 comments

Contact Details

No response

What happened?

The configuration for locations loads twice at startup, it's visible in the logs with suffixed locations being loaded at startup i.e. westus, and then westus_1. It happens for all configured location files.

client

WebAPI (Default)

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

I saw same issue, and I created a patch (but I've not sent it as a PR): YaSuenag@84662a4

Maybe it happens when both EmissionsDataSource and ForecastDataSource are defined.
LocationSource would be loaded when each data source are prepared, so same location JSON would be loaded by preparation phase of both EmissionsDatasource and ForecastDataSource.

My patch adds HashSet to remember loaded location JSONs, so it prevents to load in twice.

I can send PR if you want.

Fixed as part of #532 not to load twice