Skip to content

Commit

Permalink
docs: update boavizta doc
Browse files Browse the repository at this point in the history
  • Loading branch information
manushak committed Feb 21, 2024
1 parent c99b65a commit ae91db3
Showing 1 changed file with 44 additions and 37 deletions.
81 changes: 44 additions & 37 deletions src/lib/boavizta/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# Boavizta

> [!NOTE]
> Boavizta is a community model, not part of the IF standard library. This means the IF core team are not closely monitoring these models to keep them up to date. You should do your own research before implementing them!
> Boavizta is a community plugin, not part of the IF standard library. This means the IF core team are not closely monitoring these plugins to keep them up to date. You should do your own research before implementing them!
[Boavizta](https://boavizta.org/) is an environmental impact calculator that exposes an API we use in IEF to retrieve energy and embodied carbon estimates.

## Implementation

Boavizta exposes a [REST API](https://doc.api.boavizta.org/). If the `boavizta` model is included in an IEF pipeline, IEF sends API requests to Boavizta. The request payload is generated from input data provided to IEF in an `impl` file.
Boavizta exposes a [REST API](https://doc.api.boavizta.org/). If the `boavizta` plugin is included in an IEF pipeline, IEF sends API requests to Boavizta. The request payload is generated from input data provided to IEF in an `impl` file.

## Parameters

### Model config
### Plugin config

- `allocation`: manufacturing impacts can be reported with two allocation strategies: `TOTAL` is the total impact without adjusting for usage. `LINEAR` distrbutes the impact linearly over the lifespan of a device. See [Boavizta docs](https://doc.api.boavizta.org/Explanations/manufacture_methodology/#hover-a-specific-duration-allocation-linear) for more info.
- `physical-processor`: the name of the physical processor being used
- `core-units`: number of physical cores on a CPU
- `cpu/name`: the name of the physical processor being used
- `cpu/number-cores`: number of physical cores on a CPU
- `verbose`: determines how much information the API response contains (optional)
- `expected-lifespan`: the lifespan of the component, in seconds
- `location`: geographic location used to lookup grid carbon intensity, e.g. "USA" (optional - falls back to Boavizta default)
- `cpu/expected-lifespan`: the lifespan of the component, in seconds
- `country`: the country used to lookup grid carbon intensity, e.g. "USA" (optional - falls back to Boavizta default)

### Observations

- `cpu-util`: percentage CPU utilization for a given observation
- `cpu/utilization`: percentage CPU utilization for a given observation

## Returns

Expand All @@ -31,39 +31,47 @@ Boavizta exposes a [REST API](https://doc.api.boavizta.org/). If the `boavizta`

## Usage

To run the `boavista-cpu` model an instance of `BoaviztaCpuImpactModel` must be created and its `configure()` method called. Then, the model's `execute()` method can be called, passing `duration`,`cpu-util`,`timestamp` arguments.
To run the `boavista-cpu` plugin an instance of `BoaviztaCpuImpact` must be created and its `execute()` method called, passing `duration`,`cpu/utilization`,`timestamp` arguments.

This is how you could run the model in Typescript:
This is how you could run the plugin in Typescript:

```typescript
import {BoaviztaCpuImpactModel} from '@grnsft/if-unofficial-models';
import {BoaviztaCpuImpact} from '@grnsft/if-unofficial-plugins';

async function runBoavizta() {
const newModel = await new BoaviztaCpuImpactModel().configure({
'physical-processor': 'Intel Xeon Gold 6138f',
'core-units': 24,
'expected-lifespan': 4 * 365 * 24 * 60 * 60,
});
const usage = await newModel.calculate([
const output = BoaviztaCpuImpact({});
const usage = await output.calculate([
{
timestamp: '2021-01-01T00:00:00Z',
duration: 1,
'cpu-util': 34,
'cpu/utilization': 34,
'cpu/name': 'Intel Xeon Gold 6138f',
'cpu/number-cores': 24,
'cpu/expected-lifespan': 4 * 365 * 24 * 60 * 60,
},
{
timestamp: '2021-01-01T00:00:15Z',
duration: 1,
'cpu-util': 12,
'cpu/utilization': 12,
'cpu/name': 'Intel Xeon Gold 6138f',
'cpu/number-cores': 24,
'cpu/expected-lifespan': 4 * 365 * 24 * 60 * 60,
},
{
timestamp: '2021-01-01T00:00:30Z',
duration: 1,
'cpu-util': 1,
'cpu/utilization': 1,
'cpu/name': 'Intel Xeon Gold 6138f',
'cpu/number-cores': 24,
'cpu/expected-lifespan': 4 * 365 * 24 * 60 * 60,
},
{
timestamp: '2021-01-01T00:00:45Z',
duration: 1,
'cpu-util': 78,
'cpu/utilization': 78,
'cpu/name': 'Intel Xeon Gold 6138f',
'cpu/number-cores': 24,
'cpu/expected-lifespan': 4 * 365 * 24 * 60 * 60,
},
]);

Expand All @@ -75,42 +83,41 @@ runBoavizta();

## Example `impl`

In IEF models are expected to be invoked from an `impl` file. This is a yaml containing the model configuration and inputs. The following `impl` initializes and runs the `boavizta-cpu` model:
In IEF plugins are expected to be invoked from an `impl` file. This is a yaml containing the plugin configuration and inputs. The following `impl` initializes and runs the `boavizta-cpu` plugin:

```yaml
name: boavizta-demo
description: calls boavizta api
tags:
initialize:
models:
- name: boavizta-cpu
model: BoaviztaCpuOutputModel
path: '@grnsft/if-unofficial-models'
config:
plugins:
boavizta-cpu:
function: BoaviztaCpuOutput
path: '@grnsft/if-unofficial-plugins'
global-config:
allocation: LINEAR
verbose: true
graph:
tree:
children:
child:
pipeline:
- boavizta-cpu
config:
boavizta-cpu:
core-units: 24
physical-processor: Intel® Core™ i7-1185G7
defaults:
cpu/number-cores: 24
cpu/name: Intel® Core™ i7-1185G7
inputs:
- timestamp: 2023-07-06T00:00 # [KEYWORD] [NO-SUBFIELDS] time when measurement occurred
duration: 3600 # Secs
cpu-util: 18.392
cpu/utilization: 18.392
- timestamp: 2023-08-06T00:00 # [KEYWORD] [NO-SUBFIELDS] time when measurement occurred
duration: 3600 # Secs
cpu-util: 16
cpu/utilization: 16
```

You can run this by passing it to `impact-engine`. Run impact using the following command run from the project root:
You can run this by passing it to `if`. Run impact using the following command run from the project root:

```sh
npm i -g @grnsft/if
npm i -g @grnsft/if-unofficial-models
impact-engine --impl ./examples/impls/test/boavizta.yml --ompl ./examples/ompls/boavizta.yml
npm i -g @grnsft/if-unofficial-plugins
if --impl ./examples/impls/test/boavizta.yml --ompl ./examples/ompls/boavizta.yml
```

0 comments on commit ae91db3

Please sign in to comment.