@grnsft/if 0.3.4 → 0.4.0-beta.1

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.
Files changed (259) hide show
  1. package/.commitlintrc.js +0 -1
  2. package/.lintstagedrc.js +6 -0
  3. package/README.md +12 -8
  4. package/Refactor-migration-guide.md +6 -6
  5. package/build/builtins/coefficient/index.d.ts +3 -0
  6. package/build/builtins/coefficient/index.js +51 -0
  7. package/build/builtins/coefficient/types.d.ts +5 -0
  8. package/build/builtins/coefficient/types.js +3 -0
  9. package/build/builtins/csv-lookup/index.d.ts +2 -0
  10. package/build/builtins/csv-lookup/index.js +181 -0
  11. package/build/builtins/divide/index.d.ts +2 -0
  12. package/build/builtins/divide/index.js +67 -0
  13. package/build/builtins/exponent/index.d.ts +3 -0
  14. package/build/builtins/exponent/index.js +72 -0
  15. package/build/builtins/exponent/types.d.ts +5 -0
  16. package/build/builtins/exponent/types.js +3 -0
  17. package/build/builtins/export-csv-raw.js +4 -1
  18. package/build/builtins/export-csv.js +4 -1
  19. package/build/builtins/export-log.js +4 -2
  20. package/build/builtins/export-yaml.js +4 -1
  21. package/build/builtins/index.d.ts +13 -0
  22. package/build/builtins/index.js +28 -2
  23. package/build/builtins/interpolation/index.d.ts +2 -0
  24. package/build/builtins/interpolation/index.js +146 -0
  25. package/build/builtins/interpolation/types.d.ts +5 -0
  26. package/build/builtins/interpolation/types.js +10 -0
  27. package/build/builtins/mock-observations/helpers/common-generator.d.ts +3 -0
  28. package/build/builtins/mock-observations/helpers/common-generator.js +32 -0
  29. package/build/builtins/mock-observations/helpers/rand-int-generator.d.ts +3 -0
  30. package/build/builtins/mock-observations/helpers/rand-int-generator.js +58 -0
  31. package/build/builtins/mock-observations/index.d.ts +3 -0
  32. package/build/builtins/mock-observations/index.js +116 -0
  33. package/build/builtins/mock-observations/interfaces/index.d.ts +6 -0
  34. package/build/builtins/mock-observations/interfaces/index.js +3 -0
  35. package/build/builtins/mock-observations/types.d.ts +13 -0
  36. package/build/builtins/mock-observations/types.js +3 -0
  37. package/build/builtins/multiply/index.d.ts +3 -0
  38. package/build/builtins/multiply/index.js +63 -0
  39. package/build/builtins/multiply/types.d.ts +4 -0
  40. package/build/builtins/multiply/types.js +3 -0
  41. package/build/builtins/regex/index.d.ts +3 -0
  42. package/build/builtins/regex/index.js +78 -0
  43. package/build/builtins/sci/config.d.ts +1 -0
  44. package/build/builtins/sci/config.js +44 -0
  45. package/build/builtins/sci/index.d.ts +3 -0
  46. package/build/builtins/sci/index.js +69 -0
  47. package/build/builtins/sci-embodied/index.d.ts +2 -0
  48. package/build/builtins/sci-embodied/index.js +115 -0
  49. package/build/builtins/shell/index.d.ts +3 -0
  50. package/build/builtins/shell/index.js +58 -0
  51. package/build/builtins/subtract/index.d.ts +3 -0
  52. package/build/builtins/subtract/index.js +75 -0
  53. package/build/builtins/subtract/types.d.ts +4 -0
  54. package/build/builtins/subtract/types.js +3 -0
  55. package/build/builtins/sum/index.d.ts +3 -0
  56. package/build/builtins/sum/index.js +61 -0
  57. package/build/builtins/sum/types.d.ts +4 -0
  58. package/build/builtins/sum/types.js +3 -0
  59. package/build/config/config.d.ts +8 -2
  60. package/build/config/config.js +34 -1
  61. package/build/config/strings.d.ts +22 -0
  62. package/build/config/strings.js +23 -1
  63. package/build/diff.d.ts +2 -0
  64. package/build/diff.js +41 -0
  65. package/build/index.js +8 -4
  66. package/build/lib/aggregate.js +5 -1
  67. package/build/lib/compare.d.ts +10 -0
  68. package/build/lib/compare.js +56 -0
  69. package/build/lib/compute.js +9 -1
  70. package/build/lib/environment.js +9 -3
  71. package/build/lib/exhaust.js +3 -2
  72. package/build/lib/initialize.js +5 -2
  73. package/build/lib/load.d.ts +48 -0
  74. package/build/lib/load.js +51 -2
  75. package/build/lib/parameterize.js +8 -4
  76. package/build/types/common.d.ts +4 -0
  77. package/build/types/common.js +3 -0
  78. package/build/types/helpers.d.ts +4 -0
  79. package/build/types/helpers.js +3 -0
  80. package/build/types/interface.d.ts +2 -1
  81. package/build/types/interface.js +1 -1
  82. package/build/types/lib/compare.d.ts +7 -0
  83. package/build/types/lib/compare.js +3 -0
  84. package/build/types/process-args.d.ts +7 -1
  85. package/build/types/process-args.js +1 -1
  86. package/build/types/util/args.d.ts +4 -0
  87. package/build/types/util/args.js +3 -0
  88. package/build/util/args.d.ts +7 -2
  89. package/build/util/args.js +49 -11
  90. package/build/util/debug-logger.d.ts +4 -0
  91. package/build/util/debug-logger.js +117 -0
  92. package/build/util/errors.d.ts +1 -1
  93. package/build/util/errors.js +6 -1
  94. package/build/util/helpers.d.ts +23 -0
  95. package/build/util/helpers.js +116 -2
  96. package/build/util/log-memoize.d.ts +1 -1
  97. package/build/util/log-memoize.js +1 -1
  98. package/build/util/validations.d.ts +59 -51
  99. package/build/util/validations.js +49 -18
  100. package/github-processes.md +16 -42
  101. package/manifests/bugs/aggregation-error-wrong-metric.yml +6 -6
  102. package/manifests/bugs/azure-importer-ignoring-defaults.yml +3 -3
  103. package/manifests/bugs/azure-importer-incorrect-calculation.yml +2 -2
  104. package/manifests/bugs/mock-observations-failure-duration-is-zero.yml +34 -0
  105. package/manifests/bugs/pipeline-error-uninitialized-plugin.yml +1 -1
  106. package/manifests/bugs/pipeline-ordering-error.yml +6 -6
  107. package/manifests/bugs/sci-embodied-missing-resources-total.yml +23 -0
  108. package/manifests/examples/generics.yml +3 -3
  109. package/manifests/examples/instance-metadata.yml +36 -0
  110. package/manifests/examples/mock-cpu-util-to-carbon.yml +3 -3
  111. package/manifests/examples/nesting.yml +37 -10
  112. package/manifests/examples/pipeline-teads-sci.yml +17 -9
  113. package/manifests/examples/pipeline-with-aggregate.yml +24 -9
  114. package/manifests/examples/pipeline-with-mocks.yml +26 -9
  115. package/manifests/examples/sci.yml +131 -0
  116. package/manifests/examples/teads-curve.yml +78 -0
  117. package/manifests/features/aggregate-failure-inalid-metrics.yml +43 -0
  118. package/manifests/features/aggregate-failure-missing-metric-in-inputs.yml +43 -0
  119. package/manifests/integrations/cloud-metadata-divide-boavizta.yml +1 -1
  120. package/manifests/integrations/mock-obs-group-by-cloud-meta.yml +51 -0
  121. package/manifests/integrations/mock-obs-groupby.yml +2 -2
  122. package/manifests/integrations/mock-obs-time-sync.yml +1 -1
  123. package/manifests/plugins/cloud-metadata/failure-invalid-instance-type.yaml +21 -0
  124. package/manifests/plugins/cloud-metadata/failure-invalid-vendor.yaml +1 -1
  125. package/manifests/plugins/cloud-metadata/failure-missing-cloud-vendor.yml +21 -0
  126. package/manifests/plugins/cloud-metadata/success.yml +1 -1
  127. package/manifests/plugins/coefficient/failure-invalid-config-input-param.yml +1 -1
  128. package/manifests/plugins/coefficient/failure-output-param-is-null.yaml +24 -0
  129. package/manifests/plugins/coefficient/success.yml +1 -1
  130. package/manifests/plugins/csv-lookup/failure-missing-column.yml +26 -0
  131. package/manifests/plugins/csv-lookup/failure-missing-output.yml +26 -0
  132. package/manifests/plugins/csv-lookup/success-renaming.yml +26 -0
  133. package/manifests/plugins/csv-lookup/success.yml +26 -0
  134. package/manifests/plugins/divide/failure-denominator-equal-zero.yml +39 -0
  135. package/manifests/plugins/divide/failure-invalid-config-denominator.yml +1 -1
  136. package/manifests/plugins/divide/failure-missing-numerator.yml +39 -0
  137. package/manifests/plugins/divide/success.yml +2 -2
  138. package/manifests/plugins/groupby/failure-missing-cloud-instance-type.yml +49 -0
  139. package/manifests/plugins/interpolation/interpolation.yml +24 -0
  140. package/manifests/plugins/mock-observations/failure-invalid-config-cpu-range.yml +1 -1
  141. package/manifests/plugins/mock-observations/failure-invalid-memory-utilization-range.yml +34 -0
  142. package/manifests/plugins/mock-observations/failure-missing-timestamp-from-param.yml +34 -0
  143. package/manifests/plugins/mock-observations/success.yml +2 -2
  144. package/manifests/plugins/multiply/failure-input-parameter-is-missing.yml +1 -1
  145. package/manifests/plugins/multiply/success-with-multiple-inputs.yml +32 -0
  146. package/manifests/plugins/multiply/success.yml +3 -3
  147. package/manifests/plugins/regex/failure-missing-input-param.yml +1 -1
  148. package/manifests/plugins/regex/failure-not-matching-with-regex.yml +24 -0
  149. package/manifests/plugins/regex/success.yml +2 -2
  150. package/manifests/plugins/sci/failure-invalid-config-value.yml +2 -3
  151. package/manifests/plugins/sci/failure-missing-input-param.yml +27 -0
  152. package/manifests/plugins/sci/success.yml +5 -4
  153. package/manifests/plugins/{sci-m → sci-embodied}/failure-invalid-default-emission-value.yml +5 -6
  154. package/manifests/plugins/sci-embodied/failure-missing-expected-lifespan.yml +23 -0
  155. package/manifests/plugins/{sci-m → sci-embodied}/success.yml +5 -6
  156. package/manifests/plugins/shell/failure-invalid-command.yml +1 -1
  157. package/manifests/plugins/shell/success.yml +1 -2
  158. package/manifests/plugins/sum/failure-missing-input-param.yml +1 -1
  159. package/manifests/plugins/sum/failure-missing-output-param.yml +28 -0
  160. package/manifests/plugins/sum/success.yml +1 -1
  161. package/manifests/plugins/tdp-finder/failure-unsupported-physical-processor.yml +19 -0
  162. package/manifests/plugins/time-sync/failure-missing-global-config.yml +34 -0
  163. package/package.json +10 -2
  164. package/src/builtins/README.md +5 -5
  165. package/src/builtins/coefficient/README.md +92 -0
  166. package/src/builtins/csv-lookup/README.md +142 -0
  167. package/src/builtins/divide/README.md +95 -0
  168. package/src/builtins/exponent/README.md +97 -0
  169. package/src/builtins/interpolation/README.md +168 -0
  170. package/src/builtins/mock-observations/README.md +97 -0
  171. package/src/builtins/multiply/README.md +94 -0
  172. package/src/builtins/regex/README.md +91 -0
  173. package/src/builtins/sci/README.md +89 -0
  174. package/src/builtins/sci-embodied/README.md +110 -0
  175. package/src/builtins/shell/README.md +130 -0
  176. package/src/builtins/subtract/README.md +94 -0
  177. package/src/builtins/sum/README.md +91 -0
  178. package/.env +0 -5
  179. package/coverage/clover.xml +0 -1590
  180. package/coverage/coverage-final.json +0 -50
  181. package/coverage/lcov-report/base.css +0 -224
  182. package/coverage/lcov-report/block-navigation.js +0 -87
  183. package/coverage/lcov-report/builtins/coefficient/index.html +0 -116
  184. package/coverage/lcov-report/builtins/coefficient/index.ts.html +0 -295
  185. package/coverage/lcov-report/builtins/csv-lookup/index.html +0 -116
  186. package/coverage/lcov-report/builtins/csv-lookup/index.ts.html +0 -832
  187. package/coverage/lcov-report/builtins/divide/index.html +0 -116
  188. package/coverage/lcov-report/builtins/divide/index.ts.html +0 -361
  189. package/coverage/lcov-report/builtins/exponent/index.html +0 -116
  190. package/coverage/lcov-report/builtins/exponent/index.ts.html +0 -355
  191. package/coverage/lcov-report/builtins/export-csv-raw.ts.html +0 -553
  192. package/coverage/lcov-report/builtins/export-csv.ts.html +0 -433
  193. package/coverage/lcov-report/builtins/export-log.ts.html +0 -145
  194. package/coverage/lcov-report/builtins/export-yaml.ts.html +0 -184
  195. package/coverage/lcov-report/builtins/group-by.ts.html +0 -364
  196. package/coverage/lcov-report/builtins/index.html +0 -206
  197. package/coverage/lcov-report/builtins/index.ts.html +0 -130
  198. package/coverage/lcov-report/builtins/interpolation/index.html +0 -131
  199. package/coverage/lcov-report/builtins/interpolation/index.ts.html +0 -670
  200. package/coverage/lcov-report/builtins/interpolation/types.ts.html +0 -100
  201. package/coverage/lcov-report/builtins/mock-observations/helpers/common-generator.ts.html +0 -181
  202. package/coverage/lcov-report/builtins/mock-observations/helpers/index.html +0 -131
  203. package/coverage/lcov-report/builtins/mock-observations/helpers/rand-int-generator.ts.html +0 -295
  204. package/coverage/lcov-report/builtins/mock-observations/index.html +0 -116
  205. package/coverage/lcov-report/builtins/mock-observations/index.ts.html +0 -613
  206. package/coverage/lcov-report/builtins/multiply/index.html +0 -116
  207. package/coverage/lcov-report/builtins/multiply/index.ts.html +0 -337
  208. package/coverage/lcov-report/builtins/regex/index.html +0 -116
  209. package/coverage/lcov-report/builtins/regex/index.ts.html +0 -379
  210. package/coverage/lcov-report/builtins/sci/config.ts.html +0 -205
  211. package/coverage/lcov-report/builtins/sci/index.html +0 -116
  212. package/coverage/lcov-report/builtins/sci/index.ts.html +0 -331
  213. package/coverage/lcov-report/builtins/sci-embodied/index.html +0 -116
  214. package/coverage/lcov-report/builtins/sci-embodied/index.ts.html +0 -481
  215. package/coverage/lcov-report/builtins/shell/index.html +0 -116
  216. package/coverage/lcov-report/builtins/shell/index.ts.html +0 -283
  217. package/coverage/lcov-report/builtins/subtract/index.html +0 -116
  218. package/coverage/lcov-report/builtins/subtract/index.ts.html +0 -373
  219. package/coverage/lcov-report/builtins/sum/index.html +0 -116
  220. package/coverage/lcov-report/builtins/sum/index.ts.html +0 -340
  221. package/coverage/lcov-report/builtins/time-sync.ts.html +0 -1459
  222. package/coverage/lcov-report/config/config.ts.html +0 -334
  223. package/coverage/lcov-report/config/index.html +0 -161
  224. package/coverage/lcov-report/config/index.ts.html +0 -94
  225. package/coverage/lcov-report/config/params.ts.html +0 -697
  226. package/coverage/lcov-report/config/strings.ts.html +0 -415
  227. package/coverage/lcov-report/favicon.png +0 -0
  228. package/coverage/lcov-report/index.html +0 -386
  229. package/coverage/lcov-report/lib/aggregate.ts.html +0 -331
  230. package/coverage/lcov-report/lib/compare.ts.html +0 -283
  231. package/coverage/lcov-report/lib/compute.ts.html +0 -391
  232. package/coverage/lcov-report/lib/environment.ts.html +0 -343
  233. package/coverage/lcov-report/lib/exhaust.ts.html +0 -283
  234. package/coverage/lcov-report/lib/index.html +0 -221
  235. package/coverage/lcov-report/lib/initialize.ts.html +0 -388
  236. package/coverage/lcov-report/lib/load.ts.html +0 -268
  237. package/coverage/lcov-report/lib/parameterize.ts.html +0 -283
  238. package/coverage/lcov-report/prettify.css +0 -1
  239. package/coverage/lcov-report/prettify.js +0 -2
  240. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  241. package/coverage/lcov-report/sorter.js +0 -196
  242. package/coverage/lcov-report/types/aggregation.ts.html +0 -94
  243. package/coverage/lcov-report/types/index.html +0 -146
  244. package/coverage/lcov-report/types/interface.ts.html +0 -181
  245. package/coverage/lcov-report/types/parameters.ts.html +0 -106
  246. package/coverage/lcov-report/util/aggregation-helper.ts.html +0 -286
  247. package/coverage/lcov-report/util/args.ts.html +0 -508
  248. package/coverage/lcov-report/util/errors.ts.html +0 -232
  249. package/coverage/lcov-report/util/helpers.ts.html +0 -613
  250. package/coverage/lcov-report/util/index.html +0 -266
  251. package/coverage/lcov-report/util/json.ts.html +0 -115
  252. package/coverage/lcov-report/util/log-memoize.ts.html +0 -145
  253. package/coverage/lcov-report/util/logger.ts.html +0 -151
  254. package/coverage/lcov-report/util/os-checker.ts.html +0 -421
  255. package/coverage/lcov-report/util/plugin-storage.ts.html +0 -199
  256. package/coverage/lcov-report/util/validations.ts.html +0 -526
  257. package/coverage/lcov-report/util/yaml.ts.html +0 -193
  258. package/coverage/lcov.info +0 -2811
  259. package/src/__tests__/integration/manifest/sci-e.yaml +0 -23
