@grnsft/if 0.4.0-beta.1 → 0.5.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +7 -5
- package/README.md +20 -33
- package/Refactor-migration-guide.md +5 -6
- package/build/builtins/coefficient/index.d.ts +1 -2
- package/build/builtins/coefficient/index.js +18 -4
- package/build/builtins/copy-param/index.d.ts +2 -0
- package/build/builtins/copy-param/index.js +68 -0
- package/build/builtins/csv-lookup/index.d.ts +1 -1
- package/build/builtins/csv-lookup/index.js +44 -37
- package/build/builtins/divide/index.d.ts +1 -1
- package/build/builtins/divide/index.js +22 -11
- package/build/builtins/exponent/index.d.ts +1 -2
- package/build/builtins/exponent/index.js +9 -23
- package/build/builtins/export-csv-raw.d.ts +4 -2
- package/build/builtins/export-csv-raw.js +7 -7
- package/build/builtins/export-csv.js +8 -11
- package/build/builtins/export-log.js +1 -1
- package/build/builtins/export-yaml.js +6 -6
- package/build/builtins/group-by.d.ts +1 -1
- package/build/builtins/group-by.js +5 -5
- package/build/builtins/index.d.ts +1 -0
- package/build/builtins/index.js +4 -2
- package/build/builtins/interpolation/index.d.ts +1 -1
- package/build/builtins/interpolation/index.js +10 -8
- package/build/builtins/mock-observations/helpers/common-generator.d.ts +2 -2
- package/build/builtins/mock-observations/helpers/common-generator.js +10 -13
- package/build/builtins/mock-observations/helpers/rand-int-generator.d.ts +2 -2
- package/build/builtins/mock-observations/helpers/rand-int-generator.js +14 -24
- package/build/builtins/mock-observations/index.d.ts +1 -2
- package/build/builtins/mock-observations/index.js +2 -4
- package/build/builtins/multiply/index.d.ts +1 -2
- package/build/builtins/multiply/index.js +10 -16
- package/build/builtins/regex/index.d.ts +1 -2
- package/build/builtins/regex/index.js +8 -12
- package/build/builtins/sci/index.d.ts +1 -2
- package/build/builtins/sci/index.js +23 -22
- package/build/builtins/sci-embodied/index.d.ts +1 -1
- package/build/builtins/sci-embodied/index.js +16 -17
- package/build/builtins/shell/index.d.ts +1 -2
- package/build/builtins/shell/index.js +4 -4
- package/build/builtins/subtract/index.d.ts +1 -2
- package/build/builtins/subtract/index.js +7 -23
- package/build/builtins/sum/index.d.ts +1 -2
- package/build/builtins/sum/index.js +14 -11
- package/build/builtins/time-sync.d.ts +1 -2
- package/build/builtins/time-sync.js +62 -67
- package/build/check.d.ts +2 -0
- package/build/check.js +85 -0
- package/build/config/config.d.ts +13 -1
- package/build/config/config.js +61 -1
- package/build/config/params.js +1 -6
- package/build/config/strings.d.ts +41 -5
- package/build/config/strings.js +46 -9
- package/build/diff.js +7 -2
- package/build/env.d.ts +2 -0
- package/build/env.js +38 -0
- package/build/lib/aggregate.js +1 -1
- package/build/lib/compute.js +1 -1
- package/build/lib/exhaust.js +4 -4
- package/build/lib/initialize.js +20 -24
- package/build/lib/load.js +5 -7
- package/build/types/compute.d.ts +1 -1
- package/build/types/compute.js +1 -1
- package/build/types/if-env.d.ts +8 -0
- package/build/types/if-env.js +3 -0
- package/build/types/interface.d.ts +1 -19
- package/build/types/interface.js +1 -1
- package/build/types/npm.d.ts +9 -0
- package/build/types/npm.js +3 -0
- package/build/types/process-args.d.ts +9 -0
- package/build/types/process-args.js +1 -1
- package/build/types/util/args.d.ts +1 -0
- package/build/types/util/args.js +1 -1
- package/build/util/aggregation-helper.d.ts +1 -1
- package/build/util/aggregation-helper.js +5 -5
- package/build/util/args.d.ts +23 -1
- package/build/util/args.js +91 -14
- package/build/util/fs.d.ts +20 -0
- package/build/util/fs.js +94 -0
- package/build/util/helpers.d.ts +26 -6
- package/build/util/helpers.js +112 -17
- package/build/util/npm.d.ts +28 -0
- package/build/util/npm.js +152 -0
- package/build/util/plugin-storage.js +4 -4
- package/build/util/validations.js +4 -4
- package/github-processes.md +39 -0
- package/jest.config.js +1 -1
- package/manifests/bugs/aggregation-error-wrong-metric.yml +73 -23
- package/manifests/bugs/azure-importer-ignoring-defaults.yml +6 -3
- package/manifests/bugs/azure-importer-incorrect-calculation.yml +6 -3
- package/manifests/bugs/initialize-error-no-config.yml +4 -5
- package/manifests/bugs/initialize-error-no-path.yml +9 -5
- package/manifests/bugs/input-error-missing-duration.yml +10 -6
- package/manifests/bugs/pipeline-error-naming-mismatch.yml +8 -4
- package/manifests/bugs/pipeline-error-uninitialized-plugin.yml +9 -5
- package/manifests/bugs/pipeline-ordering-error.yml +43 -34
- package/manifests/examples/copy.yaml +20 -0
- package/manifests/examples/generics.yml +48 -13
- package/manifests/examples/instance-metadata.yml +4 -4
- package/manifests/examples/mock-cpu-util-to-carbon.yml +8 -2
- package/manifests/examples/nesting.yml +82 -35
- package/manifests/examples/pipeline-teads-sci.yml +54 -18
- package/manifests/examples/pipeline-with-aggregate.yml +66 -24
- package/manifests/examples/pipeline-with-mocks.yml +65 -22
- package/manifests/examples/region-metadata.yml +26 -0
- package/manifests/examples/tdp-finder.yml +23 -0
- package/manifests/examples/zeros.yaml +130 -0
- package/manifests/features/{aggregate-failure-inalid-metrics.yml → aggregate-failure-invalid-metrics.yml} +9 -3
- package/manifests/features/aggregate-failure-missing-metric-in-inputs.yml +9 -3
- package/manifests/features/aggregate-horizontal.yml +8 -2
- package/manifests/features/aggregate-vertical.yml +8 -2
- package/manifests/features/aggregate.yml +8 -2
- package/manifests/integrations/{cloud-metadata-divide-boavizta.yml → cloud-metadata-divide.yml} +8 -9
- package/manifests/integrations/instance-metadata/failure-invalid-instance-type.yaml +33 -0
- package/manifests/integrations/instance-metadata/failure-invalid-provider.yaml +33 -0
- package/manifests/integrations/instance-metadata/failure-missing-queried-input.yml +33 -0
- package/manifests/integrations/instance-metadata/success.yml +33 -0
- package/manifests/integrations/mock-obs-group-by-cloud-meta.yml +8 -2
- package/manifests/integrations/mock-obs-time-sync.yml +50 -5
- package/manifests/plugins/{cloud-metadata → csv-lookup/cloud-metadata}/failure-invalid-instance-type.yaml +9 -3
- package/manifests/plugins/{cloud-metadata → csv-lookup/cloud-metadata}/failure-invalid-vendor.yaml +8 -2
- package/manifests/plugins/{cloud-metadata → csv-lookup/cloud-metadata}/failure-missing-cloud-vendor.yml +9 -3
- package/manifests/plugins/{cloud-metadata → csv-lookup/cloud-metadata}/success.yml +8 -2
- package/manifests/plugins/csv-lookup/{success.yml → region-metadata/success.yml} +1 -1
- package/manifests/plugins/csv-lookup/tdp-finder/failure-missing-input-param.yml +23 -0
- package/manifests/plugins/csv-lookup/tdp-finder/failure-unsupported-physical-processor.yml +24 -0
- package/manifests/plugins/csv-lookup/tdp-finder/success.yml +24 -0
- package/manifests/plugins/divide/failure-denominator-equal-zero.yml +8 -9
- package/manifests/plugins/divide/failure-invalid-config-denominator.yml +8 -9
- package/manifests/plugins/divide/failure-missing-numerator.yml +8 -9
- package/manifests/plugins/divide/success.yml +9 -10
- package/manifests/plugins/exponent/success.yml +26 -0
- package/manifests/plugins/interpolation/success.yml +24 -0
- package/manifests/plugins/sci/failure-missing-input-param.yml +2 -6
- package/manifests/plugins/sci/success.yml +0 -3
- package/manifests/plugins/subtract/success.yml +25 -0
- package/manifests/plugins/sum/success.yml +1 -1
- package/package.json +10 -4
- package/src/__mocks__/mock-manifest.yaml +72 -0
- package/src/builtins/README.md +1 -1
- package/src/builtins/coefficient/README.md +19 -1
- package/src/builtins/copy-param/README.md +104 -0
- package/src/builtins/csv-lookup/README.md +39 -1
- package/src/builtins/divide/README.md +29 -3
- package/src/builtins/exponent/README.md +21 -1
- package/src/builtins/interpolation/README.md +29 -1
- package/src/builtins/mock-observations/README.md +1 -1
- package/src/builtins/multiply/README.md +16 -1
- package/src/builtins/regex/README.md +32 -2
- package/src/builtins/sci/README.md +24 -1
- package/src/builtins/sci-embodied/README.md +15 -1
- package/src/builtins/shell/README.md +12 -1
- package/src/builtins/subtract/README.md +12 -1
- package/src/builtins/sum/README.md +28 -1
- package/src/config/env-template.yml +24 -0
- package/build/builtins/coefficient/types.d.ts +0 -5
- package/build/builtins/coefficient/types.js +0 -3
- package/build/builtins/exponent/types.d.ts +0 -5
- package/build/builtins/exponent/types.js +0 -3
- package/build/builtins/interpolation/types.d.ts +0 -5
- package/build/builtins/interpolation/types.js +0 -10
- package/build/builtins/mock-observations/types.d.ts +0 -13
- package/build/builtins/mock-observations/types.js +0 -3
- package/build/builtins/multiply/types.d.ts +0 -4
- package/build/builtins/multiply/types.js +0 -3
- package/build/builtins/subtract/types.d.ts +0 -4
- package/build/builtins/subtract/types.js +0 -3
- package/build/builtins/sum/types.d.ts +0 -4
- package/build/builtins/sum/types.js +0 -3
- package/build/types/common.d.ts +0 -4
- package/build/types/common.js +0 -3
- package/build/types/group-by.d.ts +0 -3
- package/build/types/group-by.js +0 -3
- package/build/types/helpers.d.ts +0 -4
- package/build/types/helpers.js +0 -3
- package/build/util/errors.d.ts +0 -6
- package/build/util/errors.js +0 -33
- package/manifests/examples/basic.yml +0 -28
- package/manifests/plugins/tdp-finder/failure-missing-input-param.yml +0 -18
- package/manifests/plugins/tdp-finder/failure-unsupported-physical-processor.yml +0 -19
- package/manifests/plugins/tdp-finder/success.yml +0 -19
- /package/manifests/plugins/csv-lookup/{failure-missing-column.yml → region-metadata/failure-missing-column.yml} +0 -0
- /package/manifests/plugins/csv-lookup/{failure-missing-output.yml → region-metadata/failure-missing-output.yml} +0 -0
- /package/manifests/plugins/csv-lookup/{success-renaming.yml → region-metadata/success-renaming.yml} +0 -0
|
@@ -5,8 +5,14 @@ initialize:
|
|
|
5
5
|
# outputs: ['yaml']
|
|
6
6
|
plugins:
|
|
7
7
|
cloud-metadata:
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
path: builtin
|
|
9
|
+
method: CSVLookup
|
|
10
|
+
global-config:
|
|
11
|
+
filepath: >-
|
|
12
|
+
https://raw.githubusercontent.com/Green-Software-Foundation/if-data/main/cloud-metdata-aws-instances.csv
|
|
13
|
+
query:
|
|
14
|
+
instance-class: cloud/instance-type
|
|
15
|
+
output: ['cpu-cores-utilized', 'vcpus-allocated']
|
|
10
16
|
divide:
|
|
11
17
|
method: Divide
|
|
12
18
|
path: "builtin"
|
|
@@ -14,19 +20,12 @@ initialize:
|
|
|
14
20
|
numerator: vcpus-allocated
|
|
15
21
|
denominator: 0
|
|
16
22
|
output: cpu/number-cores
|
|
17
|
-
boavizta-cpu:
|
|
18
|
-
method: BoaviztaCpuOutput
|
|
19
|
-
path: "@grnsft/if-unofficial-plugins"
|
|
20
|
-
global-config:
|
|
21
|
-
allocation: LINEAR
|
|
22
|
-
verbose: true
|
|
23
23
|
tree:
|
|
24
24
|
children:
|
|
25
25
|
child:
|
|
26
26
|
pipeline:
|
|
27
27
|
- cloud-metadata
|
|
28
28
|
- divide
|
|
29
|
-
- boavizta-cpu
|
|
30
29
|
config:
|
|
31
30
|
divide:
|
|
32
31
|
defaults:
|
|
@@ -5,8 +5,14 @@ initialize:
|
|
|
5
5
|
outputs: ['yaml']
|
|
6
6
|
plugins:
|
|
7
7
|
cloud-metadata:
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
path: builtin
|
|
9
|
+
method: CSVLookup
|
|
10
|
+
global-config:
|
|
11
|
+
filepath: >-
|
|
12
|
+
https://raw.githubusercontent.com/Green-Software-Foundation/if-data/main/cloud-metdata-aws-instances.csv
|
|
13
|
+
query:
|
|
14
|
+
instance-class: cloud/instance-type
|
|
15
|
+
output: ['cpu-cores-utilized', 'vcpus-allocated']
|
|
10
16
|
divide:
|
|
11
17
|
method: Divide
|
|
12
18
|
path: "builtin"
|
|
@@ -14,19 +20,12 @@ initialize:
|
|
|
14
20
|
numerator: vcpus-allocated
|
|
15
21
|
denominator: 'vcpus'
|
|
16
22
|
output: cpu/number-cores
|
|
17
|
-
boavizta-cpu:
|
|
18
|
-
method: BoaviztaCpuOutput
|
|
19
|
-
path: "@grnsft/if-unofficial-plugins"
|
|
20
|
-
global-config:
|
|
21
|
-
allocation: LINEAR
|
|
22
|
-
verbose: true
|
|
23
23
|
tree:
|
|
24
24
|
children:
|
|
25
25
|
child:
|
|
26
26
|
pipeline:
|
|
27
27
|
- cloud-metadata
|
|
28
28
|
- divide
|
|
29
|
-
- boavizta-cpu
|
|
30
29
|
config:
|
|
31
30
|
divide:
|
|
32
31
|
defaults:
|
|
@@ -5,8 +5,14 @@ initialize:
|
|
|
5
5
|
# outputs: ['yaml']
|
|
6
6
|
plugins:
|
|
7
7
|
cloud-metadata:
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
path: builtin
|
|
9
|
+
method: CSVLookup
|
|
10
|
+
global-config:
|
|
11
|
+
filepath: >-
|
|
12
|
+
https://raw.githubusercontent.com/Green-Software-Foundation/if-data/main/cloud-metdata-aws-instances.csv
|
|
13
|
+
query:
|
|
14
|
+
instance-class: cloud/instance-type
|
|
15
|
+
output: ['cpu-cores-utilized', 'vcpus-allocated']
|
|
10
16
|
divide:
|
|
11
17
|
method: Divide
|
|
12
18
|
path: "builtin"
|
|
@@ -14,19 +20,12 @@ initialize:
|
|
|
14
20
|
#numerator: vcpus-allocated
|
|
15
21
|
denominator: 2
|
|
16
22
|
output: cpu/number-cores
|
|
17
|
-
boavizta-cpu:
|
|
18
|
-
method: BoaviztaCpuOutput
|
|
19
|
-
path: "@grnsft/if-unofficial-plugins"
|
|
20
|
-
global-config:
|
|
21
|
-
allocation: LINEAR
|
|
22
|
-
verbose: true
|
|
23
23
|
tree:
|
|
24
24
|
children:
|
|
25
25
|
child:
|
|
26
26
|
pipeline:
|
|
27
27
|
- cloud-metadata
|
|
28
28
|
- divide
|
|
29
|
-
- boavizta-cpu
|
|
30
29
|
config:
|
|
31
30
|
divide:
|
|
32
31
|
defaults:
|
|
@@ -2,11 +2,17 @@ name: divide
|
|
|
2
2
|
description: success path
|
|
3
3
|
tags:
|
|
4
4
|
initialize:
|
|
5
|
-
#
|
|
5
|
+
# outputs: ['yaml']
|
|
6
6
|
plugins:
|
|
7
7
|
cloud-metadata:
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
path: builtin
|
|
9
|
+
method: CSVLookup
|
|
10
|
+
global-config:
|
|
11
|
+
filepath: >-
|
|
12
|
+
https://raw.githubusercontent.com/Green-Software-Foundation/if-data/main/cloud-metdata-aws-instances.csv
|
|
13
|
+
query:
|
|
14
|
+
instance-class: cloud/instance-type
|
|
15
|
+
output: ['cpu-cores-utilized', 'vcpus-allocated']
|
|
10
16
|
divide:
|
|
11
17
|
method: Divide
|
|
12
18
|
path: "builtin"
|
|
@@ -14,19 +20,12 @@ initialize:
|
|
|
14
20
|
numerator: vcpus-allocated
|
|
15
21
|
denominator: 2
|
|
16
22
|
output: cpu/number-cores
|
|
17
|
-
boavizta-cpu:
|
|
18
|
-
method: BoaviztaCpuOutput
|
|
19
|
-
path: "@grnsft/if-unofficial-plugins"
|
|
20
|
-
global-config:
|
|
21
|
-
allocation: LINEAR
|
|
22
|
-
verbose: true
|
|
23
23
|
tree:
|
|
24
24
|
children:
|
|
25
25
|
child:
|
|
26
26
|
pipeline:
|
|
27
27
|
- cloud-metadata
|
|
28
28
|
- divide
|
|
29
|
-
- boavizta-cpu
|
|
30
29
|
config:
|
|
31
30
|
divide:
|
|
32
31
|
defaults:
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: exponent demo
|
|
2
|
+
description:
|
|
3
|
+
tags:
|
|
4
|
+
initialize:
|
|
5
|
+
# outputs:
|
|
6
|
+
# - yaml
|
|
7
|
+
plugins:
|
|
8
|
+
exponent:
|
|
9
|
+
method: Exponent
|
|
10
|
+
path: 'builtin'
|
|
11
|
+
global-config:
|
|
12
|
+
input-parameter: 'cpu/energy'
|
|
13
|
+
exponent: 2
|
|
14
|
+
output-parameter: 'energy'
|
|
15
|
+
tree:
|
|
16
|
+
children:
|
|
17
|
+
child:
|
|
18
|
+
pipeline:
|
|
19
|
+
- exponent
|
|
20
|
+
config:
|
|
21
|
+
exponent:
|
|
22
|
+
inputs:
|
|
23
|
+
- timestamp: 2023-08-06T00:00
|
|
24
|
+
duration: 3600
|
|
25
|
+
cpu/energy: 0.001
|
|
26
|
+
network/energy: 0.001
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: interpolation-demo
|
|
2
|
+
description: simple demo of interpolation plugin
|
|
3
|
+
tags:
|
|
4
|
+
initialize:
|
|
5
|
+
plugins:
|
|
6
|
+
interpolation:
|
|
7
|
+
method: Interpolation
|
|
8
|
+
path: "builtin"
|
|
9
|
+
global-config:
|
|
10
|
+
method: linear
|
|
11
|
+
x: [0, 10, 50, 100]
|
|
12
|
+
y: [0.12, 0.32, 0.75, 1.02]
|
|
13
|
+
input-parameter: "cpu/utilization"
|
|
14
|
+
output-parameter: "result"
|
|
15
|
+
|
|
16
|
+
tree:
|
|
17
|
+
children:
|
|
18
|
+
child:
|
|
19
|
+
pipeline:
|
|
20
|
+
- interpolation
|
|
21
|
+
inputs:
|
|
22
|
+
- timestamp: 2023-07-06T00:00
|
|
23
|
+
duration: 3600
|
|
24
|
+
cpu/utilization: 45
|
|
@@ -8,17 +8,13 @@ initialize:
|
|
|
8
8
|
kind: plugin
|
|
9
9
|
method: Sci
|
|
10
10
|
path: "builtin"
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
global-config:
|
|
12
|
+
functional-unit: requests
|
|
13
13
|
tree:
|
|
14
14
|
children:
|
|
15
15
|
child:
|
|
16
16
|
pipeline:
|
|
17
17
|
- sci
|
|
18
|
-
config:
|
|
19
|
-
sci:
|
|
20
|
-
functional-unit-time: 1 sec
|
|
21
|
-
functional-unit: requests # factor to convert per time to per f.unit
|
|
22
18
|
inputs:
|
|
23
19
|
- timestamp: 2023-07-06T00:00
|
|
24
20
|
duration: 3600
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: subtract demo
|
|
2
|
+
description:
|
|
3
|
+
tags:
|
|
4
|
+
initialize:
|
|
5
|
+
outputs:
|
|
6
|
+
- yaml
|
|
7
|
+
plugins:
|
|
8
|
+
subtract:
|
|
9
|
+
method: Subtract
|
|
10
|
+
path: 'builtin'
|
|
11
|
+
global-config:
|
|
12
|
+
input-parameters: ['cpu/energy', 'network/energy']
|
|
13
|
+
output-parameter: 'energy/diff'
|
|
14
|
+
tree:
|
|
15
|
+
children:
|
|
16
|
+
child:
|
|
17
|
+
pipeline:
|
|
18
|
+
- subtract
|
|
19
|
+
config:
|
|
20
|
+
subtract:
|
|
21
|
+
inputs:
|
|
22
|
+
- timestamp: 2023-08-06T00:00
|
|
23
|
+
duration: 3600
|
|
24
|
+
cpu/energy: 0.003
|
|
25
|
+
network/energy: 0.001
|
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grnsft/if",
|
|
3
3
|
"description": "Impact Framework",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0-beta.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Green Software Foundation",
|
|
7
7
|
"email": "info@gsf.com"
|
|
8
8
|
},
|
|
9
9
|
"bin": {
|
|
10
|
-
"
|
|
11
|
-
"if-
|
|
10
|
+
"if-diff": "./build/diff.js",
|
|
11
|
+
"if-run": "./build/index.js",
|
|
12
|
+
"if-env": "./build/env.js",
|
|
13
|
+
"if-check": "./build/check.js"
|
|
12
14
|
},
|
|
13
15
|
"bugs": {
|
|
14
16
|
"url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
|
|
@@ -16,6 +18,7 @@
|
|
|
16
18
|
"dependencies": {
|
|
17
19
|
"@commitlint/cli": "^18.6.0",
|
|
18
20
|
"@commitlint/config-conventional": "^18.6.0",
|
|
21
|
+
"@grnsft/if-core": "^0.0.10",
|
|
19
22
|
"axios": "^1.7.2",
|
|
20
23
|
"csv-parse": "^5.5.6",
|
|
21
24
|
"csv-stringify": "^6.4.6",
|
|
@@ -36,6 +39,7 @@
|
|
|
36
39
|
"@types/luxon": "^3.4.2",
|
|
37
40
|
"@types/node": "^20.8.9",
|
|
38
41
|
"axios-mock-adapter": "^1.22.0",
|
|
42
|
+
"cross-env": "7.0.3",
|
|
39
43
|
"fixpack": "^4.0.0",
|
|
40
44
|
"gts": "^5.0.0",
|
|
41
45
|
"husky": "^8.0.0",
|
|
@@ -72,8 +76,10 @@
|
|
|
72
76
|
"coverage": "jest --verbose --coverage --testPathPattern=src/__tests__/unit",
|
|
73
77
|
"fix": "gts fix",
|
|
74
78
|
"fix:package": "fixpack",
|
|
75
|
-
"
|
|
79
|
+
"if-check": "cross-env CURRENT_DIR=$(node -p \"process.env.INIT_CWD\") npx ts-node src/check.ts",
|
|
76
80
|
"if-diff": "npx ts-node src/diff.ts",
|
|
81
|
+
"if-env": "cross-env CURRENT_DIR=$(node -p \"process.env.INIT_CWD\") npx ts-node src/env.ts",
|
|
82
|
+
"if-run": "npx ts-node src/index.ts",
|
|
77
83
|
"lint": "gts lint",
|
|
78
84
|
"pre-commit": "lint-staged",
|
|
79
85
|
"prepare": "husky install",
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
name: template manifest
|
|
2
|
+
description: auto-generated template
|
|
3
|
+
tags: null
|
|
4
|
+
initialize:
|
|
5
|
+
plugins:
|
|
6
|
+
memory-energy-from-memory-util:
|
|
7
|
+
path: builtin
|
|
8
|
+
method: Coefficient
|
|
9
|
+
global-config:
|
|
10
|
+
input-parameter: memory/utilization
|
|
11
|
+
coefficient: 0.0001
|
|
12
|
+
output-parameter: memory/energy
|
|
13
|
+
outputs:
|
|
14
|
+
- yaml
|
|
15
|
+
execution:
|
|
16
|
+
command: >-
|
|
17
|
+
/Users/manushak/.npm/_npx/1bf7c3c15bf47d04/node_modules/.bin/ts-node
|
|
18
|
+
/Users/manushak/Documents/Projects/Green-Software/if/src/index.ts -m
|
|
19
|
+
./src/env-template.yml -o ./manifests/outputs/template
|
|
20
|
+
environment:
|
|
21
|
+
if-version: 0.4.0
|
|
22
|
+
os: macOS
|
|
23
|
+
os-version: 13.6.6
|
|
24
|
+
node-version: 20.12.2
|
|
25
|
+
date-time: 2024-06-18T08:39:55.771Z (UTC)
|
|
26
|
+
dependencies:
|
|
27
|
+
- "@babel/core@7.22.10"
|
|
28
|
+
- "@babel/preset-typescript@7.23.3"
|
|
29
|
+
- "@commitlint/cli@18.6.0"
|
|
30
|
+
- "@commitlint/config-conventional@18.6.0"
|
|
31
|
+
- "@grnsft/if-core@0.0.3"
|
|
32
|
+
- "@jest/globals@29.7.0"
|
|
33
|
+
- "@types/jest@29.5.8"
|
|
34
|
+
- "@types/js-yaml@4.0.9"
|
|
35
|
+
- "@types/luxon@3.4.2"
|
|
36
|
+
- "@types/node@20.9.0"
|
|
37
|
+
- axios-mock-adapter@1.22.0
|
|
38
|
+
- axios@1.7.2
|
|
39
|
+
- cross-env@7.0.3
|
|
40
|
+
- csv-parse@5.5.6
|
|
41
|
+
- csv-stringify@6.4.6
|
|
42
|
+
- fixpack@4.0.0
|
|
43
|
+
- gts@5.2.0
|
|
44
|
+
- husky@8.0.3
|
|
45
|
+
- jest@29.7.0
|
|
46
|
+
- js-yaml@4.1.0
|
|
47
|
+
- lint-staged@15.2.2
|
|
48
|
+
- luxon@3.4.4
|
|
49
|
+
- release-it@16.3.0
|
|
50
|
+
- rimraf@5.0.5
|
|
51
|
+
- ts-command-line-args@2.5.1
|
|
52
|
+
- ts-jest@29.1.1
|
|
53
|
+
- typescript-cubic-spline@1.0.1
|
|
54
|
+
- typescript@5.2.2
|
|
55
|
+
- winston@3.11.0
|
|
56
|
+
- zod@3.22.4
|
|
57
|
+
status: success
|
|
58
|
+
tree:
|
|
59
|
+
children:
|
|
60
|
+
child:
|
|
61
|
+
pipeline:
|
|
62
|
+
- memory-energy-from-memory-util
|
|
63
|
+
config: null
|
|
64
|
+
inputs:
|
|
65
|
+
- timestamp: 2023-12-12T00:00:00.000Z
|
|
66
|
+
duration: 3600
|
|
67
|
+
memory/utilization: 10
|
|
68
|
+
outputs:
|
|
69
|
+
- timestamp: 2023-12-12T00:00:00.000Z
|
|
70
|
+
duration: 3600
|
|
71
|
+
memory/utilization: 10
|
|
72
|
+
memory/energy: 0.001
|
package/src/builtins/README.md
CHANGED
|
@@ -305,7 +305,7 @@ Then, you must select the metric you want to export to CSV. The name of that met
|
|
|
305
305
|
For example, to export the `carbon` data from your tree to a CSV file:
|
|
306
306
|
|
|
307
307
|
```sh
|
|
308
|
-
|
|
308
|
+
if-run --manifest example.yml --output example#carbon
|
|
309
309
|
```
|
|
310
310
|
|
|
311
311
|
This will save a CSV file called `example.csv`. The contents will look similar to the following:
|
|
@@ -86,7 +86,25 @@ tree:
|
|
|
86
86
|
You can run this example by saving it as `./examples/manifests/coefficient.yml` and executing the following command from the project root:
|
|
87
87
|
|
|
88
88
|
```sh
|
|
89
|
-
|
|
89
|
+
if-run --manifest ./examples/manifests/coefficient.yml --output ./examples/outputs/coefficient.yml
|
|
90
90
|
```
|
|
91
91
|
|
|
92
92
|
The results will be saved to a new `yaml` file in `./examples/outputs`
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
## Errors
|
|
96
|
+
|
|
97
|
+
`Coefficient` exposes one of the IF error classes.
|
|
98
|
+
|
|
99
|
+
### GlobalConfigError
|
|
100
|
+
|
|
101
|
+
You will receive an error starting `GlobalConfigError: ` if you have not provided the expected configuration data in the plugin's `initialize` block.
|
|
102
|
+
|
|
103
|
+
The required parameters are:
|
|
104
|
+
- `input-parameter`: this must be a string
|
|
105
|
+
- `coefficient`: this must be a number
|
|
106
|
+
- `output-parameter`: this must be a string
|
|
107
|
+
|
|
108
|
+
You can fix this error by checking you are providing valid values for each parameter in the config.
|
|
109
|
+
|
|
110
|
+
For more information on our error classes, please visit [our docs](https://if.greensoftware.foundation/reference/errors
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Copy-param
|
|
2
|
+
|
|
3
|
+
`copy-param` is a generic plugin that duplicates an existing parameter in the `input` data and assigns it to a new key. You can either keep or delete the original copied parameter. A common use case for this is to rename parameters in the `inputs` array.
|
|
4
|
+
|
|
5
|
+
You provide the name of the value you want to copy, and a name to assign the copy to. You also toggle a `keep-existing` parameter to either persist or delete the original copied value.
|
|
6
|
+
|
|
7
|
+
For example, you could copy `energy` into `energy-copy`, with `keep-existing=true`. In this case your inputs:
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
- timestamp: "2023-12-12T00:00:13.000Z",
|
|
11
|
+
duration: 30,
|
|
12
|
+
energy: 30
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
would become
|
|
16
|
+
|
|
17
|
+
```yaml
|
|
18
|
+
- timestamp: "2023-12-12T00:00:13.000Z",
|
|
19
|
+
duration: 30,
|
|
20
|
+
energy: 30
|
|
21
|
+
energy-copy: 30
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
but with `keep-existing=false`, the same inputs would yield:
|
|
25
|
+
|
|
26
|
+
```yaml
|
|
27
|
+
- timestamp: "2023-12-12T00:00:13.000Z",
|
|
28
|
+
duration: 30,
|
|
29
|
+
energy-copy: 30
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Parameters
|
|
33
|
+
|
|
34
|
+
### Config
|
|
35
|
+
|
|
36
|
+
Three parameters are required in config: `from` and `to` and `keep-existing`.
|
|
37
|
+
|
|
38
|
+
`from`: an array of strings. Each string should match an existing key in the `inputs` array
|
|
39
|
+
`to`: a string defining the name to use to add the result of summing the input parameters to the output array.
|
|
40
|
+
`keep-existing`: toggles whether to keep or delete the copied parameter (defined in `to`)
|
|
41
|
+
|
|
42
|
+
### Inputs
|
|
43
|
+
|
|
44
|
+
As with all plugins, `timestamp` and `duration` are required. The key passed to `from` must exist in the `input` data.
|
|
45
|
+
|
|
46
|
+
## Returns
|
|
47
|
+
|
|
48
|
+
The plugin adds a new parameter with the name defined in `to` to the `input` data.
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
## Implementation
|
|
52
|
+
|
|
53
|
+
To run the plugin, you must first create an instance of `Copy`. Then, you can call `execute()`.
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { Copy } from ".";
|
|
57
|
+
|
|
58
|
+
const plugin = Copy({ 'keep-existing': true, from: 'from-param', to: 'to-param' });
|
|
59
|
+
|
|
60
|
+
const result = plugin.execute([{
|
|
61
|
+
timestamp: "2023-12-12T00:00:13.000Z",
|
|
62
|
+
duration: 30,
|
|
63
|
+
'from-param': 'hello',
|
|
64
|
+
}])
|
|
65
|
+
|
|
66
|
+
console.log(result)
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Example manifest
|
|
71
|
+
|
|
72
|
+
IF users will typically call the plugin as part of a pipeline defined in a manifest file. In this case, instantiating the plugin is handled by and does not have to be done explicitly by the user. The following is an example manifest that calls `copy-param`:
|
|
73
|
+
|
|
74
|
+
```yaml
|
|
75
|
+
name: copy-param
|
|
76
|
+
description:
|
|
77
|
+
tags:
|
|
78
|
+
initialize:
|
|
79
|
+
plugins:
|
|
80
|
+
copy-param:
|
|
81
|
+
path: builtin
|
|
82
|
+
method: Copy
|
|
83
|
+
global-config:
|
|
84
|
+
keep-existing: true
|
|
85
|
+
from: original
|
|
86
|
+
to: copy
|
|
87
|
+
tree:
|
|
88
|
+
children:
|
|
89
|
+
child-1:
|
|
90
|
+
pipeline:
|
|
91
|
+
- copy-param
|
|
92
|
+
inputs:
|
|
93
|
+
- timestamp: "2023-12-12T00:00:00.000Z"
|
|
94
|
+
original: 'hello'
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
You can run this example by saving it as `./manifests/examples/copy.yml` and executing the following command from the project root:
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
if-run --manifest ./manifests/examples/copy.yml -s
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The results will be displayed in the console.
|
|
@@ -136,7 +136,45 @@ You can run this example by saving it as `./examples/manifests/csv-lookup.yml` a
|
|
|
136
136
|
|
|
137
137
|
```sh
|
|
138
138
|
npm i -g @grnsft/if
|
|
139
|
-
|
|
139
|
+
if-run --manifest manifests/plugins/csv-lookup.yml --output manifests/outputs/csv-lookup
|
|
140
140
|
```
|
|
141
141
|
|
|
142
142
|
The results will be saved to a new `yaml` file in `manifests/outputs`.
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
## Errors
|
|
146
|
+
|
|
147
|
+
Coefficient exposes six of the IF error classes.
|
|
148
|
+
|
|
149
|
+
### FetchingFileError
|
|
150
|
+
|
|
151
|
+
This error is caused by problems finding the file at the path provided in the `filepath`. If the file is on your local filesystem, you can check that the file is definitely there. For a remote file, check your internet connection. You can check your connection to the server using a tool such as `ping` or `curl`. if you still experience problems, you could retrieve the remote file onto your local filesystem using a tool such as `wget`.
|
|
152
|
+
|
|
153
|
+
### ReadFileError,
|
|
154
|
+
|
|
155
|
+
This error is caused by problems reading the CSV file provided in the `filepath`. To fix it, check that the file contains valid CSV data. The file should have a `.csv` file extension and the data inside should be formatted correctly.
|
|
156
|
+
|
|
157
|
+
### MissingCSVColumnError,
|
|
158
|
+
|
|
159
|
+
This error is caused by `CsvLookup` failing to find a column in the CSV file whose name matches what was provided in `query`. To debug, check that you do not have any typos in your `query` and confirm that the requested column name definitely exists in the target file.
|
|
160
|
+
|
|
161
|
+
### QueryDataNotFoundError,
|
|
162
|
+
|
|
163
|
+
This error is caused by the `CsvLookup` plugin failing to find data that matches your query. Try revising your query parameters.
|
|
164
|
+
|
|
165
|
+
### CSVParseError,
|
|
166
|
+
|
|
167
|
+
This error arises due to problems parsing CSV data into IF. This can occur when the CSV data is incorrectly formatted or contains unexpected characters that IF does not recognize. These errors are expected to be unusual edge cases as incorrectly formatted data will usually be identified during file loading and cause a `ReadFileError`. To debug, check your CSV file for any unexpected formatting or unusual characters.
|
|
168
|
+
|
|
169
|
+
### GlobalConfigError
|
|
170
|
+
|
|
171
|
+
You will receive an error starting `GlobalConfigError: ` if you have not provided the expected configuration data in the plugin's `initialize` block.
|
|
172
|
+
|
|
173
|
+
The required parameters are:
|
|
174
|
+
- `filepath`: This must be a path to a csv file
|
|
175
|
+
- `query`: this must be an array of key-value pairs where the key is a string containing a column name an the value is a string containing the name of a value in `inputs`
|
|
176
|
+
- `output`: this must be a string containing a name or a wildcard character (`"*"`)
|
|
177
|
+
|
|
178
|
+
You can fix this error by checking you are providing valid values for each parameter in the config.
|
|
179
|
+
|
|
180
|
+
For more information on our error classes, please visit [our docs](https://if.greensoftware.foundation/reference/errors
|
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
You provide the names of the values you want to divide, and a name to use to add the divide to the output array.
|
|
6
6
|
|
|
7
|
-
For example, `boavizta-cpu` need `cpu/number-cores` to work, however `cloud-metadata` returns `vcpus-allocated`, to get number of cores you divide `vcpus-allocated` by 2.
|
|
8
|
-
|
|
9
7
|
## Parameters
|
|
10
8
|
|
|
11
9
|
### Plugin config
|
|
@@ -26,6 +24,8 @@ For example, `boavizta-cpu` need `cpu/number-cores` to work, however `cloud-meta
|
|
|
26
24
|
|
|
27
25
|
The plugin throws an exception if the division result is not a number.
|
|
28
26
|
|
|
27
|
+
>Note: Plugin will warn and return `numerator` value in case if `denominator` is zero.
|
|
28
|
+
|
|
29
29
|
## Calculation
|
|
30
30
|
|
|
31
31
|
```pseudocode
|
|
@@ -89,7 +89,33 @@ You can run this example by saving it as `./examples/manifests/divide.yml` and e
|
|
|
89
89
|
|
|
90
90
|
```sh
|
|
91
91
|
npm i -g @grnsft/if
|
|
92
|
-
|
|
92
|
+
if-run --manifest ./examples/manifests/divide.yml --output ./examples/outputs/divide.yml
|
|
93
93
|
```
|
|
94
94
|
|
|
95
95
|
The results will be saved to a new `yaml` file in `./examples/outputs`.
|
|
96
|
+
|
|
97
|
+
## Errors
|
|
98
|
+
|
|
99
|
+
`Divide` exposes two of IF's error classes.
|
|
100
|
+
|
|
101
|
+
### GlobalConfigError
|
|
102
|
+
|
|
103
|
+
You will receive an error starting `GlobalConfigError: ` if you have not provided the expected configuration data in the plugin's `initialize` block.
|
|
104
|
+
|
|
105
|
+
The required parameters are:
|
|
106
|
+
- `numerator`: a string containing the name of the input parameter whose value should be divided by `denominator`
|
|
107
|
+
- `denominator`: a number to use as the denominator
|
|
108
|
+
- ``output`: a string containing the name to assign the result of the division
|
|
109
|
+
|
|
110
|
+
You can fix this error by checking you are providing valid values for each parameter in the config.
|
|
111
|
+
|
|
112
|
+
### `MissingInputDataError`
|
|
113
|
+
|
|
114
|
+
This error arises when a necessary piece of input data is missing from the `inputs` array.
|
|
115
|
+
Every element in the ``inputs` array must contain:
|
|
116
|
+
- `timestamp`
|
|
117
|
+
- `duration`
|
|
118
|
+
- whatever value you passed to `numerator`
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
For more information on our error classes, please visit [our docs](https://if.greensoftware.foundation/reference/errors
|
|
@@ -91,7 +91,27 @@ You can run this example by saving it as `manifests/examples/test/exponent.yml`
|
|
|
91
91
|
|
|
92
92
|
```sh
|
|
93
93
|
npm i -g @grnsft/if
|
|
94
|
-
|
|
94
|
+
if-run --manifest manifests/examples/test/exponent.yml --output manifests/outputs/exponent.yml
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
The results will be saved to a new `yaml` file in `manifests/outputs`.
|
|
98
|
+
|
|
99
|
+
## Errors
|
|
100
|
+
|
|
101
|
+
`Exponent` exposes two of IF's error classes.
|
|
102
|
+
|
|
103
|
+
### `MissingInputDataError`
|
|
104
|
+
|
|
105
|
+
This error arises when a necessary piece of input data is missing from the `inputs` array.
|
|
106
|
+
Every element in the `inputs` array must contain:
|
|
107
|
+
|
|
108
|
+
- `timestamp`
|
|
109
|
+
- `duration`
|
|
110
|
+
- whatever value you passed to `input-parameter`
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
### `InputValidationError`
|
|
114
|
+
|
|
115
|
+
This error arises when an invalid value is passed to `Exponent`. Typically, this can occur when a non-numeric value (such as a string made of alphabetic characters) is passed where a number or numeric string is expected. Please check that the types are correct for all the relevant fields in your `inputs` array.
|
|
116
|
+
|
|
117
|
+
For more information on our error classes, please visit [our docs](https://if.greensoftware.foundation/reference/errors
|