Skip to content

Commit

Permalink
Merge pull request #944 from Green-Software-Foundation/fix-parameter-…
Browse files Browse the repository at this point in the history
…metadata

Merge `parameter-metadata` with plugin's hardcoded data
  • Loading branch information
manushak authored Aug 8, 2024
2 parents ce87cca + bb83d4d commit 2e6981a
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 68 deletions.
16 changes: 2 additions & 14 deletions src/if-run/builtins/coefficient/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,8 @@ export const Coefficient = (
): ExecutePlugin => {
const metadata = {
kind: 'execute',
inputs: parametersMetadata?.inputs || {
carbon: {
description: 'an amount of carbon emitted into the atmosphere',
unit: 'gCO2e',
'aggregation-method': 'sum',
},
},
outputs: parametersMetadata?.outputs || {
'carbon-product': {
description: 'a product of cabon property and the coefficient',
unit: 'gCO2e',
'aggregation-method': 'sum',
},
},
inputs: parametersMetadata?.inputs,
outputs: parametersMetadata?.outputs,
};

/**
Expand Down
67 changes: 36 additions & 31 deletions src/if-run/builtins/sci-embodied/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {z} from 'zod';
import {
ExecutePlugin,
ParameterMetadata,
PluginParametersMetadata,
PluginParams,
} from '@grnsft/if-core/types';
Expand All @@ -16,37 +17,41 @@ export const SciEmbodied = (
): ExecutePlugin => {
const metadata = {
kind: 'execute',
inputs: parametersMetadata?.inputs || {
'device/emissions-embodied': {
description: 'total embodied emissions of some component',
unit: 'gCO2e',
'aggregation-method': 'sum',
},
'device/expected-lifespan': {
description: 'Total Expected Lifespan of the Component in Seconds',
unit: 'seconds',
'aggregation-method': 'sum',
},
'resources-reserved': {
description: 'resources reserved for an application',
unit: 'count',
'aggregation-method': 'none',
},
'resources-total': {
description: 'total resources available',
unit: 'count',
'aggregation-method': 'none',
},
'vcpus-allocated': {
description: 'number of vcpus allocated to particular resource',
unit: 'count',
'aggregation-method': 'none',
},
'vcpus-total': {
description: 'total number of vcpus available on a particular resource',
unit: 'count',
'aggregation-method': 'none',
},
inputs: {
...({
'device/emissions-embodied': {
description: 'total embodied emissions of some component',
unit: 'gCO2e',
'aggregation-method': 'sum',
},
'device/expected-lifespan': {
description: 'Total Expected Lifespan of the Component in Seconds',
unit: 'seconds',
'aggregation-method': 'sum',
},
'resources-reserved': {
description: 'resources reserved for an application',
unit: 'count',
'aggregation-method': 'none',
},
'resources-total': {
description: 'total resources available',
unit: 'count',
'aggregation-method': 'none',
},
'vcpus-allocated': {
description: 'number of vcpus allocated to particular resource',
unit: 'count',
'aggregation-method': 'none',
},
'vcpus-total': {
description:
'total number of vcpus available on a particular resource',
unit: 'count',
'aggregation-method': 'none',
},
} as ParameterMetadata),
...parametersMetadata?.inputs,
},
outputs: parametersMetadata?.outputs || {
'carbon-embodied': {
Expand Down
28 changes: 16 additions & 12 deletions src/if-run/builtins/sci/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
PluginParams,
ConfigParams,
PluginParametersMetadata,
ParameterMetadata,
} from '@grnsft/if-core/types';

import {validate, allDefined} from '../../../common/util/validations';
Expand All @@ -25,18 +26,21 @@ export const Sci = (
): ExecutePlugin => {
const metadata = {
kind: 'execute',
inputs: parametersMetadata?.inputs || {
carbon: {
description: 'an amount of carbon emitted into the atmosphere',
unit: 'gCO2e',
'aggregation-method': 'sum',
},
'functional-unit': {
description:
'the name of the functional unit in which the final SCI value should be expressed, e.g. requests, users',
unit: 'none',
'aggregation-method': 'sum',
},
inputs: {
...({
carbon: {
description: 'an amount of carbon emitted into the atmosphere',
unit: 'gCO2e',
'aggregation-method': 'sum',
},
'functional-unit': {
description:
'the name of the functional unit in which the final SCI value should be expressed, e.g. requests, users',
unit: 'none',
'aggregation-method': 'sum',
},
} as ParameterMetadata),
...parametersMetadata?.inputs,
},
outputs: parametersMetadata?.outputs || {
sci: {
Expand Down
3 changes: 3 additions & 0 deletions src/if-run/builtins/sum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,16 @@ initialize:
cpu/energy:
description: energy consumed by the cpu
unit: kWh
aggregation-method: sum
network/energy:
description: energy consumed by data ingress and egress
unit: kWh
aggregation-method: sum
outputs:
energy:
description: sum of energy components
unit: kWh
aggregation-method: sum
tree:
children:
child:
Expand Down
26 changes: 15 additions & 11 deletions src/if-run/builtins/time-sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
TimeNormalizerConfig,
TimeParams,
PluginParametersMetadata,
ParameterMetadata,
} from '@grnsft/if-core/types';

import {validate} from '../../../common/util/validations';
Expand Down Expand Up @@ -57,17 +58,20 @@ export const TimeSync = (
): ExecutePlugin => {
const metadata = {
kind: 'execute',
inputs: parametersMetadata?.inputs || {
timestamp: {
description: 'refers to the time of occurrence of the input',
unit: 'RFC3339',
'aggregation-method': 'none',
},
duration: {
description: 'refers to the duration of the input',
unit: 'seconds',
'aggregation-method': 'sum',
},
inputs: {
...({
timestamp: {
description: 'refers to the time of occurrence of the input',
unit: 'RFC3339',
'aggregation-method': 'none',
},
duration: {
description: 'refers to the duration of the input',
unit: 'seconds',
'aggregation-method': 'sum',
},
} as ParameterMetadata),
...parametersMetadata?.inputs,
},
outputs: parametersMetadata?.outputs,
};
Expand Down

0 comments on commit 2e6981a

Please sign in to comment.