@@ -0,0 +1,34 @@
1
+ name: mock-observation-demo
2
+ description: a manifest demonstrating how to use the mock observations feature
3
+ tags:
4
+ initialize:
5
+ # outputs: ['yaml']
6
+ plugins:
7
+ mock-observations:
8
+ kind: plugin
9
+ method: MockObservations
10
+ path: "builtin"
11
+ global-config:
12
+ timestamp-from: 2023-07-06T00:00
13
+ timestamp-to: 2023-07-06T00:10
14
+ duration: 60
15
+ components:
16
+ - cloud/instance-type: A1
17
+ - cloud/instance-type: B1
18
+ generators:
19
+ common:
20
+ region: uk-west
21
+ common-key: common-val
22
+ randint:
23
+ cpu/utilization:
24
+ min: 1
25
+ max: 99
26
+ memory/utilization:
27
+ min: 99
28
+ max: 10
29
+ tree:
30
+ children:
31
+ child:
32
+ pipeline:
33
+ - mock-observations
34
+ inputs:
@@ -0,0 +1,34 @@
1
+ name: mock-observation-demo
2
+ description: a manifest demonstrating how to use the mock observations feature
3
+ tags:
4
+ initialize:
5
+ outputs: ['yaml']
6
+ plugins:
7
+ mock-observations:
8
+ kind: plugin
9
+ method: MockObservations
10
+ path: "builtin"
11
+ global-config:
12
+ #timestamp-from: 2023-07-06T00:00
13
+ timestamp-to: 2023-07-06T00:10
14
+ duration: 60
15
+ components:
16
+ - cloud/instance-type: A1
17
+ - cloud/instance-type: B1
18
+ generators:
19
+ common:
20
+ region: uk-west
21
+ common-key: common-val
22
+ randint:
23
+ cpu/utilization:
24
+ min: 1
25
+ max: 99
26
+ memory/utilization:
27
+ min: 1
28
+ max: 99
29
+ tree:
30
+ children:
31
+ child:
32
+ pipeline:
33
+ - mock-observations
34
+ inputs:
@@ -2,12 +2,12 @@ name: mock-observation-demo
2
2
  description: a manifest demonstrating how to use the mock observations feature
