Green-Software-Foundation / if

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

Add `explainer` that collates `metadata` from plugins in a pipeline #818

Open zanete opened 3 weeks ago

zanete commented 3 weeks ago

Why: Sub of #761 What: Add explain feature that collates metadata from all the plugins in a pipeline and reports it in a new explain block

Blocked by:

Context In https://github.com/Green-Software-Foundation/if/issues/815 we are adding parameter metadata as a property of the initialized plugin instance that is set during the plugin initialization. The explain feature will list out the metadata for every initialized plugin in the manifest.

It should be triggered simply by passing a boolean to explain in the top level manifest context, e.g.

explainer: true

If any other value is passed to explainer the feature should not execute.

Scope of work:

Acceptance criteria

name: pipeline-teads-sci
description: a full pipeline seeded with some hardcoded input data and yielding an SCI score
tags:
explain: true
initialize:
  plugins:
    "sum":
       path: "builtin"
       method: Sum
       global-config:
         input-parameters:
           - cpu/energy
           - network/energy
         output-parameter: energy-sum
         parameter-metadata:
           inputs:
             - cpu/energy
               description: energy consumed by the CPU 
               unit: 'kWh'
             - network/energy
               description: energy consumed by network data ingress/egress  
               unit: 'kWh'
            outputs:
              - energy-sum
                description: sum of energy components
                unit: kWh
    "coefficient":
       path: "builtin"
       method: Coefficient
       global-config:
         input-parameter: energy
         coefficient: 2
         output-parameter: energy-doubled
      parameter-metadata:
        inputs:
          - energy
            description: energy consumed by the CPU 
            unit: 'kWh'
          - coefficient
            description: coefficient applied to energy to yield energy-doubled  
            unit: 'dimensionless'          
         outputs:
           - energy-doubled
             description: energy multiplied by coefficient  
             unit: 'kWh'
tree:
  children:
    child-1:
      pipeline:
        - sum
        - coefficient
      defaults:
      inputs:
        - timestamp: "2023-12-12T00:00:00.000Z"
          cloud/instance-type: A1
          cloud/region: uk-west
          duration: 1
          cpu/utilization: 50
          network/energy: 0.000001
        - timestamp: "2023-12-12T00:00:01.000Z"
          duration: 5
          cpu/utilization: 20
          cloud/instance-type: A1
          cloud/region: uk-west
          network/energy: 0.000001
        - timestamp: "2023-12-12T00:00:06.000Z"
          duration: 7
          cpu/utilization: 15
          cloud/instance-type: A1
          cloud/region: uk-west
          network/energy: 0.000001
        - timestamp: "2023-12-12T00:00:13.000Z"
          duration: 30
          cloud/instance-type: A1
          cloud/region: uk-west
          cpu/utilization: 15
          network/energy: 0.000001

THEN the following block would be added to the outputs, above the tree:

explain:
  sum:
    method: Sum
    path: builtin
    inputs:
      - name: energy/cpu
        description: energy consumed by cpu
        unit: kWh
      - name: energy/network
        description: energy consumed by network data ingress/egress
        unit: kWh
    outputs:
      - energy-sum
        description: sum of energy components
        unit: kWh
  coefficient:
    method: Coefficient
    path: builtin
    inputs:
      - energy
        description: energy consumed by the CPU 
        unit: 'kWh'
      - coefficient
        description: coefficient applied to energy to yield energy-doubled  
        unit: 'dimensionless'          
     outputs:
       - energy-doubled
         description: energy multiplied by coefficient  
         unit: 'kWh'
explain:
  example:
    method: SomeMethod
    path: '@grnsft/dummy-plugins'
    inputs:
    outputs:
zanete commented 2 weeks ago

@manushak @narekhovhannisyan please review ac to confirm you're ok with it