Boavizta / boaviztapi

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

Verbose output of CPU and RAM use impact values are inconsistent with total use impact values #297

Open davidkopp opened 4 months ago

davidkopp commented 4 months ago

Bug description

Using the verbose output, the usage impacts of individual components are higher than the total usage impact. I would expect that the total usage impact is the sum of all individual components.

The individual embedded impacts seems to be consistent with the total value.

To Reproduce

Make any request with verbose=true.

Example request:

 curl -X 'POST' 'https://api.boavizta.org/v1/cloud/instance?verbose=true&criteria=gwp' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{
  "provider": "aws",
  "instance_type": "t3.large",
  "usage": {
    "usage_location": "DEU",
    "time_workload": [
      {
        "time_percentage": 100,
        "load_percentage": 100
      }
    ]
  }
}' | jq

Expected behavior

The sum of the use values of all individual components is equal to the total use value.

Actual values:

JSON OUTPUT

The following JSON is a shorted version including only the relevant properties regarding this issue.

{
  "impacts": {
    "gwp": {
      "unit": "kgCO2eq",
      "description": "Total climate change",
      "use": {
        "value": 245,
        "min": 221.5,
        "max": 295.3
      }
    }
  },
  "verbose": {
    "CPU-1": {
      "impacts": {
        "gwp": {
          "unit": "kgCO2eq",
          "description": "Total climate change",
          "use": {
            "value": 301.9,
            "min": 301.9,
            "max": 301.9
          }
        }
      },
    },
    "RAM-1": {
      "impacts": {
        "gwp": {
          "unit": "kgCO2eq",
          "description": "Total climate change",
          "use": {
            "value": 403.1,
            "min": 403.1,
            "max": 403.1
          }
        }
      }
    }
  }
}