3
3
  tags:
4
4
  initialize:
5
- outputs: ['yaml']
5
+ # outputs: ['yaml']
6
6
  plugins:
7
7
  mock-observations:
8
8
  kind: plugin
9
9
  method: MockObservations
10
- path: "@grnsft/if-plugins"
10
+ path: "builtin"
11
11
  global-config:
12
12
  timestamp-from: 2023-07-06T00:00
13
13
  timestamp-to: 2023-07-06T00:10
@@ -6,7 +6,7 @@ initialize:
6
6
  plugins:
7
7
  multiply:
8
8
  method: Multiply
9
- path: "@grnsft/if-plugins"
9
+ path: "builtin"
10
10
  global-config:
11
11
  input-parameters: ["cpu/energy", "network/energy"]
12
12
  output-parameter: "energy-product"
@@ -0,0 +1,32 @@
1
+ name: multiply
2
+ description: a manifest demonstrating how to use the multiply feature
3
+ tags:
4
+ initialize:
5
+ outputs: ['yaml']
6
+ plugins:
7
+ multiply:
8
+ method: Multiply
9
+ path: "builtin"
10
+ global-config:
11
+ input-parameters: ["cpu/energy", "network/energy"]
12
+ output-parameter: "energy-product"
13
+ tree:
14
+ children:
15
+ child:
16
+ pipeline:
17
+ - multiply
18
+ config:
19
+ sum:
20
+ inputs:
21
+ - timestamp: 2023-08-06T00:00
22
+ duration: 3600
23
+ cpu/energy: 0.001
24
+ network/energy: 0.002
25
+ - timestamp: 2023-08-06T10:00
26
+ duration: 3600
27
+ cpu/energy: 0.005
28
+ network/energy: -0.002
29
+ - timestamp: 2023-08-06T10:00
30
+ duration: 3600
31
+ cpu/energy: 0.005
32
+ network/energy: 0
@@ -2,11 +2,11 @@ name: multiply
2
2
  description: a manifest demonstrating how to use the multiply feature
