Skip to content

Commit 2e6981a

Browse files
authored
Merge pull request #944 from Green-Software-Foundation/fix-parameter-metadata
Merge `parameter-metadata` with plugin's hardcoded data
2 parents ce87cca + bb83d4d commit 2e6981a

File tree

5 files changed

+72
-68
lines changed

5 files changed

+72
-68
lines changed

src/if-run/builtins/coefficient/index.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,8 @@ export const Coefficient = (
2020
): ExecutePlugin => {
2121
const metadata = {
2222
kind: 'execute',
23-
inputs: parametersMetadata?.inputs || {
24-
carbon: {
25-
description: 'an amount of carbon emitted into the atmosphere',
26-
unit: 'gCO2e',
27-
'aggregation-method': 'sum',
28-
},
29-
},
30-
outputs: parametersMetadata?.outputs || {
31-
'carbon-product': {
32-
description: 'a product of cabon property and the coefficient',
33-
unit: 'gCO2e',
34-
'aggregation-method': 'sum',
35-
},
36-
},
23+
inputs: parametersMetadata?.inputs,
24+
outputs: parametersMetadata?.outputs,
3725
};
3826

3927
/**

src/if-run/builtins/sci-embodied/index.ts

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {z} from 'zod';
22
import {
33
ExecutePlugin,
4+
ParameterMetadata,
45
PluginParametersMetadata,
56
PluginParams,
67
} from '@grnsft/if-core/types';
@@ -16,37 +17,41 @@ export const SciEmbodied = (
1617
): ExecutePlugin => {
1718
const metadata = {
1819
kind: 'execute',
19-
inputs: parametersMetadata?.inputs || {
20-
'device/emissions-embodied': {
21-
description: 'total embodied emissions of some component',
22-
unit: 'gCO2e',
23-
'aggregation-method': 'sum',
24-
},
25-
'device/expected-lifespan': {
26-
description: 'Total Expected Lifespan of the Component in Seconds',
27-
unit: 'seconds',
28-
'aggregation-method': 'sum',
29-
},
30-
'resources-reserved': {
31-
description: 'resources reserved for an application',
32-
unit: 'count',
33-
'aggregation-method': 'none',
34-
},
35-
'resources-total': {
36-
description: 'total resources available',
37-
unit: 'count',
38-
'aggregation-method': 'none',
39-
},
40-
'vcpus-allocated': {
41-
description: 'number of vcpus allocated to particular resource',
42-
unit: 'count',
43-
'aggregation-method': 'none',
44-
},
45-
'vcpus-total': {
46-
description: 'total number of vcpus available on a particular resource',
47-
unit: 'count',
48-
'aggregation-method': 'none',
49-
},
20+
inputs: {
21+
...({
22+
'device/emissions-embodied': {
23+
description: 'total embodied emissions of some component',
24+
unit: 'gCO2e',
25+
'aggregation-method': 'sum',
26+
},
27+
'device/expected-lifespan': {
28+
description: 'Total Expected Lifespan of the Component in Seconds',
29+
unit: 'seconds',
30+
'aggregation-method': 'sum',
31+
},
32+
'resources-reserved': {
33+
description: 'resources reserved for an application',
34+
unit: 'count',
35+
'aggregation-method': 'none',
36+
},
37+
'resources-total': {
38+
description: 'total resources available',
39+
unit: 'count',
40+
'aggregation-method': 'none',
41+
},
42+
'vcpus-allocated': {
43+
description: 'number of vcpus allocated to particular resource',
44+
unit: 'count',
45+
'aggregation-method': 'none',
46+
},
47+
'vcpus-total': {
48+
description:
49+
'total number of vcpus available on a particular resource',
50+
unit: 'count',
51+
'aggregation-method': 'none',
52+
},
53+
} as ParameterMetadata),
54+
...parametersMetadata?.inputs,
5055
},
5156
outputs: parametersMetadata?.outputs || {
5257
'carbon-embodied': {

src/if-run/builtins/sci/index.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
PluginParams,
66
ConfigParams,
77
PluginParametersMetadata,
8+
ParameterMetadata,
89
} from '@grnsft/if-core/types';
910

1011
import {validate, allDefined} from '../../../common/util/validations';
@@ -25,18 +26,21 @@ export const Sci = (
2526
): ExecutePlugin => {
2627
const metadata = {
2728
kind: 'execute',
28-
inputs: parametersMetadata?.inputs || {
29-
carbon: {
30-
description: 'an amount of carbon emitted into the atmosphere',
31-
unit: 'gCO2e',
32-
'aggregation-method': 'sum',
33-
},
34-
'functional-unit': {
35-
description:
36-
'the name of the functional unit in which the final SCI value should be expressed, e.g. requests, users',
37-
unit: 'none',
38-
'aggregation-method': 'sum',
39-
},
29+
inputs: {
30+
...({
31+
carbon: {
32+
description: 'an amount of carbon emitted into the atmosphere',
33+
unit: 'gCO2e',
34+
'aggregation-method': 'sum',
35+
},
36+
'functional-unit': {
37+
description:
38+
'the name of the functional unit in which the final SCI value should be expressed, e.g. requests, users',
39+
unit: 'none',
40+
'aggregation-method': 'sum',
41+
},
42+
} as ParameterMetadata),
43+
...parametersMetadata?.inputs,
4044
},
4145
outputs: parametersMetadata?.outputs || {
4246
sci: {

src/if-run/builtins/sum/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,16 @@ initialize:
8686
cpu/energy:
8787
description: energy consumed by the cpu
8888
unit: kWh
89+
aggregation-method: sum
8990
network/energy:
9091
description: energy consumed by data ingress and egress
9192
unit: kWh
93+
aggregation-method: sum
9294
outputs:
9395
energy:
9496
description: sum of energy components
9597
unit: kWh
98+
aggregation-method: sum
9699
tree:
97100
children:
98101
child:

src/if-run/builtins/time-sync/index.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
TimeNormalizerConfig,
1111
TimeParams,
1212
PluginParametersMetadata,
13+
ParameterMetadata,
1314
} from '@grnsft/if-core/types';
1415

1516
import {validate} from '../../../common/util/validations';
@@ -57,17 +58,20 @@ export const TimeSync = (
5758
): ExecutePlugin => {
5859
const metadata = {
5960
kind: 'execute',
60-
inputs: parametersMetadata?.inputs || {
61-
timestamp: {
62-
description: 'refers to the time of occurrence of the input',
63-
unit: 'RFC3339',
64-
'aggregation-method': 'none',
65-
},
66-
duration: {
67-
description: 'refers to the duration of the input',
68-
unit: 'seconds',
69-
'aggregation-method': 'sum',
70-
},
61+
inputs: {
62+
...({
63+
timestamp: {
64+
description: 'refers to the time of occurrence of the input',
65+
unit: 'RFC3339',
66+
'aggregation-method': 'none',
67+
},
68+
duration: {
69+
description: 'refers to the duration of the input',
70+
unit: 'seconds',
71+
'aggregation-method': 'sum',
72+
},
73+
} as ParameterMetadata),
74+
...parametersMetadata?.inputs,
7175
},
7276
outputs: parametersMetadata?.outputs,
7377
};

0 commit comments

Comments
 (0)