Skip to content

Commit

Permalink
fix(builtins): merge parameter-metdata if there is harcoded data
Browse files Browse the repository at this point in the history
  • Loading branch information
manushak committed Aug 7, 2024
1 parent 20df97f commit 86f79f1
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 54 deletions.
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
26 changes: 15 additions & 11 deletions src/if-run/builtins/time-sync.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 86f79f1

Please sign in to comment.