3
3
  tags:
4
4
  initialize:
5
- outputs: ['yaml']
5
+ # outputs: ['yaml']
6
6
  plugins:
7
7
  multiply:
8
8
  method: Multiply
9
- path: "@grnsft/if-plugins"
9
+ path: builtin
10
10
  global-config:
11
11
  input-parameters: ["cpu/energy", "network/energy"]
12
12
  output-parameter: "energy-product"
@@ -16,7 +16,7 @@ tree:
16
16
  pipeline:
17
17
  - multiply
18
18
  config:
19
- sum:
19
+ sum:
20
20
  inputs:
21
21
  - timestamp: 2023-08-06T00:00
22
22
  duration: 3600
@@ -6,7 +6,7 @@ initialize:
6
6
  plugins:
7
7
  regex:
8
8
  method: Regex
9
- path: "@grnsft/if-plugins"
9
+ path: "builtin"
10
10
  global-config:
11
11
  parameter: physical-processor
12
12
  match: ^(.*),
@@ -0,0 +1,24 @@
1
+ name: regex
2
+ description: physical processor doesn't match the regex expression
3
+ tags:
4
+ initialize:
5
+ # outputs: ['yaml']
6
+ plugins:
7
+ regex:
8
+ method: Regex
9
+ path: "builtin"
10
+ global-config:
11
+ parameter: physical-processor
12
+ match: ^
13
+ output: cpu/name
14
+ tree:
15
+ children:
16
+ child:
17
+ pipeline:
18
+ - regex
19
+ config:
20
+ regex:
21
+ inputs:
22
+ - timestamp: 2023-08-06T00:00
23
+ duration: 3600
24
+ physical-processor: Intel® Xeon® Platinum 8272CL,Intel® Xeon® 8171M 2.1 GHz,Intel® Xeon® E5-2673 v4 2.3 GHz,Intel® Xeon® E5-2673 v3 2.4 GHz
@@ -2,11 +2,11 @@ name: regex
2
2
  description: successful path
