Boavizta / boaviztapi

🛠 Giving access to BOAVIZTA reference data and methodologies trough a RESTful API
GNU Affero General Public License v3.0
66 stars 21 forks source link

\t in servers.csv -> SSD.units\t makes verbose SSD impact data apply to only one unit #256

Closed VincentVillet closed 5 months ago

VincentVillet commented 6 months ago

Bug description

There is a \t character after SSD.units in data/archetypes/server.csv. That makes the self.units of the server disk attribute to be initialized to min:1, max:1, default:1 because the Component class expects a "units" key in its init method (models.components.component.py). As a result the impact of the SSD is always computed with a single unit even though the api call to https://api.boavizta.org/v1/server/archetype_config will show the right archetype in its output, simply with a \t after units:

"SSD": { "units\t": { "default": 4, "min": 2, "max": 8 },

And when getting server impact from archetype at /v1/server we always see SSD units at 1 for default, min and max.

To Reproduce

curl -X 'GET' \ 'https://api.boavizta.org/v1/server/archetype_config?archetype=compute_medium' \ -H 'accept: application/json'

and see the \t in the units key. "SSD": { "units\t": { "default": 4, "min": 2, "max": 8 },

curl -X 'GET' \ 'https://api.boavizta.org/v1/server/?archetype=compute_medium&verbose=true&criteria=gwp' \ -H 'accept: application/json'

and see that its SSD impact is for only one unit: "SSD-1": { "impacts": { "gwp": { "embedded": { "value": 30, "min": 8.059, "max": 274.6, "warnings": [ "End of life is not included in the calculation" ] }, "use": "not implemented", "unit": "kgCO2eq", "description": "Total climate change" } }, "units": { "value": 1, "status": "ARCHETYPE", "min": 1, "max": 1 },

Note that all archetypes will show this bug, which is especially wrong for the storage types.

Expected behavior

Have the right number of SSD units in server archetype impact. Just removing the \t should do.

da-ekchajzer commented 6 months ago

Thank you, @VincentVillet, for your PR. This bug was identified and fixed during the code refactoring conducted in this https://github.com/Boavizta/boaviztapi/pull/255. I'll let you test on the PR or wait for the release to test if the bug persists.