Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/__tests__/unit/lib/cloud-metadata/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ describe('lib/cloud-metadata:', () => {
'Intel® Xeon® Platinum 8272CL,Intel® Xeon® 8171M 2.1 GHz,Intel® Xeon® E5-2673 v4 2.3 GHz,Intel® Xeon® E5-2673 v3 2.4 GHz',
'vcpus-allocated': 1,
'vcpus-total': 52,
'water-usage-effectiveness': 1.8,
},
]);
});
Expand Down
10 changes: 9 additions & 1 deletion src/lib/cloud-metadata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Not Needed

## Returns

An array containing:
An array containing compute information:


- `timestamp`: "2023-07-06T00:01"
Expand All @@ -31,6 +31,14 @@ An array containing:
- `cpu/thermal-design-power`: the thermal design power of the given processor (selects the first in the list of multiple are returned)


And cloud data:
- `cloud/region-cfe`: the cfe region
- `cloud/region-em-zone-id`: the em zone id
- `cloud/region-wt-id`: region id for the Watt-Time plugin
- `cloud/region-location`: region location (text)
- `cloud/region-geolocation`: geolocation lat/lon (decimal)
- `water-usage-effectiveness`: operational water usage effectiveness of a data center (L/kWh)

## IF Implementation

IF implements this plugin using data from Cloud Carbon Footprint. This allows determination of cpu for type of instance in a cloud and can be invoked as part of a plugin pipeline defined in a `manifest`.
Expand Down
5 changes: 5 additions & 0 deletions src/lib/cloud-metadata/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export const GSF_HEADERS = [
'grid-carbon-intensity-marginal',
'grid-carbon-intensity-production',
'grid-carbon-intensity',
'water-usage-effectiveness',
'water-usage-effectiveness-source',
'power-usage-effectiveness-source',
];

export const AZURE_HEADERS = [
Expand Down Expand Up @@ -47,3 +50,5 @@ export const AWS_HEADERS = [
'release-date',
'storage-drives',
];

export const WUE_DEFAULT = 1.8;
544 changes: 277 additions & 267 deletions src/lib/cloud-metadata/gsf-data.csv

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion src/lib/cloud-metadata/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {buildErrorMessage} from '../../util/helpers';
import {ERRORS} from '../../util/errors';

import {InstanceInput, RegionInput} from './types';
import {AWS_HEADERS, AZURE_HEADERS, GSF_HEADERS} from './config';
import {AWS_HEADERS, AZURE_HEADERS, GSF_HEADERS, WUE_DEFAULT} from './config';

const AWS_INSTANCES = path.resolve(__dirname, './aws-instances.csv');
const AZURE_INSTANCES = path.resolve(__dirname, './azure-instances.csv');
Expand All @@ -21,6 +21,7 @@ const {UnsupportedValueError} = ERRORS;

export const CloudMetadata = (): PluginInterface => {
const SUPPORTED_CLOUDS = ['aws', 'azure'] as const;
// const SUPPORTED_CLOUDS = ['aws', 'azure', 'gcp'] as const;
const errorBuilder = buildErrorMessage(CloudMetadata.name);
const metadata = {
kind: 'execute',
Expand Down Expand Up @@ -63,6 +64,7 @@ export const CloudMetadata = (): PluginInterface => {
const processRegionData = async (input: PluginParams) => {
const region = input['cloud/region'];
const vendor = input['cloud/vendor'];
let wue: number;

const regionInput: RegionInput = await getVendorRegion(vendor, region);

Expand All @@ -73,12 +75,23 @@ export const CloudMetadata = (): PluginInterface => {
})
);
}

if (
!regionInput['water-usage-effectiveness'] || // Check if it's empty
isNaN(parseFloat(regionInput['water-usage-effectiveness'])) // Check if it's not a number
) {
wue = WUE_DEFAULT; // Assign default value
} else {
wue = parseFloat(regionInput['water-usage-effectiveness']); // Otherwise, parse the value
}

return {
'cloud/region-cfe': regionInput['cfe-region'],
'cloud/region-em-zone-id': regionInput['em-zone-id'],
'cloud/region-wt-id': regionInput['wt-region-id'],
'cloud/region-location': regionInput['location'],
'cloud/region-geolocation': regionInput['geolocation'].trim(),
'water-usage-effectiveness': wue,
};
};

Expand Down
1 change: 1 addition & 0 deletions src/lib/cloud-metadata/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export type RegionInput = {
'wt-region-id': string;
location: string;
geolocation: string;
'water-usage-effectiveness': string;
};