3
3
  tags:
4
4
  initialize:
5
- outputs: ['yaml']
5
+ # outputs: ['yaml']
6
6
  plugins:
7
7
  regex:
8
8
  method: Regex
9
- path: "@grnsft/if-plugins"
9
+ path: "builtin"
10
10
  global-config:
11
11
  parameter: physical-processor
12
12
  match: ^(.*),
@@ -7,9 +7,9 @@ initialize:
7
7
  sci:
8
8
  kind: plugin
9
9
  method: Sci
10
- path: "@grnsft/if-plugins"
10
+ path: "builtin"
11
11
  # global-config:
12
- # functional-unit-time: 1 minute
12
+ # functional-unit: 1 minute
13
13
  tree:
14
14
  children:
15
15
  child:
@@ -17,7 +17,6 @@ tree:
17
17
  - sci
18
18
  config:
19
19
  sci:
20
- functional-unit-time: 1 sec
21
20
  functional-unit: 999 # factor to convert per time to per f.unit
22
21
  inputs:
23
22
  - timestamp: 2023-07-06T00:00
@@ -0,0 +1,27 @@
1
+ name: sci
2
+ description: missing input value (carbon-embodied)
3
+ tags:
4
+ initialize:
5
+ #outputs: ['yaml']
6
+ plugins:
7
+ sci:
8
+ kind: plugin
9
+ method: Sci
10
+ path: "builtin"
11
+ # global-config:
12
+ # functional-unit: requests
13
+ tree:
14
+ children:
15
+ child:
16
+ pipeline:
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
+ inputs:
23
+ - timestamp: 2023-07-06T00:00
24
+ duration: 3600
25
+ energy: 5
26
+ carbon-operational: 5
27
+ requests: 100
@@ -2,14 +2,14 @@ name: sci
2
2
  description: successful path
