Green-Software-Foundation / if

Impact Framework
https://if.greensoftware.foundation/
MIT License
136 stars 37 forks source link

Move `aggregation: method` definition to feature config #842

Open jmcook1186 opened 2 weeks ago

jmcook1186 commented 2 weeks ago

What Refactor aggregation so it grabs parameter aggregation methods from manifest context.

Why This supports the deprecation of params.ts and simplifies how we configure the aggregation feature.

Context

The params.ts file is currently used to grab the aggregation method that the aggregate feature should use to aggregate the values for a given parameter across time or across components. This can be moved into the aggregate feature config. This means you only have to provide the information when it is actually needed.

This is what the config should look like in the manifest:

aggregation: metrics: 
  - 'cpu/utilization' 
    method: sum 
  - cpu/energy
    method: sum
  type: 'both’ 

Prerequisites/resources none

SoW (scope of work)

Acceptance criteria

name: Aggregation
description: Apply both `horizontal` and `vertical` aggregations
aggregation:
  metrics:
    - 'cpu/utilization'
     method: sum
    - 'cpu/energy'
      method: sum
  type: 'both'
initialize:
  plugins:
    "sum":
      path: "builtin"
      method: Sum
      global-config:
        input-parameters:
          - cpu/energy
          - network/energy
        output-parameter: energy-sum
tree:
  children:
    application:
      pipeline:
        - sum
      children:
        uk-west:
          children:
            server-1:
              inputs:
                - timestamp: '2024-02-26 00:00:00'
                  duration: 300
                  cpu/utilization: 89
                  cpu/energy: 30
                  network/energy: 1
                - timestamp: '2024-02-26 00:05:00'
                  duration: 300
                  cpu/utilization: 59
                  cpu/energy: 30
                  network/energy: 1
            server-2:
              inputs:
                - timestamp: '2024-02-26 00:00:00'
                  duration: 300
                  cpu/utilization: 24
                  network/energy: 1
                  cpu/energy: 20
                - timestamp: '2024-02-26 00:05:00'
                  duration: 300
                  cpu/utilization: 27
                  cpu/energy: 10
                  network/energy: 1

AND the params.ts file has been deleted from IF THEN the aggregate method should operate using the method values given in the manifest and return the following data:

name: Aggregation
description: Apply both `horizontal` and `vertical` aggregations
aggregation:
  metrics:
    - 'cpu/utilization'
     method: sum
    - 'cpu/energy'
      method: sum
  type: 'both'
initialize:
  plugins:
    sum:
      path: builtin
      method: Sum
      global-config:
        input-parameters:
          - cpu/energy
          - network/energy
        output-parameter: energy-sum
execution:
  command: >-
    /home/user/.npm/_npx/1bf7c3c15bf47d04/node_modules/.bin/ts-node
    /home/user/Code/if/src/index.ts -m manifests/features/aggregate.yml -s
  environment:
    if-version: 0.4.0
    os: linux
    os-version: 5.15.0-107-generic
    node-version: 21.4.0
    date-time: 2024-06-14T11:01:43.663Z (UTC)
    dependencies:
      - '@babel/core@7.22.10'
      - '@babel/preset-typescript@7.23.3'
      - '@commitlint/cli@18.6.0'
      - '@commitlint/config-conventional@18.6.0'
      - '@jest/globals@29.7.0'
      - '@types/jest@29.5.8'
      - '@types/js-yaml@4.0.9'
      - '@types/luxon@3.4.2'
      - '@types/node@20.9.0'
      - axios-mock-adapter@1.22.0
      - axios@1.7.2
      - csv-parse@5.5.6
      - csv-stringify@6.4.6
      - fixpack@4.0.0
      - gts@5.2.0
      - husky@8.0.3
      - jest@29.7.0
      - js-yaml@4.1.0
      - lint-staged@15.2.2
      - luxon@3.4.4
      - release-it@16.3.0
      - rimraf@5.0.5
      - ts-command-line-args@2.5.1
      - ts-jest@29.1.1
      - typescript-cubic-spline@1.0.1
      - typescript@5.2.2
      - winston@3.11.0
      - zod@3.22.4
  status: success
tree:
  children:
    application:
      pipeline:
        - sum
      children:
        uk-west:
          children:
            server-1:
              inputs:
                - timestamp: '2024-02-26 00:00:00'
                  duration: 300
                  cpu/utilization: 89
                  cpu/energy: 30
                  network/energy: 1
                - timestamp: '2024-02-26 00:05:00'
                  duration: 300
                  cpu/utilization: 59
                  cpu/energy: 30
                  network/energy: 1
              outputs:
                - timestamp: '2024-02-26 00:00:00'
                  duration: 300
                  cpu/utilization: 89
                  cpu/energy: 30
                  network/energy: 1
                  energy-sum: 31
                - timestamp: '2024-02-26 00:05:00'
                  duration: 300
                  cpu/utilization: 59
                  cpu/energy: 30
                  network/energy: 1
                  energy-sum: 31
              aggregated:
                cpu/utilization: 74
                cpu/energy: 60
            server-2:
              inputs:
                - timestamp: '2024-02-26 00:00:00'
                  duration: 300
                  cpu/utilization: 24
                  network/energy: 1
                  cpu/energy: 20
                - timestamp: '2024-02-26 00:05:00'
                  duration: 300
                  cpu/utilization: 27
                  cpu/energy: 10
                  network/energy: 1
              outputs:
                - timestamp: '2024-02-26 00:00:00'
                  duration: 300
                  cpu/utilization: 24
                  network/energy: 1
                  cpu/energy: 20
                  energy-sum: 21
                - timestamp: '2024-02-26 00:05:00'
                  duration: 300
                  cpu/utilization: 27
                  cpu/energy: 10
                  network/energy: 1
                  energy-sum: 11
              aggregated:
                cpu/utilization: 25.5
                cpu/energy: 30
          outputs:
            - cpu/utilization: 56.5
              cpu/energy: 50
              timestamp: '2024-02-26 00:00:00'
              duration: 300
            - cpu/utilization: 43
              cpu/energy: 40
              timestamp: '2024-02-26 00:05:00'
              duration: 300
          aggregated:
            cpu/utilization: 49.75
            cpu/energy: 90
      outputs:
        - cpu/utilization: 56.5
          cpu/energy: 50
          timestamp: '2024-02-26 00:00:00'
          duration: 300
        - cpu/utilization: 43
          cpu/energy: 40
          timestamp: '2024-02-26 00:05:00'
          duration: 300
      aggregated:
        cpu/utilization: 49.75
        cpu/energy: 90
  outputs:
    - cpu/utilization: 56.5
      cpu/energy: 50
      timestamp: '2024-02-26 00:00:00'
      duration: 300
    - cpu/utilization: 43
      cpu/energy: 40
      timestamp: '2024-02-26 00:05:00'
      duration: 300
  aggregated:
    cpu/utilization: 49.75
    cpu/energy: 90
zanete commented 2 weeks ago

@manushak @narekhovhannisyan please review AC to see if it all looks good