Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify SCI model code to use a single parameter for functional-unit #705

Closed
1 of 10 tasks
jmcook1186 opened this issue May 8, 2024 · 3 comments
Closed
1 of 10 tasks
Assignees
Labels
fix PR fixes a bug or improves something

Comments

@jmcook1186
Copy link
Contributor

jmcook1186 commented May 8, 2024

What

Simplify the SCI model code so that it accepts a single parameter representing functional-unit instead of two (functional-unit and functional-unit-time) .

Why

SCI is a core feature that has to be as easy as possible to build into pipelines. The current implementation puts some unnecessary burden on the user that could be abstracted away or implemented in separate plugins.

Context

When we first built the SCI plugin we wanted to be able to normalize carbon values to any functional unit, including functional units that are just units of time. We also wanted to be able to support composites of some functional unit and time such as requests/month. We ended up supporting this by using two distinct parameters: functional-unit and functional-unit-time.

Instead, we can just use functional-unit, which should come from global-level config. The value of functional-unit should be a string.

It should be assumed that functional-unit is a string that precisely matches the name of some value found in inputs, in which case the value associated with that parameter should be used as a scaling factor. If the given string does not match a key in the input data, we should error out.

In summary, remove the time manipulation features from the current SCI plugin. Also remove any logic related to operational-carbon and embodied-carbon - instead make it a hard requirement that carbon is present - if it is not found, then error out.

The plugin should ONLY divide the given carbon value by the specified functional-unit.

Prerequisites/resources

SoW (scope of work)

  • update source code to use a single parameter
  • update source to remove time logic
  • update source code to remove operational-carbon and embodied-carbon logic
  • update source code to move config from node level to global level
  • documentation updated
  • test cases added

Acceptance criteria

  • the SCI plugin accepts a single parameter representing the functional unit, called functional-unit
    • the parameter should be a string

    • GIVEN the changes have been merged
      WHEN the following manifest is executed (providing a valid functional unit) :

name: sci
description: successful path
tags:
initialize:
  outputs: ['yaml']
  plugins:
    sci:
      kind: plugin
      method: Sci
      path: "@grnsft/if-plugins"
      global-config:
          functional-unit: requests
tree:
  children:
    child:
      pipeline:
        - sci
      inputs:
        - timestamp: 2023-07-06T00:00
          duration: 1
          energy: 5
          carbon: 1
          requests: 10

THEN the following output should be generated (providing carbon per request in each timestep):

name: sci
description: successful path
tags:
initialize:
  outputs: ['yaml']
  plugins:
    sci:
      kind: plugin
      method: Sci
      path: "@grnsft/if-plugins"
      global-config:
          functional-unit: requests
tree:
  children:
    child:
      pipeline:
        - sci
      inputs:
        - timestamp: 2023-07-06T00:00
          duration: 1
          energy: 5
          carbon: 1
          requests: 10
      outputs:
        - timestamp: 2023-07-06T00:00
          duration: 1
          energy: 5
          carbon: 1
          sci: 0.1
  • GIVEN the changes have been merged
    WHEN the following manifest is executed (normalizing to functional-unit when duration is not equal to 1):
name: sci
description: successful path
tags:
initialize:
  outputs: ['yaml']
  plugins:
    sci:
      kind: plugin
      method: Sci
      path: "@grnsft/if-plugins"
      global-config:
          functional-unit: requests
tree:
  children:
    child:
      pipeline:
        - sci
      inputs:
        - timestamp: 2023-07-06T00:00
          duration: 10
          energy: 5
          carbon: 60
          requests: 10

THEN

the following output should be generated (notice the SCI is just the carbon divided by requests, with no modification due to duration):

name: sci
description: successful path
tags:
initialize:
  outputs: ['yaml']
  plugins:
    sci:
      kind: plugin
      method: Sci
      path: "@grnsft/if-plugins"
      global-config:
          functional-unit: requests
tree:
  children:
    child:
      pipeline:
        - sci
      inputs:
        - timestamp: 2023-07-06T00:00
          duration: 1
          energy: 5
          carbon: 60
          requests: 10
      outputs:
        - timestamp: 2023-07-06T00:00
          duration: 10
          energy: 5
          carbon: 60
          sci: 6
  • GIVEN the changes have been merged
    WHEN the following manifest is executed (defining a functional-unit that is missing in inputs) :
name: sci
description: successful path
tags:
initialize:
  outputs: ['yaml']
  plugins:
    sci:
      kind: plugin
      method: Sci
      path: "@grnsft/if-plugins"
      global-config:
          functional-unit: requests
tree:
  children:
    child:
      pipeline:
        - sci
      inputs:
        - timestamp: 2023-07-06T00:00
          duration: 1
          energy: 5
          carbon: 1

THEN Impact Framework should error out.

InputValidationError: the required `functional-unit` parameter is missing from the SCI plugin
  • the README documentation is updated
  • unit tests are updated and have 100% coverage and 100% passing
@jmcook1186 jmcook1186 added backlogged on the global backlog awaiting action fix PR fixes a bug or improves something labels May 8, 2024
@jmcook1186 jmcook1186 self-assigned this May 8, 2024
@jmcook1186 jmcook1186 added the help-wanted suggested for community contributions label May 16, 2024
@jmcook1186
Copy link
Contributor Author

jmcook1186 commented May 20, 2024

@pazbardanl the SCI model is being migrated into builtins (#704)
(note: this is now done)

@jmcook1186 jmcook1186 removed backlogged on the global backlog awaiting action help-wanted suggested for community contributions labels May 20, 2024
@jmcook1186 jmcook1186 removed their assignment May 20, 2024
@zanete
Copy link

zanete commented May 23, 2024

Hey @pazbardanl how's it going, wondered if you have had a chance to / will look at this issue?

@zanete zanete assigned jmcook1186 and unassigned pazbardanl May 24, 2024
@jmcook1186
Copy link
Contributor Author

closing as complete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix PR fixes a bug or improves something
Projects
Status: Done
Development

No branches or pull requests

3 participants