3
3
  tags:
4
4
  initialize:
5
- outputs: ['yaml']
5
+ # outputs: ['yaml']
6
6
  plugins:
7
7
  sci:
8
8
  kind: plugin
9
9
  method: Sci
10
- path: "@grnsft/if-plugins"
11
- # global-config:
12
- # functional-unit-time: 1 minute
10
+ path: "builtin"
11
+ global-config:
12
+ functional-unit: requests
13
13
  tree:
14
14
  children:
15
15
  child:
@@ -25,4 +25,5 @@ tree:
25
25
  energy: 5
26
26
  carbon-operational: 5
27
27
  carbon-embodied: 0.02
28
+ carbon: 5.02
28
29
  requests: 100
@@ -1,18 +1,17 @@
1
- name: sci-m
1
+ name: sci-embodied
2
2
  description: failure with `defaults.device/emissions-embodied` being string instead of number
3
3
  tags:
4
4
  initialize:
5
5
  outputs: ['yaml']
6
6
  plugins:
7
- "sci-m": # a model that calculates m from te, tir, el, rr and rtor
8
- method: SciM
9
- verbose: false
10
- path: "@grnsft/if-plugins"
7
+ "sci-embodied": # a model that calculates m from te, tir, el, rr and rtor
8
+ method: SciEmbodied
9
+ path: "builtin"
11
10
  tree:
12
11
  children:
13
12
  child:
14
13
  pipeline:
15
- - sci-m # duration & config -> embodied
14
+ - sci-embodied # duration & config -> embodied
16
15
  defaults:
17
16
  device/emissions-embodied: 'fail' # gCO2eq
18
17
  time-reserved: 3600 # 1hr in seconds
@@ -0,0 +1,23 @@
1
+ name: sci-embodied
2
+ description: missing device/expected-lifespan
3
+ tags:
4
+ initialize:
5
+ #outputs: ['yaml']
6
+ plugins:
7
+ "sci-embodied": # a model that calculates m from te, tir, el, rr and rtor
8
+ method: SciEmbodied
9
+ path: "builtin"
10
+ tree:
11
+ children:
12
+ child:
13
+ pipeline:
14
+ - sci-embodied # duration & config -> embodied
15
+ defaults:
16
+ device/emissions-embodied: 1533.120 # gCO2eq
17
+ time-reserved: 3600 # 1hr in seconds
18
+ #device/expected-lifespan: 94608000 # 3 years in seconds
19
+ resources-reserved: 1
20
+ resources-total: 8
21
+ inputs:
22
+ - timestamp: 2023-07-06T00:00
23
+ duration: 3600
@@ -1,18 +1,17 @@
1
- name: sci-m
1
+ name: sci-embodied
2
2
  description: successful path
3
3
  tags:
4
4
  initialize:
5
5
  outputs: ['yaml']
6
6
  plugins:
7
- "sci-m": # a model that calculates m from te, tir, el, rr and rtor
8
- method: SciM
9
- verbose: false
10
- path: "@grnsft/if-plugins"
7
+ "sci-embodied": # a model that calculates m from te, tir, el, rr and rtor
8
+ method: SciEmbodied
9
+ path: "builtin"
11
10
  tree:
12
11
  children:
13
12
  child:
14
13
  pipeline:
15
- - sci-m # duration & config -> embodied
14
+ - sci-embodied # duration & config -> embodied
16
15
  defaults:
17
16
  device/emissions-embodied: 1533.120 # gCO2eq
18
17
  time-reserved: 3600 # 1hr in seconds
@@ -6,7 +6,7 @@ initialize:
6
6
  plugins:
7
7
  shell:
8
8
  method: Shell
9
- path: "@grnsft/if-plugins"
9
+ path: "builtin"
10
10
  global-config:
11
11
  command: 1000
12
12
  tree:
@@ -2,11 +2,10 @@ name: shell
2
2
  description: successful path
3
3
  tags:
4
4
  initialize:
5
- outputs: ['yaml']
6
5
  plugins:
7
6
  shell:
8
7
  method: Shell
