Green-Software-Foundation / if

Impact Framework
https://if.greensoftware.foundation/
MIT License
143 stars 40 forks source link

Feedback - Can not resolve SciModel #415

Closed Irenia111 closed 7 months ago

Irenia111 commented 8 months ago

Scope

What does your feedback relate to?

Details

I have tried to use IF cli with the example yaml. But I kept receiving error messages as the snapshot until I deleted the SciModel config in the graph.children.child.config.sci.

Screenshot 2024-01-29 at 13 32 35

It's so weird since my colleague can resolve the same yaml file with the IF cli and we both use Mac OS and the node v18.17.1 (npm v9.6.7). The @grnsft/if, @grnsft/if-models, and @grnsft/if-unofficial-models are the same version 9.6.7.

jmcook1186 commented 8 months ago

Hi - my first guess is that you might not have the latest releases of both the Impact Framework and the plugins installed.

Can you update using:

npm i -g @grnsft/if
npm i -g @grnsft/if-models

Then let me know whether the issue resolves? And also please share which example yaml you are using - the one from the SCI model README or one from the IF repository examples/impls/test directory?

Irenia111 commented 8 months ago

npm i -g @grnsft/if-models

I have re-installed the dependencies and here are the log:

➜  gsf git:(main) ✗ nvm use 18.17.1
Now using node v18.17.1 (npm v9.6.7)
➜  gsf git:(main) ✗ npm i -g @grnsft/if

changed 85 packages in 2s

5 packages are looking for funding
  run `npm fund` for details
➜  gsf git:(main) ✗ npm i -g @grnsft/if-models                

changed 105 packages in 13s

9 packages are looking for funding
  run `npm fund` for details
➜  gsf git:(main) ✗ impact-engine --impl test.yml

[!important] Incubation Project

This project is an incubation project being run inside the Green Software Foundation; as such, we *DON’T recommend using it in any critical use case. 
Incubation projects are experimental, offer no support guarantee, have minimal governance and process, and may be retired at any moment. This project may one day graduate, in which case this disclaimer will be removed.

[!important]

You are using models that are not part of the Impact Framework standard library. You should do your own research to ensure the models are up to date and accurate. They may not be actively maintained.  

InputValidationError: Invalid input
    at validate (/Users/yuysnsun/.nvm/versions/node/v18.17.1/lib/node_modules/@grnsft/if-models/build/util/validations.js:37:15)
    at SciModel.validateInput (/Users/yuysnsun/.nvm/versions/node/v18.17.1/lib/node_modules/@grnsft/if-models/build/lib/sci/index.js:99:43)
    at /Users/yuysnsun/.nvm/versions/node/v18.17.1/lib/node_modules/@grnsft/if-models/build/lib/sci/index.js:26:36
    at Array.map (<anonymous>)
    at SciModel.execute (/Users/yuysnsun/.nvm/versions/node/v18.17.1/lib/node_modules/@grnsft/if-models/build/lib/sci/index.js:25:36)
    at Observatory.doInvestigationsWith (/Users/yuysnsun/.nvm/versions/node/v18.17.1/lib/node_modules/@grnsft/if/build/lib/observatory.js:20:44)
    at Supercomputer.calculateOutputsForChild (/Users/yuysnsun/.nvm/versions/node/v18.17.1/lib/node_modules/@grnsft/if/build/lib/supercomputer.js:103:31)
    at async Supercomputer.compute (/Users/yuysnsun/.nvm/versions/node/v18.17.1/lib/node_modules/@grnsft/if/build/lib/supercomputer.js:139:13)
    at async impactEngine (/Users/yuysnsun/.nvm/versions/node/v18.17.1/lib/node_modules/@grnsft/if/build/index.js:38:22)
(node:42128) [DEP0128] DeprecationWarning: Invalid 'main' field in '/Users/yuysnsun/.nvm/versions/node/v18.17.1/lib/node_modules/@grnsft/if-unofficial-models/node_modules/@cloud-carbon-footprint/core/dist/package.json' of 'dist/index.js'. Please either fix that or report it to the module author
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:42128) [DEP0128] DeprecationWarning: Invalid 'main' field in '/Users/yuysnsun/.nvm/versions/node/v18.17.1/lib/node_modules/@grnsft/if-unofficial-models/node_modules/@cloud-carbon-footprint/core/dist/package.json' of 'dist/index.js'. Please either fix that or report it to the module author
(node:42128) [DEP0128] DeprecationWarning: Invalid 'main' field in '/Users/yuysnsun/.nvm/versions/node/v18.17.1/lib/node_modules/@grnsft/if-unofficial-models/node_modules/@cloud-carbon-footprint/core/dist/package.json' of 'dist/index.js'. Please either fix that or report it to the module author
(node:42128) [DEP0128] DeprecationWarning: Invalid 'main' field in '/Users/yuysnsun/.nvm/versions/node/v18.17.1/lib/node_modules/@grnsft/if-unofficial-models/node_modules/@cloud-carbon-footprint/core/dist/package.json' of 'dist/index.js'. Please either fix that or report it to the module author
(node:42128) [DEP0128] DeprecationWarning: Invalid 'main' field in '/Users/yuysnsun/.nvm/versions/node/v18.17.1/lib/node_modules/@grnsft/if-unofficial-models/node_modules/@cloud-carbon-footprint/core/dist/package.json' of 'dist/index.js'. Please either fix that or report it to the module author
(node:42128) [DEP0128] DeprecationWarning: Invalid 'main' field in '/Users/yuysnsun/.nvm/versions/node/v18.17.1/lib/node_modules/@grnsft/if-unofficial-models/node_modules/@cloud-carbon-footprint/core/dist/package.json' of 'dist/index.js'. Please either fix that or report it to the module author

