From 9fcdcbf873572f94fa4cb2277c21c35680a5ba25 Mon Sep 17 00:00:00 2001 From: manushak Date: Tue, 6 Aug 2024 19:07:41 +0400 Subject: [PATCH 01/10] fix(manifests): remove config from manifests --- .../coefficient/failure-invalid-config-input-param.yml | 2 -- .../builtins/coefficient/failure-output-param-is-null.yaml | 2 -- manifests/examples/builtins/coefficient/success.yml | 2 -- .../cloud-metadata/failure-invalid-instance-type.yaml | 1 - .../csv-lookup/cloud-metadata/failure-invalid-vendor.yaml | 1 - .../cloud-metadata/failure-missing-cloud-vendor.yml | 1 - .../examples/builtins/csv-lookup/cloud-metadata/success.yml | 1 - .../csv-lookup/tdp-finder/failure-missing-input-param.yml | 1 - .../tdp-finder/failure-unsupported-physical-processor.yml | 1 - .../examples/builtins/csv-lookup/tdp-finder/success.yml | 1 - .../builtins/divide/failure-denominator-equal-zero.yml | 2 -- .../builtins/divide/failure-invalid-config-denominator.yml | 2 -- .../examples/builtins/divide/failure-missing-numerator.yml | 2 -- .../examples/builtins/sci/failure-invalid-config-value.yml | 5 ++--- .../outputs/builtins/divide/failure-missing-numerator.yaml | 2 -- .../outputs/builtins/sci/failure-invalid-config-value.yaml | 5 ++--- manifests/outputs/pipelines/pipeline-teads-sci.yaml | 1 - 17 files changed, 4 insertions(+), 28 deletions(-) diff --git a/manifests/examples/builtins/coefficient/failure-invalid-config-input-param.yml b/manifests/examples/builtins/coefficient/failure-invalid-config-input-param.yml index 5d497b948..55f9f0b64 100644 --- a/manifests/examples/builtins/coefficient/failure-invalid-config-input-param.yml +++ b/manifests/examples/builtins/coefficient/failure-invalid-config-input-param.yml @@ -16,8 +16,6 @@ tree: pipeline: compute: - coefficient - config: - sum: inputs: - timestamp: 2023-08-06T00:00 duration: 3600 diff --git a/manifests/examples/builtins/coefficient/failure-output-param-is-null.yaml b/manifests/examples/builtins/coefficient/failure-output-param-is-null.yaml index 1ef932df0..ce722c9dd 100644 --- a/manifests/examples/builtins/coefficient/failure-output-param-is-null.yaml +++ b/manifests/examples/builtins/coefficient/failure-output-param-is-null.yaml @@ -16,8 +16,6 @@ tree: pipeline: compute: - coefficient - config: - sum: inputs: - timestamp: 2023-08-06T00:00 duration: 3600 diff --git a/manifests/examples/builtins/coefficient/success.yml b/manifests/examples/builtins/coefficient/success.yml index 69dd764eb..31e75a235 100644 --- a/manifests/examples/builtins/coefficient/success.yml +++ b/manifests/examples/builtins/coefficient/success.yml @@ -16,8 +16,6 @@ tree: pipeline: compute: - coefficient - config: - sum: inputs: - timestamp: 2023-08-06T00:00 duration: 3600 diff --git a/manifests/examples/builtins/csv-lookup/cloud-metadata/failure-invalid-instance-type.yaml b/manifests/examples/builtins/csv-lookup/cloud-metadata/failure-invalid-instance-type.yaml index 21f9769b4..6a6e2201e 100644 --- a/manifests/examples/builtins/csv-lookup/cloud-metadata/failure-invalid-instance-type.yaml +++ b/manifests/examples/builtins/csv-lookup/cloud-metadata/failure-invalid-instance-type.yaml @@ -18,7 +18,6 @@ tree: pipeline: compute: - cloud-metadata - config: inputs: - timestamp: 2023-07-06T00:00 # [KEYWORD] [NO-SUBFIELDS] time when measurement occurred cloud/vendor: aws diff --git a/manifests/examples/builtins/csv-lookup/cloud-metadata/failure-invalid-vendor.yaml b/manifests/examples/builtins/csv-lookup/cloud-metadata/failure-invalid-vendor.yaml index c9fbb8296..5098c7a95 100644 --- a/manifests/examples/builtins/csv-lookup/cloud-metadata/failure-invalid-vendor.yaml +++ b/manifests/examples/builtins/csv-lookup/cloud-metadata/failure-invalid-vendor.yaml @@ -18,7 +18,6 @@ tree: pipeline: compute: - cloud-metadata - config: inputs: - timestamp: 2023-07-06T00:00 # [KEYWORD] [NO-SUBFIELDS] time when measurement occurred cloud/vendor: gcp diff --git a/manifests/examples/builtins/csv-lookup/cloud-metadata/failure-missing-cloud-vendor.yml b/manifests/examples/builtins/csv-lookup/cloud-metadata/failure-missing-cloud-vendor.yml index 62de6150d..3c7d9d55d 100644 --- a/manifests/examples/builtins/csv-lookup/cloud-metadata/failure-missing-cloud-vendor.yml +++ b/manifests/examples/builtins/csv-lookup/cloud-metadata/failure-missing-cloud-vendor.yml @@ -18,7 +18,6 @@ tree: pipeline: compute: - cloud-metadata - config: inputs: - timestamp: 2023-07-06T00:00 # [KEYWORD] [NO-SUBFIELDS] time when measurement occurred #cloud/vendor: aws diff --git a/manifests/examples/builtins/csv-lookup/cloud-metadata/success.yml b/manifests/examples/builtins/csv-lookup/cloud-metadata/success.yml index 84e10112b..e11db823f 100644 --- a/manifests/examples/builtins/csv-lookup/cloud-metadata/success.yml +++ b/manifests/examples/builtins/csv-lookup/cloud-metadata/success.yml @@ -18,7 +18,6 @@ tree: pipeline: compute: - cloud-metadata - config: inputs: - timestamp: 2023-07-06T00:00 # [KEYWORD] [NO-SUBFIELDS] time when measurement occurred cloud/vendor: aws diff --git a/manifests/examples/builtins/csv-lookup/tdp-finder/failure-missing-input-param.yml b/manifests/examples/builtins/csv-lookup/tdp-finder/failure-missing-input-param.yml index 991bdbb8b..03791996a 100644 --- a/manifests/examples/builtins/csv-lookup/tdp-finder/failure-missing-input-param.yml +++ b/manifests/examples/builtins/csv-lookup/tdp-finder/failure-missing-input-param.yml @@ -17,7 +17,6 @@ tree: pipeline: compute: - tdp-finder - config: inputs: - timestamp: 2023-07-06T00:00 duration: 300 diff --git a/manifests/examples/builtins/csv-lookup/tdp-finder/failure-unsupported-physical-processor.yml b/manifests/examples/builtins/csv-lookup/tdp-finder/failure-unsupported-physical-processor.yml index 3d433d6b2..db0459d56 100644 --- a/manifests/examples/builtins/csv-lookup/tdp-finder/failure-unsupported-physical-processor.yml +++ b/manifests/examples/builtins/csv-lookup/tdp-finder/failure-unsupported-physical-processor.yml @@ -17,7 +17,6 @@ tree: pipeline: compute: - tdp-finder - config: inputs: - timestamp: 2023-07-06T00:00 duration: 300 diff --git a/manifests/examples/builtins/csv-lookup/tdp-finder/success.yml b/manifests/examples/builtins/csv-lookup/tdp-finder/success.yml index a04288e0c..b60869399 100644 --- a/manifests/examples/builtins/csv-lookup/tdp-finder/success.yml +++ b/manifests/examples/builtins/csv-lookup/tdp-finder/success.yml @@ -17,7 +17,6 @@ tree: pipeline: compute: - tdp-finder - config: inputs: - timestamp: 2023-07-06T00:00 duration: 300 diff --git a/manifests/examples/builtins/divide/failure-denominator-equal-zero.yml b/manifests/examples/builtins/divide/failure-denominator-equal-zero.yml index 96d627aee..c3a4d216d 100644 --- a/manifests/examples/builtins/divide/failure-denominator-equal-zero.yml +++ b/manifests/examples/builtins/divide/failure-denominator-equal-zero.yml @@ -26,8 +26,6 @@ tree: compute: - cloud-metadata - divide - config: - divide: defaults: cloud/vendor: aws cloud/instance-type: m5n.large diff --git a/manifests/examples/builtins/divide/failure-invalid-config-denominator.yml b/manifests/examples/builtins/divide/failure-invalid-config-denominator.yml index fef8a1a7c..712e1205c 100644 --- a/manifests/examples/builtins/divide/failure-invalid-config-denominator.yml +++ b/manifests/examples/builtins/divide/failure-invalid-config-denominator.yml @@ -26,8 +26,6 @@ tree: compute: - cloud-metadata - divide - config: - divide: defaults: cloud/vendor: aws cloud/instance-type: m5n.large diff --git a/manifests/examples/builtins/divide/failure-missing-numerator.yml b/manifests/examples/builtins/divide/failure-missing-numerator.yml index 5645f0ecf..59b604582 100644 --- a/manifests/examples/builtins/divide/failure-missing-numerator.yml +++ b/manifests/examples/builtins/divide/failure-missing-numerator.yml @@ -26,8 +26,6 @@ tree: compute: - cloud-metadata - divide - config: - divide: defaults: cloud/vendor: aws cloud/instance-type: m5n.large diff --git a/manifests/examples/builtins/sci/failure-invalid-config-value.yml b/manifests/examples/builtins/sci/failure-invalid-config-value.yml index 5882111dd..2d51dbe66 100644 --- a/manifests/examples/builtins/sci/failure-invalid-config-value.yml +++ b/manifests/examples/builtins/sci/failure-invalid-config-value.yml @@ -15,9 +15,8 @@ tree: pipeline: compute: - sci - config: - sci: - functional-unit: 999 # factor to convert per time to per f.unit + defaults: + functional-unit: 999 # factor to convert per time to per f.unit inputs: - timestamp: 2023-07-06T00:00 duration: 3600 diff --git a/manifests/outputs/builtins/divide/failure-missing-numerator.yaml b/manifests/outputs/builtins/divide/failure-missing-numerator.yaml index 6c714bf18..235b3395a 100644 --- a/manifests/outputs/builtins/divide/failure-missing-numerator.yaml +++ b/manifests/outputs/builtins/divide/failure-missing-numerator.yaml @@ -62,8 +62,6 @@ tree: pipeline: compute: - divide - config: - divide: null defaults: cloud/vendor: aws cloud/instance-type: m5n.large diff --git a/manifests/outputs/builtins/sci/failure-invalid-config-value.yaml b/manifests/outputs/builtins/sci/failure-invalid-config-value.yaml index 384fe14b1..c8f34a4e4 100644 --- a/manifests/outputs/builtins/sci/failure-invalid-config-value.yaml +++ b/manifests/outputs/builtins/sci/failure-invalid-config-value.yaml @@ -58,9 +58,8 @@ tree: pipeline: compute: - sci - config: - sci: - functional-unit: 999 + defaults: + functional-unit: 999 inputs: - timestamp: 2023-07-06T00:00 duration: 3600 diff --git a/manifests/outputs/pipelines/pipeline-teads-sci.yaml b/manifests/outputs/pipelines/pipeline-teads-sci.yaml index 1c2a9d005..05e28edd4 100644 --- a/manifests/outputs/pipelines/pipeline-teads-sci.yaml +++ b/manifests/outputs/pipelines/pipeline-teads-sci.yaml @@ -142,7 +142,6 @@ tree: - operational-carbon - sum-carbon - sci - config: null defaults: cpu/thermal-design-power: 100 grid/carbon-intensity: 800 From fb5622950b468e0dc127b3122c340b68224b7a94 Mon Sep 17 00:00:00 2001 From: manushak Date: Tue, 6 Aug 2024 19:10:08 +0400 Subject: [PATCH 02/10] test(mocks): remove config from mocked files --- src/__mocks__/builtins/export-yaml.ts | 2 -- src/__mocks__/fs/index.ts | 7 +++---- src/__mocks__/mock-manifest.yaml | 1 - 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/__mocks__/builtins/export-yaml.ts b/src/__mocks__/builtins/export-yaml.ts index 85f54e966..b323de7b5 100644 --- a/src/__mocks__/builtins/export-yaml.ts +++ b/src/__mocks__/builtins/export-yaml.ts @@ -6,7 +6,6 @@ export const tree = { children: { 'child-1': { pipeline: ['teads-curve', 'sum', 'sci-embodied', 'sci-o', 'sci'], - config: null, defaults: { 'cpu/thermal-design-power': 100, 'grid/carbon-intensity': 800, @@ -55,7 +54,6 @@ export const tree = { }, 'child-2': { pipeline: ['teads-curve', 'sum', 'sci-embodied', 'sci-o', 'sci'], - config: null, defaults: { 'cpu/thermal-design-power': 100, 'grid/carbon-intensity': 800, diff --git a/src/__mocks__/fs/index.ts b/src/__mocks__/fs/index.ts index 491123143..7acaf9f20 100644 --- a/src/__mocks__/fs/index.ts +++ b/src/__mocks__/fs/index.ts @@ -55,10 +55,9 @@ cpu-cores-available,cpu-cores-utilized,cpu-manufacturer,cpu-model-name,cpu-tdp,g pipeline: compute: - boavizta-cpu - config: - boavizta-cpu: - core-units: 24 - processor: Intel® Core™ i7-1185G7 + defaults: + core-units: 24 + processor: Intel® Core™ i7-1185G7 inputs: - timestamp: 2023-07-06T00:00 duration: 3600 # Secs diff --git a/src/__mocks__/mock-manifest.yaml b/src/__mocks__/mock-manifest.yaml index a69009d1e..549b2c14f 100644 --- a/src/__mocks__/mock-manifest.yaml +++ b/src/__mocks__/mock-manifest.yaml @@ -59,7 +59,6 @@ tree: pipeline: compute: - memory-energy-from-memory-util - config: null inputs: - timestamp: 2023-12-12T00:00:00.000Z duration: 3600 From d1fb8d74d8498d972d1690125b46e738bf80435d Mon Sep 17 00:00:00 2001 From: manushak Date: Tue, 6 Aug 2024 19:17:35 +0400 Subject: [PATCH 03/10] test(lib): update comupte test --- src/__tests__/if-run/lib/compute.test.ts | 25 ------------------------ 1 file changed, 25 deletions(-) diff --git a/src/__tests__/if-run/lib/compute.test.ts b/src/__tests__/if-run/lib/compute.test.ts index 912793381..4663d461b 100644 --- a/src/__tests__/if-run/lib/compute.test.ts +++ b/src/__tests__/if-run/lib/compute.test.ts @@ -252,31 +252,6 @@ describe('lib/compute: ', () => { expect(response.children.mockChild.outputs).toEqual(expectedResult); }); - - it('computes simple tree with node config and execute plugin.', async () => { - const tree = { - children: { - mockChild: { - pipeline: { - compute: ['mock'], - }, - config: { - 'cpu/name': 'Intel CPU', - }, - inputs: [ - {timestamp: 'mock-timestamp-1', duration: 10}, - {timestamp: 'mock-timestamp-2', duration: 10}, - ], - }, - }, - }; - const response = await compute(tree, paramsExecute); - const expectedResult = mockExecutePlugin().execute( - tree.children.mockChild.inputs - ); - - expect(response.children.mockChild.outputs).toEqual(expectedResult); - }); }); it('computes simple tree with observe plugin.', async () => { From 0c34bcc953dd39cded51591bf9dd59e2cd522e16 Mon Sep 17 00:00:00 2001 From: manushak Date: Tue, 6 Aug 2024 19:19:53 +0400 Subject: [PATCH 04/10] fix(config): remove config from if-env template --- src/if-env/config/env-template.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/if-env/config/env-template.yml b/src/if-env/config/env-template.yml index dc801cbc1..ec412c47b 100644 --- a/src/if-env/config/env-template.yml +++ b/src/if-env/config/env-template.yml @@ -6,7 +6,7 @@ initialize: memory-energy-from-memory-util: # you can name this any way you like! method: Coefficient # the name of the function exported from the plugin path: "builtin" # the import path - global-config: # anmy config required by the plugin + global-config: # any config required by the plugin input-parameter: "memory/utilization" coefficient: 0.0001 #kwH/GB output-parameter: "memory/energy" @@ -16,7 +16,6 @@ tree: pipeline: # the pipeline is an ordered list of plugins you want to execute compute: - memory-energy-from-memory-util # must match the name in initialize! - config: # any plugin specific, node-level config inputs: - timestamp: 2023-12-12T00:00:00.000Z # ISO 8061 string duration: 3600 # units of seconds From 73331916030db8221eb056c07569bfd242997b4c Mon Sep 17 00:00:00 2001 From: manushak Date: Tue, 6 Aug 2024 19:23:21 +0400 Subject: [PATCH 05/10] docs(builtins): remove config from builtins doc example --- src/if-run/builtins/README.md | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/if-run/builtins/README.md b/src/if-run/builtins/README.md index e05110887..a2b1a8c81 100644 --- a/src/if-run/builtins/README.md +++ b/src/if-run/builtins/README.md @@ -222,8 +222,8 @@ initialize: method: TeadsCurve path: '@grnsft/if-unofficial-plugins' sci-e: - method: SciE - path: '@grnsft/if-plugins' + method: SciEmbodied + path: 'builtin' sci-embodied: path: 'builtin' method: SciEmbodied @@ -237,6 +237,7 @@ initialize: start-time: '2023-12-12T00:00:00.000Z' # ISO timestamp end-time: '2023-12-12T00:01:00.000Z' # ISO timestamp interval: 5 # seconds + allow-padding: true tree: children: child: # an advanced grouping node @@ -247,19 +248,16 @@ tree: - sci-embodied - sci-o - time-sync - config: - teads-curve: - cpu/thermal-design-power: 65 - sci-embodied: - device/emissions-embodied: 251000 # gCO2eq - time-reserved: 3600 # 1 hour in s - device/expected-lifespan: 126144000 # 4 years in seconds - resources-reserved: 1 - resources-total: 1 - sci-o: - grid/carbon-intensity: 457 # gCO2/kwh children: child-1: + defaults: + device/emissions-embodied: 251000 # gCO2eq + time-reserved: 3600 # 1 hour in s + device/expected-lifespan: 126144000 # 4 years in seconds + resources-reserved: 1 + resources-total: 1 + grid/carbon-intensity: 457 # gCO2/kwh + cpu/thermal-design-power: 65 inputs: - timestamp: '2023-12-12T00:00:00.000Z' duration: 10 @@ -269,6 +267,7 @@ tree: requests: 300 - timestamp: '2023-12-12T00:00:10.000Z' duration: 10 + cpu/thermal-design-power: 65 cpu/utilization: 20 carbon: 200 energy: 200 From 1e4f86fadcb1dc9c9a7e51b53a6553a6b3e1f44d Mon Sep 17 00:00:00 2001 From: manushak Date: Tue, 6 Aug 2024 19:28:20 +0400 Subject: [PATCH 06/10] docs(doc): remove node config description section --- Refactor-migration-guide.md | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/Refactor-migration-guide.md b/Refactor-migration-guide.md index e29a80d0e..481eb2a7c 100644 --- a/Refactor-migration-guide.md +++ b/Refactor-migration-guide.md @@ -123,27 +123,6 @@ There have also been some changes to the structure of manifest files. Some of th allow-padding: true ``` -- **Node level config** - - We have also introduced the concept of node-level config. This is designed for pluin configuration that might vary between components in the tree. For example, for each child in the tree you might wish to use the `regroup` feature to group the outputs according to a different set of keys. - - ```yaml - tree: - children: - child-1: - pipeline: - compute: - - teads-curve - - sci-e - - sci-embodied - - sci-o - - time-sync - - sci - regroup: - - region - - cloud/instance-type - ``` - - **Defaults** We have also introduced the concept of `defaults`. This is a section in each component's definition that can be used to provide fallbacks for missing input data. For example, perhaps you have a value arriving from an external API that should be present in every observation in your inputs array, but for soem reason the API fails to deliver a value for some timestamps. In this case, IF would fallback to the value provided for that metric in the `defaults` section of the manifest for that component. @@ -229,10 +208,7 @@ Instead of the old class-based model, plugins are now functions. They conform to ```ts export type PluginInterface = { - execute: ( - inputs: PluginParams[], - config?: Record - ) => PluginParams[]; + execute: (inputs: PluginParams[]) => PluginParams[]; metadata: { kind: string; }; From d64182f3a991828476453b1052071f9f91c54217 Mon Sep 17 00:00:00 2001 From: manushak Date: Tue, 6 Aug 2024 19:29:52 +0400 Subject: [PATCH 07/10] feat(config): add `CONFIG_WARN` string --- src/if-run/config/strings.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/if-run/config/strings.ts b/src/if-run/config/strings.ts index 24835f8ed..e93fea11f 100644 --- a/src/if-run/config/strings.ts +++ b/src/if-run/config/strings.ts @@ -108,4 +108,10 @@ ${error}`, MISSING_GLOBAL_CONFIG: 'Global config is not provided.', MISSING_INPUT_DATA: (param: string) => `${param} is missing from the input array, or has nullish value.`, + CONFIG_WARN: (plugins: string, isMore: boolean) => + `You have included node-level config in your manifest to support \`${plugins}\` plugin${ + isMore ? 's' : '' + }. IF no longer supports node-level config. \`${plugins}\` plugin${ + isMore ? 's' : '' + } should be refactored to accept all its config from global config or input data.`, }; From d5d66aea7e870ef01d99d676e2c18d8f061c5d17 Mon Sep 17 00:00:00 2001 From: manushak Date: Tue, 6 Aug 2024 19:38:18 +0400 Subject: [PATCH 08/10] fix(types): remove config from types --- src/if-run/types/compute.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/if-run/types/compute.ts b/src/if-run/types/compute.ts index 6777bf553..53c6bdb78 100644 --- a/src/if-run/types/compute.ts +++ b/src/if-run/types/compute.ts @@ -3,10 +3,6 @@ import {PluginParams} from '@grnsft/if-core/types'; import {PluginStorageInterface} from './plugin-storage'; import {Context} from '../../common/types/manifest'; -export type NodeConfig = { - [key: string]: Record; -}; - export type PhasedPipeline = { observe?: string[]; regroup?: string[]; @@ -17,7 +13,6 @@ export type ComputeParams = { pluginStorage: PluginStorageInterface; context: Context; pipeline?: PhasedPipeline; - config?: NodeConfig; defaults?: PluginParams; observe?: Boolean; regroup?: Boolean; @@ -27,7 +22,6 @@ export type ComputeParams = { export type Node = { children?: any; pipeline?: PhasedPipeline; - config?: NodeConfig; defaults?: PluginParams; inputs?: PluginParams[]; outputs?: PluginParams[]; From abf2214f61273fa23fbff1fd86303c1f6fe4e0c3 Mon Sep 17 00:00:00 2001 From: manushak Date: Tue, 6 Aug 2024 19:40:45 +0400 Subject: [PATCH 09/10] feat(lib): remove config and add warning message if persists in the manifest --- src/if-run/lib/compute.ts | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/if-run/lib/compute.ts b/src/if-run/lib/compute.ts index 41a153448..ff882d887 100644 --- a/src/if-run/lib/compute.ts +++ b/src/if-run/lib/compute.ts @@ -3,15 +3,17 @@ import {PluginParams} from '@grnsft/if-core/types'; import {Regroup} from './regroup'; import {addExplainData} from './explain'; -import {mergeObjects} from '../util/helpers'; import {debugLogger} from '../../common/util/debug-logger'; +import {logger} from '../../common/util/logger'; + +import {mergeObjects} from '../util/helpers'; import {STRINGS} from '../config/strings'; import {ComputeParams, Node, PhasedPipeline} from '../types/compute'; import {isExecute} from '../types/interface'; -const {MERGING_DEFAULTS_WITH_INPUT_DATA} = STRINGS; +const {MERGING_DEFAULTS_WITH_INPUT_DATA, CONFIG_WARN} = STRINGS; /** * Traverses all child nodes based on children grouping. @@ -60,16 +62,16 @@ const mergeDefaults = ( */ const computeNode = async (node: Node, params: ComputeParams): Promise => { const pipeline = node.pipeline || (params.pipeline as PhasedPipeline); - const config = node.config || params.config; const defaults = node.defaults || params.defaults; const noFlags = !params.observe && !params.regroup && !params.compute; + warnIfConfigProvided(node); + if (node.children) { return traverse(node.children, { ...params, pipeline, defaults, - config, }); } @@ -84,10 +86,9 @@ const computeNode = async (node: Node, params: ComputeParams): Promise => { while (pipelineCopy.observe.length !== 0) { const pluginName = pipelineCopy.observe.shift() as string; const plugin = params.pluginStorage.get(pluginName); - const nodeConfig = config && config[pluginName]; if (isExecute(plugin)) { - inputStorage = await plugin.execute(inputStorage, nodeConfig); + inputStorage = await plugin.execute(inputStorage); node.inputs = inputStorage; if (params.context.explainer) { @@ -118,7 +119,6 @@ const computeNode = async (node: Node, params: ComputeParams): Promise => { regroup: undefined, }, defaults, - config, }); } @@ -129,10 +129,9 @@ const computeNode = async (node: Node, params: ComputeParams): Promise => { while (pipelineCopy.compute.length !== 0) { const pluginName = pipelineCopy.compute.shift() as string; const plugin = params.pluginStorage.get(pluginName); - const nodeConfig = config && config[pluginName]; if (isExecute(plugin)) { - inputStorage = await plugin.execute(inputStorage, nodeConfig); + inputStorage = await plugin.execute(inputStorage); node.outputs = inputStorage; debugLogger.setExecutingPluginName(); } @@ -140,6 +139,19 @@ const computeNode = async (node: Node, params: ComputeParams): Promise => { } }; +/** + * Warns if the `config` is provided in the manifest. + */ +const warnIfConfigProvided = (node: any) => { + if ('config' in node) { + const plugins = Object.keys(node.config); + const joinedPlugins = plugins.join(', '); + const isMore = plugins.length > 1; + + logger.warn(CONFIG_WARN(joinedPlugins, isMore)); + } +}; + /** * Creates copy of existing tree, then applies computing strategy. */ From 86083c1f224ff73b828443ebdddee26ff81437dd Mon Sep 17 00:00:00 2001 From: manushak Date: Mon, 12 Aug 2024 18:06:57 +0400 Subject: [PATCH 10/10] fix(src): get back config and add todo comment to remove after some time --- src/if-run/lib/compute.ts | 9 +++++++-- src/if-run/types/compute.ts | 9 +++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/if-run/lib/compute.ts b/src/if-run/lib/compute.ts index ff882d887..51bd3e2ad 100644 --- a/src/if-run/lib/compute.ts +++ b/src/if-run/lib/compute.ts @@ -62,6 +62,7 @@ const mergeDefaults = ( */ const computeNode = async (node: Node, params: ComputeParams): Promise => { const pipeline = node.pipeline || (params.pipeline as PhasedPipeline); + const config = node.config || params.config; const defaults = node.defaults || params.defaults; const noFlags = !params.observe && !params.regroup && !params.compute; @@ -72,6 +73,7 @@ const computeNode = async (node: Node, params: ComputeParams): Promise => { ...params, pipeline, defaults, + config, }); } @@ -86,9 +88,10 @@ const computeNode = async (node: Node, params: ComputeParams): Promise => { while (pipelineCopy.observe.length !== 0) { const pluginName = pipelineCopy.observe.shift() as string; const plugin = params.pluginStorage.get(pluginName); + const nodeConfig = config && config[pluginName]; if (isExecute(plugin)) { - inputStorage = await plugin.execute(inputStorage); + inputStorage = await plugin.execute(inputStorage, nodeConfig); node.inputs = inputStorage; if (params.context.explainer) { @@ -119,6 +122,7 @@ const computeNode = async (node: Node, params: ComputeParams): Promise => { regroup: undefined, }, defaults, + config, }); } @@ -129,9 +133,10 @@ const computeNode = async (node: Node, params: ComputeParams): Promise => { while (pipelineCopy.compute.length !== 0) { const pluginName = pipelineCopy.compute.shift() as string; const plugin = params.pluginStorage.get(pluginName); + const nodeConfig = config && config[pluginName]; if (isExecute(plugin)) { - inputStorage = await plugin.execute(inputStorage); + inputStorage = await plugin.execute(inputStorage, nodeConfig); node.outputs = inputStorage; debugLogger.setExecutingPluginName(); } diff --git a/src/if-run/types/compute.ts b/src/if-run/types/compute.ts index 53c6bdb78..56346d390 100644 --- a/src/if-run/types/compute.ts +++ b/src/if-run/types/compute.ts @@ -3,6 +3,13 @@ import {PluginParams} from '@grnsft/if-core/types'; import {PluginStorageInterface} from './plugin-storage'; import {Context} from '../../common/types/manifest'; +/** + * @todo: remove NodeConfig after some period + */ +export type NodeConfig = { + [key: string]: Record; +}; + export type PhasedPipeline = { observe?: string[]; regroup?: string[]; @@ -13,6 +20,7 @@ export type ComputeParams = { pluginStorage: PluginStorageInterface; context: Context; pipeline?: PhasedPipeline; + config?: NodeConfig; defaults?: PluginParams; observe?: Boolean; regroup?: Boolean; @@ -22,6 +30,7 @@ export type ComputeParams = { export type Node = { children?: any; pipeline?: PhasedPipeline; + config?: NodeConfig; defaults?: PluginParams; inputs?: PluginParams[]; outputs?: PluginParams[];