9
- path: "@grnsft/if-plugins"
8
+ path: 'builtin'
10
9
  global-config:
11
10
  command: python3 /usr/local/bin/sampler
12
11
  tree:
@@ -6,7 +6,7 @@ initialize:
6
6
  plugins:
7
7
  sum:
8
8
  method: Sum
9
- path: "@grnsft/if-plugins"
9
+ path: "builtin"
10
10
  global-config:
11
11
  input-parameters: ["cpu/energy", "network/energy"]
12
12
  output-parameter: "energy"
@@ -0,0 +1,28 @@
1
+ name: sum
2
+ description: missing `output-parameter` in global-config
3
+ tags:
4
+ initialize:
5
+ outputs: ['yaml']
6
+ plugins:
7
+ sum:
8
+ method: Sum
9
+ path: "builtin"
10
+ global-config:
11
+ input-parameters: ["cpu/energy", "network/energy"]
12
+ # output-parameter: "energy"
13
+ tree:
14
+ children:
15
+ child:
16
+ pipeline:
17
+ - sum
18
+ config:
19
+ sum:
20
+ inputs:
21
+ - timestamp: 2023-08-06T00:00
22
+ duration: 3600
23
+ cpu/energy: 0.001
24
+ network/energy: 0.001
25
+ - timestamp: 2023-08-06T00:00
26
+ duration: 3600
27
+ cpu/energy: 0.001
28
+ network/energy: e
@@ -6,7 +6,7 @@ initialize:
6
6
  plugins:
7
7
  sum:
8
8
  method: Sum
9
- path: "@grnsft/if-plugins"
9
+ path: "builtin"
10
10
  global-config:
11
11
  input-parameters: ["cpu/energy", "network/energy"]
12
12
  output-parameter: "energy"
@@ -0,0 +1,19 @@
1
+ name: tdp-finder
2
+ description: successful path
3
+ tags:
4
+ initialize:
5
+ outputs: ['yaml']
6
+ plugins:
7
+ tdp-finder: # a model that returns an embodied value given the sci embodied attribution equation.
8
+ method: TdpFinder
9
+ path: "@grnsft/if-plugins"
10
+ tree:
11
+ children:
12
+ child:
13
+ pipeline:
14
+ - tdp-finder
15
+ config:
16
+ inputs:
17
+ - timestamp: 2023-07-06T00:00
18
+ duration: 300
19
+ physical-processor: AMD 302
@@ -0,0 +1,34 @@
1
+ name: time-sync
2
+ description: missing global config
3
+ tags:
4
+ initialize:
5
+ output:
6
+ - yaml
7
+ plugins:
8
+ 'time-sync':
9
+ method: TimeSync
10
+ path: "builtin"
11
+ global-config:
12
+ # start-time: '2023-12-12T00:00:00.000Z'
13
+ # end-time: '2023-12-12T00:01:00.000Z'
14
+ # interval: 5
15
+ # allow-padding: true
16
+ tree:
17
+ children:
18
+ child:
19
+ pipeline:
20
+ - time-sync
21
+ config:
22
+ inputs:
23
+ - timestamp: '2023-12-12T00:00:00.000Z'
24
+ duration: 3
25
+ energy-cpu: 0.001
26
+ - timestamp: '2023-12-12T00:00:01.000Z'
27
+ duration: 5
28
+ energy-cpu: 0.001
29
+ - timestamp: '2023-12-12T00:00:06.000Z'
30
+ duration: 7
31
+ energy-cpu: 0.001
32
+ - timestamp: '2023-12-12T00:00:13.000Z'
33
+ duration: 30
34
+ energy-cpu: 0.001
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@grnsft/if",
3
3
  "description": "Impact Framework",
4
- "version": "0.3.4",
4
+ "version": "0.4.0-beta.1",
5
5
  "author": {
6
6
  "name": "Green Software Foundation",
7
7
  "email": "info@gsf.com"
8
8
  },
9
9
  "bin": {
10
- "ie": "./build/index.js"
10
+ "ie": "./build/index.js",
11
+ "if-diff": "./build/diff.js"
11
12
  },