The yaml file I used is examples/impls/test/aggregation-test.yml

Irenia111 commented 8 months ago

If I annotate the sci model, it runs seems well:

impact-engine --impl test.yml  --ompl result.yaml

[!important] Incubation Project

This project is an incubation project being run inside the Green Software Foundation; as such, we *DON’T recommend using it in any critical use case. 
Incubation projects are experimental, offer no support guarantee, have minimal governance and process, and may be retired at any moment. This project may one day graduate, in which case this disclaimer will be removed.

[!important]

You are using models that are not part of the Impact Framework standard library. You should do your own research to ensure the models are up to date and accurate. They may not be actively maintained.  

here is the impl file test.yaml(I also annotate the aggregation, since the InvalidAggregationParams: Aggregation metric carbon is not found in inputs[0]. error):

name: nesting-demo
description:
#aggregation:
#  aggregation-metrics: ['carbon', 'energy']
#  metrics: ['carbon', 'energy']
#  type: 'horizontal'
tags:
  kind: web
  complexity: moderate
  category: on-premisen
initialize:
  models:
    - name: teads-curve
      model: TeadsCurveModel
      path: "@grnsft/if-unofficial-models"
    - name: sci-e
      model: SciEModel
      path: "@grnsft/if-models"
    - name: sci-m
      path: "@grnsft/if-models"
      model: SciMModel
    - name: sci-o
      model: SciOModel
      path: "@grnsft/if-models"
    - name: sci
      model: SciModel
      path: "@grnsft/if-models"
graph:
  children:
    child: # an advanced grouping node
      pipeline:
        - teads-curve
        - sci-e
        - sci-m
        - sci-o
#        - sci
      config:
        teads-curve:
          thermal-design-power: 65
        sci-m:
          total-embodied-emissions: 251000 # gCO2eq
          time-reserved: 3600 # 1 hour in s
          expected-lifespan: 126144000 # 4 years in seconds
          resources-reserved: 1
          total-resources: 1
        sci-o:
          grid-carbon-intensity: 457 # gCO2/kwh
#        sci:
#          functional-unit-duration: 1
#          functional-duration-time: ''
#          functional-unit: requests # factor to convert per time to per f.unit
      children:
        child-1:
          inputs:
            - timestamp: 2023-07-06T00:00
              duration: 10
              cpu-util: 10
              e-net: 0.000811 #kwh
              requests: 380
            - timestamp: 2023-07-06T00:10
              duration: 10
              cpu-util: 10
              e-net: 0.000811 #kwh
              requests: 380
            - timestamp: 2023-07-06T00:20
              duration: 10
              cpu-util: 10
              e-net: 0.000811 #kwh
              requests: 380
            - timestamp: 2023-07-06T00:30
              duration: 10
              cpu-util: 10
              e-net: 0.000811 #kwh
              requests: 380
        child-2:
          inputs:
            - timestamp: 2023-07-06T00:00
              duration: 10
              cpu-util: 20
              e-net: 0.000811 #kwh
              requests: 380
            - timestamp: 2023-07-06T00:10
              duration: 10
              cpu-util: 30
              e-net: 0.000811 #kwh
              requests: 380
            - timestamp: 2023-07-06T00:20
              duration: 10
              cpu-util: 40
              e-net: 0.000811 #kwh
              requests: 380
            - timestamp: 2023-07-06T00:30
              duration: 10
              cpu-util: 50
              e-net: 0.000811 #kwh
              requests: 380
        child-3:
          inputs:
            - timestamp: 2023-07-06T00:00
              duration: 10
              cpu-util: 10
              e-net: 0.000811 #kwh
              requests: 380
        child-4:
          inputs:
            - timestamp: 2023-07-06T00:00
              duration: 10
              cpu-util: 10
              e-net: 0.000811 #kwh
              requests: 380

here is the ompl file result.yaml:

name: nesting-demo
description: null
tags:
  kind: web
  complexity: moderate
  category: on-premisen
initialize:
  models:
    - name: teads-curve
      path: '@grnsft/if-unofficial-models'
      model: TeadsCurveModel
    - name: sci-e
      path: '@grnsft/if-models'
      model: SciEModel
    - name: sci-m
      path: '@grnsft/if-models'
      model: SciMModel
    - name: sci-o
      path: '@grnsft/if-models'
      model: SciOModel
    - name: sci
      path: '@grnsft/if-models'
      model: SciModel
graph:
  children:
    child:
      pipeline:
        - teads-curve
        - sci-e
        - sci-m
        - sci-o
      config:
        teads-curve:
          thermal-design-power: 65
        sci-m:
          total-embodied-emissions: 251000
          time-reserved: 3600
          expected-lifespan: 126144000
          resources-reserved: 1
          total-resources: 1
        sci-o:
          grid-carbon-intensity: 457
      children:
        child-1:
          inputs:
            - timestamp: 2023-07-06T00:00
              duration: 10
              cpu-util: 10
              e-net: 0.000811
              requests: 380
            - timestamp: 2023-07-06T00:10
              duration: 10
              cpu-util: 10
              e-net: 0.000811
              requests: 380
            - timestamp: 2023-07-06T00:20
              duration: 10
              cpu-util: 10
              e-net: 0.000811
              requests: 380
            - timestamp: 2023-07-06T00:30
              duration: 10
              cpu-util: 10
              e-net: 0.000811
              requests: 380
          outputs:
            - grid-carbon-intensity: 457
              energy: 0.000057777777777777776
              operational-carbon: 0.026404444444444442
            - grid-carbon-intensity: 457
              energy: 0.000057777777777777776
              operational-carbon: 0.026404444444444442
            - grid-carbon-intensity: 457
              energy: 0.000057777777777777776
              operational-carbon: 0.026404444444444442
            - grid-carbon-intensity: 457
              energy: 0.000057777777777777776
              operational-carbon: 0.026404444444444442
        child-2:
          inputs:
            - timestamp: 2023-07-06T00:00
              duration: 10
              cpu-util: 20
              e-net: 0.000811
              requests: 380
            - timestamp: 2023-07-06T00:10
              duration: 10
              cpu-util: 30
              e-net: 0.000811
              requests: 380
            - timestamp: 2023-07-06T00:20
              duration: 10
              cpu-util: 40
              e-net: 0.000811
              requests: 380
            - timestamp: 2023-07-06T00:30
              duration: 10
              cpu-util: 50
              e-net: 0.000811
              requests: 380
          outputs:
            - grid-carbon-intensity: 457
              energy: 0.00008625546239837399
              operational-carbon: 0.039418746316056914
            - grid-carbon-intensity: 457
              energy: 0.0001072720189701897
              operational-carbon: 0.04902331266937669
            - grid-carbon-intensity: 457
              energy: 0.00012295117716802168
              operational-carbon: 0.056188687965785904
            - grid-carbon-intensity: 457
              energy: 0.00013541666666666666
              operational-carbon: 0.061885416666666665
        child-3:
          inputs:
            - timestamp: 2023-07-06T00:00
              duration: 10
              cpu-util: 10
              e-net: 0.000811
              requests: 380
          outputs:
            - grid-carbon-intensity: 457
              energy: 0.000057777777777777776
              operational-carbon: 0.026404444444444442
        child-4:
          inputs:
            - timestamp: 2023-07-06T00:00
              duration: 10
              cpu-util: 10
              e-net: 0.000811
              requests: 380
          outputs:
            - grid-carbon-intensity: 457
              energy: 0.000057777777777777776
              operational-carbon: 0.026404444444444442
jmcook1186 commented 8 months ago

oooh ok - i see the problem. The example impl you are using is out of date - there is a PR open to fix this and I'm reviewing it now - I'll tag you in this comment thread when it's done so you can grab the up to date one.

EDIT: maybe you built this yaml yourself - in which case we can break down the the reasons why SCI is not working so you can debug - the inputs to the plugin are not correct - the correct set of inputs for SCI are:

functional-unit: ''
functional-unit-time: '2 min`

you can provide either or both of these - the functional-unit is generally something like "users" or "requests" depending on your use case. It doesn't matter as long as it matches a field in the input array.

functional-unit-time is there to enable you to normalize your SCI to a new time unit, e.g. maybe your input array covers one month of observations but you want a value of SCI/week or SCI/year - you just provide 1 week or 1 year as the value here.

functional-unit-duration is deprecated - it's causing your SCI model to throw an exception.

Similarly, the reason your aggregation is not working right now is that youy are telling it to aggregate carbon values from your input array but it's not there - you have embodied-carbon and operational-carbon but not just carbon (this is a downstream consequence of SCI failing to execute)

jmcook1186 commented 7 months ago

closing as complete