12
13
  "bugs": {
13
14
  "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
@@ -15,11 +16,14 @@
15
16
  "dependencies": {
16
17
  "@commitlint/cli": "^18.6.0",
17
18
  "@commitlint/config-conventional": "^18.6.0",
19
+ "axios": "^1.7.2",
20
+ "csv-parse": "^5.5.6",
18
21
  "csv-stringify": "^6.4.6",
19
22
  "js-yaml": "^4.1.0",
20
23
  "luxon": "^3.4.4",
21
24
  "ts-command-line-args": "^2.5.1",
22
25
  "typescript": "^5.1.6",
26
+ "typescript-cubic-spline": "^1.0.1",
23
27
  "winston": "^3.11.0",
24
28
  "zod": "^3.22.4"
25
29
  },
@@ -31,10 +35,12 @@
31
35
  "@types/js-yaml": "^4.0.5",
32
36
  "@types/luxon": "^3.4.2",
33
37
  "@types/node": "^20.8.9",
38
+ "axios-mock-adapter": "^1.22.0",
34
39
  "fixpack": "^4.0.0",
35
40
  "gts": "^5.0.0",
36
41
  "husky": "^8.0.0",
37
42
  "jest": "^29.6.1",
43
+ "lint-staged": "^15.2.2",
38
44
  "release-it": "^16.3.0",
39
45
  "rimraf": "^5.0.5",
40
46
  "ts-jest": "^29.1.1"
@@ -67,7 +73,9 @@
67
73
  "fix": "gts fix",
68
74
  "fix:package": "fixpack",
69
75
  "ie": "npx ts-node src/index.ts",
76
+ "if-diff": "npx ts-node src/diff.ts",
70
77
  "lint": "gts lint",
78
+ "pre-commit": "lint-staged",
71
79
  "prepare": "husky install",
72
80
  "prepublish": "npm run build",
73
81
  "release": "release-it",
@@ -231,9 +231,9 @@ initialize:
231
231
  sci-e:
232
232
  method: SciE
233
233
  path: '@grnsft/if-plugins'
234
- sci-m:
235
- path: '@grnsft/if-plugins'
236
- method: SciM
234
+ sci-embodied:
235
+ path: 'builtin'
236
+ method: SciEmbodied
237
237
  sci-o:
238
238
  method: SciO
239
239
  path: '@grnsft/if-plugins'
@@ -250,13 +250,13 @@ tree:
250
250
  pipeline:
251
251
  - teads-curve
252
252
  - sci-e
253
- - sci-m
253
+ - sci-embodied
254
254
  - sci-o
255
255
  - time-sync
256
256
  config:
257
257
  teads-curve:
258
258
  cpu/thermal-design-power: 65
259
- sci-m:
259
+ sci-embodied:
260
260
  device/emissions-embodied: 251000 # gCO2eq
261
261
  time-reserved: 3600 # 1 hour in s
262
262
  device/expected-lifespan: 126144000 # 4 years in seconds
@@ -0,0 +1,92 @@
1
+ # Coefficient
2
+
3
+ `Coefficient` is a generic plugin for multiplying a value in an `input` array by a given coefficient.
4
+
5
+ You provide the name of the value you want to multiply, a coefficient value, and a name to use to append the product to the output array.
6
+
7
+ For example, you could multiply `cpu/energy` by 10 and name the result `energy-product`. `energy-product` would then be added to every observation in your input array as the product of `cpu/energy` and 10.
8
+
9
+ ## Parameters
10
+
11
+ ### Plugin global config
12
+
13
+ Three parameters are required in global config: `input-parameter`, `coefficient` and `output-parameter`.
14
+
15
+ - `input-parameter`: a string matching an existing key in the `inputs` array
16
+ - `coefficient`: the value to multiply `input-parameter` by.
17
+ - `output-parameter`: a string defining the name to use to add the product of the input parameters to the output array.
18
+
19
+ ### Inputs
20
+
21
+ All of `input-parameters` must be available in the input array.
22
+
23
+ ## Returns
24
+
25
+ - `output-parameter`: the product of all `input-parameters` with the parameter name defined by `output-parameter` in global config.
26
+
27
+ ## Calculation
28
+
29
+ ```pseudocode
30
+ output = input * coefficient
31
+ ```
32
+
33
+ ## Implementation
34
+
35
+ To run the plugin from a Typescript app, you must first create an instance of `Coefficient`. Then, you can call `execute()`.
36
+
37
+ ```typescript
38
+ const config = {
39
+ 'input-parameter': 'carbon',
40
+ coefficient: 10,
41
+ 'output-parameter': 'carbon-product',
42
+ };
43
+
44
+ const coeff = Coefficient(config);
45
+ const result = coeff.execute([
46
+ {
47
+ duration: 3600,
48
+ timestamp: '2021-01-01T00:00:00Z',
49
+ carbon: 3,
50
+ },
51
+ ]);
52
+ ```
53
+
54
+ ## Example manifest
55
+
56
+ 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 `ie` and does not have to be done explicitly by the user. The following is an example manifest that calls `coefficient`:
57
+
58
+ ```yaml
59
+ name: coefficient-demo
60
+ description:
61
+ tags:
62
+ initialize:
63
+ outputs:
64
+ - yaml
65
+ plugins:
66
+ coefficient:
67
+ method: Coefficient
68
+ path: 'builtin'
69
+ global-config:
70
+ input-parameter: 'carbon'
71
+ coefficient: 3
72
+ output-parameter: 'carbon-product'
73
+ tree:
74
+ children:
75
+ child:
76
+ pipeline:
77
+ - coefficient
78
+ config:
79
+ coefficient:
80
+ inputs:
81
+ - timestamp: 2023-08-06T00:00
82
+ duration: 3600
83
+ carbon: 30
84
+ ```
85
+
86
+ You can run this example by saving it as `./examples/manifests/coefficient.yml` and executing the following command from the project root:
87
+
88
+ ```sh
89
+ ie --manifest ./examples/manifests/coefficient.yml --output ./examples/outputs/coefficient.yml
90
+ ```
91
+
92
+ The results will be saved to a new `yaml` file in `./examples/outputs`