@grnsft/if 0.6.0-beta.0 → 0.7.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.
Files changed (354) hide show
  1. package/Refactor-migration-guide.md +68 -82
  2. package/github-processes.md +3 -9
  3. package/manifests/examples/builtins/coefficient/failure-invalid-config-input-param.yml +2 -4
  4. package/manifests/examples/builtins/coefficient/failure-output-param-is-null.yaml +1 -3
  5. package/manifests/examples/builtins/coefficient/success.yml +1 -3
  6. package/manifests/examples/builtins/csv-lookup/cloud-metadata/failure-invalid-instance-type.yaml +1 -2
  7. package/manifests/examples/builtins/csv-lookup/cloud-metadata/failure-invalid-vendor.yaml +3 -4
  8. package/manifests/examples/builtins/csv-lookup/cloud-metadata/failure-missing-cloud-vendor.yml +2 -3
  9. package/manifests/examples/builtins/csv-lookup/cloud-metadata/success.yml +1 -2
  10. package/manifests/examples/builtins/csv-lookup/region-metadata/failure-missing-column.yml +1 -1
  11. package/manifests/examples/builtins/csv-lookup/region-metadata/failure-missing-output.yml +2 -2
  12. package/manifests/examples/builtins/csv-lookup/region-metadata/success-renaming.yml +1 -1
  13. package/manifests/examples/builtins/csv-lookup/region-metadata/success.yml +1 -1
  14. package/manifests/examples/builtins/csv-lookup/tdp-finder/failure-missing-input-param.yml +1 -2
  15. package/manifests/examples/builtins/csv-lookup/tdp-finder/failure-unsupported-physical-processor.yml +1 -2
  16. package/manifests/examples/builtins/csv-lookup/tdp-finder/success.yml +1 -2
  17. package/manifests/examples/builtins/divide/failure-invalid-config-denominator.yml +3 -5
  18. package/manifests/examples/builtins/divide/failure-missing-numerator.yml +2 -4
  19. package/manifests/examples/builtins/divide/success.yml +2 -2
  20. package/manifests/examples/builtins/exponent/success.yml +1 -1
  21. package/manifests/examples/builtins/interpolation/success.yml +1 -1
  22. package/manifests/examples/builtins/mock-observations/failure-invalid-config-cpu-range.yml +2 -2
  23. package/manifests/examples/builtins/mock-observations/failure-invalid-memory-utilization-range.yml +1 -1
  24. package/manifests/examples/builtins/mock-observations/failure-missing-timestamp-from-param.yml +1 -1
  25. package/manifests/examples/builtins/mock-observations/success.yml +1 -1
  26. package/manifests/examples/builtins/multiply/failure-input-parameter-is-missing.yml +1 -1
  27. package/manifests/examples/builtins/multiply/success-with-multiple-inputs.yml +1 -1
  28. package/manifests/examples/builtins/multiply/success.yml +1 -1
  29. package/manifests/examples/builtins/regex/failure-missing-input-param.yml +1 -1
  30. package/manifests/examples/builtins/regex/failure-not-matching-with-regex.yml +2 -2
  31. package/manifests/examples/builtins/regex/success.yml +1 -1
  32. package/manifests/examples/builtins/sci/failure-invalid-config-value.yml +3 -4
  33. package/manifests/examples/builtins/sci/failure-missing-input-param.yml +1 -1
  34. package/manifests/examples/builtins/sci/success.yml +1 -1
  35. package/manifests/examples/builtins/sci-embodied/scenario-1.yml +27 -0
  36. package/manifests/examples/builtins/sci-embodied/scenario-2.yml +37 -0
  37. package/manifests/examples/builtins/sci-embodied/success.yml +13 -0
  38. package/manifests/examples/builtins/shell/failure-invalid-command.yml +2 -2
  39. package/manifests/examples/builtins/shell/success.yml +2 -2
  40. package/manifests/examples/builtins/subtract/success.yml +1 -1
  41. package/manifests/examples/builtins/sum/failure-missing-input-param.yml +2 -2
  42. package/manifests/examples/builtins/sum/failure-missing-output-param.yml +2 -2
  43. package/manifests/examples/builtins/sum/success.yml +1 -1
  44. package/manifests/examples/builtins/time-converter/success.yaml +24 -0
  45. package/manifests/examples/builtins/time-sync/failure-config-start-later-end.yml +10 -12
  46. package/manifests/examples/builtins/time-sync/{failure-missing-global-config.yml → failure-missing-config.yml} +3 -8
  47. package/manifests/examples/builtins/time-sync/success.yml +2 -2
  48. package/manifests/examples/features/regroup/failure-missing-cloud-instance-type.yml +1 -1
  49. package/manifests/examples/features/regroup/success.yml +1 -1
  50. package/manifests/examples/pipelines/generics.yml +8 -8
  51. package/manifests/examples/pipelines/instance-metadata.yml +2 -2
  52. package/manifests/examples/pipelines/nesting.yml +75 -33
  53. package/manifests/examples/pipelines/outputs-if-diff/pipeline-with-aggregate.yaml +166 -122
  54. package/manifests/examples/pipelines/outputs-if-diff/pipeline-with-mocks.yaml +130 -70
  55. package/manifests/examples/pipelines/pipeline-teads-sci.yml +15 -15
  56. package/manifests/examples/pipelines/pipeline-with-aggregate.yml +57 -27
  57. package/manifests/examples/pipelines/pipeline-with-mocks.yml +99 -41
  58. package/manifests/examples/pipelines/scenario-3.yml +1 -1
  59. package/manifests/examples/pipelines/scenario-4.yml +5 -5
  60. package/manifests/examples/pipelines/scenario-5.yml +3 -3
  61. package/manifests/examples/pipelines/sci.yml +12 -12
  62. package/manifests/examples/pipelines/teads-curve.yml +10 -10
  63. package/manifests/examples/pipelines/zeros.yml +23 -23
  64. package/manifests/outputs/bugs/aggregation-error-wrong-metric.yaml +40 -40
  65. package/manifests/outputs/bugs/input-error-missing-duration.yaml +1 -1
  66. package/manifests/outputs/bugs/mock-observations-failure-duration-is-zero.yaml +2 -2
  67. package/manifests/outputs/bugs/pipeline-error-naming-mismatch.yaml +1 -1
  68. package/manifests/outputs/bugs/pipeline-error-uninitialized-plugin.yaml +1 -1
  69. package/manifests/outputs/bugs/pipeline-ordering-error.yaml +6 -6
  70. package/manifests/outputs/builtins/coefficient/failure-invalid-config-input-param.yaml +2 -2
  71. package/manifests/outputs/builtins/coefficient/failure-output-param-is-null.yaml +1 -1
  72. package/manifests/outputs/builtins/coefficient/success.yaml +23 -22
  73. package/manifests/outputs/builtins/csv-lookup/cloud-metadata/failure-invalid-instance-type.yaml +1 -1
  74. package/manifests/outputs/builtins/csv-lookup/cloud-metadata/failure-invalid-vendor.yaml +76 -0
  75. package/manifests/outputs/builtins/csv-lookup/cloud-metadata/failure-missing-cloud-vendor.yaml +22 -21
  76. package/manifests/outputs/builtins/csv-lookup/cloud-metadata/success.yaml +1 -1
  77. package/manifests/outputs/builtins/csv-lookup/region-metadata/failure-missing-column.yaml +1 -1
  78. package/manifests/outputs/builtins/csv-lookup/region-metadata/failure-missing-output.yaml +21 -20
  79. package/manifests/outputs/builtins/csv-lookup/region-metadata/success-renaming.yaml +1 -1
  80. package/manifests/outputs/builtins/csv-lookup/region-metadata/success.yaml +1 -1
  81. package/manifests/outputs/builtins/csv-lookup/tdp-finder/failure-missing-input-param.yaml +1 -1
  82. package/manifests/outputs/builtins/csv-lookup/tdp-finder/failure-unsupported-physical-processor.yaml +1 -1
  83. package/manifests/outputs/builtins/csv-lookup/tdp-finder/success.yaml +1 -1
  84. package/manifests/outputs/builtins/divide/failure-invalid-config-denominator.yaml +41 -25
  85. package/manifests/outputs/builtins/divide/failure-missing-numerator.yaml +32 -23
  86. package/manifests/outputs/builtins/divide/success-denominator-equal-zero.yaml +2 -2
  87. package/manifests/outputs/builtins/divide/success.yaml +2 -2
  88. package/manifests/outputs/builtins/exponent/success.yaml +1 -1
  89. package/manifests/outputs/builtins/interpolation/interpolation.yaml +1 -1
  90. package/manifests/outputs/builtins/interpolation/success.yaml +1 -1
  91. package/manifests/outputs/builtins/mock-observations/failure-invalid-config-cpu-range.yaml +3 -3
  92. package/manifests/outputs/builtins/mock-observations/failure-invalid-memory-utilization-range.yaml +2 -2
  93. package/manifests/outputs/builtins/mock-observations/failure-missing-timestamp-from-param.yaml +1 -1
  94. package/manifests/outputs/builtins/mock-observations/success.yaml +49 -190
  95. package/manifests/outputs/builtins/multiply/failure-input-parameter-is-missing.yaml +1 -1
  96. package/manifests/outputs/builtins/multiply/success-with-multiple-inputs.yaml +1 -1
  97. package/manifests/outputs/builtins/multiply/success.yaml +1 -1
  98. package/manifests/outputs/builtins/regex/failure-missing-input-param.yaml +1 -1
  99. package/manifests/outputs/builtins/regex/failure-not-matching-with-regex.yaml +72 -0
  100. package/manifests/outputs/builtins/regex/success.yaml +1 -1
  101. package/manifests/outputs/builtins/sci/failure-invalid-config-value.yaml +22 -23
  102. package/manifests/outputs/builtins/sci/failure-missing-input-param.yaml +1 -1
  103. package/manifests/outputs/builtins/sci/success.yaml +1 -1
  104. package/manifests/outputs/builtins/sci-embodied/failure-invalid-default-emission-value.yaml +22 -26
  105. package/manifests/outputs/builtins/sci-embodied/scenario-1.yaml +100 -0
  106. package/manifests/outputs/builtins/sci-embodied/scenario-2.yaml +101 -0
  107. package/manifests/outputs/builtins/sci-embodied/success.yaml +44 -20
  108. package/manifests/outputs/builtins/shell/failure-invalid-command.yaml +2 -2
  109. package/manifests/outputs/builtins/shell/success.yaml +1 -1
  110. package/manifests/outputs/builtins/subtract/success.yaml +1 -1
  111. package/manifests/outputs/builtins/sum/failure-missing-input-param.yaml +2 -2
  112. package/manifests/outputs/builtins/sum/failure-missing-output-param.yaml +2 -2
  113. package/manifests/outputs/builtins/sum/success.yaml +1 -1
  114. package/manifests/outputs/builtins/time-converter/success.yaml +73 -0
  115. package/manifests/outputs/builtins/time-sync/failure-config-start-later-end.yaml +3 -3
  116. package/manifests/outputs/builtins/time-sync/failure-missing-config.yaml +74 -0
  117. package/manifests/outputs/builtins/time-sync/success.yaml +50 -59
  118. package/manifests/outputs/features/aggregate-failure-invalid-metrics.yaml +1 -1
  119. package/manifests/outputs/features/aggregate-failure-missing-metric-in-inputs.yaml +1 -1
  120. package/manifests/outputs/features/aggregate-horizontal.yaml +4 -2
  121. package/manifests/outputs/features/aggregate-vertical.yaml +4 -2
  122. package/manifests/outputs/features/aggregate.yaml +4 -2
  123. package/manifests/outputs/features/regroup/failure-invalid-regroup.yaml +87 -0
  124. package/manifests/outputs/features/regroup/failure-missing-cloud-instance-type.yaml +87 -0
  125. package/manifests/outputs/pipelines/cloud-metadata-divide.yaml +2 -2
  126. package/manifests/outputs/pipelines/generics.yaml +28 -28
  127. package/manifests/outputs/pipelines/instance-metadata.yaml +14 -14
  128. package/manifests/outputs/pipelines/nesting.yaml +713 -486
  129. package/manifests/outputs/pipelines/pipeline-teads-sci.yaml +63 -32
  130. package/manifests/outputs/pipelines/scenario-4.yaml +105 -0
  131. package/manifests/outputs/pipelines/sci.yaml +56 -32
  132. package/manifests/outputs/pipelines/teads-curve.yaml +18 -18
  133. package/manifests/outputs/pipelines/zeros.yaml +27 -27
  134. package/package.json +7 -5
  135. package/src/__mocks__/mock-manifest.yaml +1 -2
  136. package/src/if-env/config/env-template.yml +1 -2
  137. package/src/if-run/builtins/coefficient/README.md +41 -17
  138. package/src/if-run/builtins/copy-param/README.md +28 -8
  139. package/src/if-run/builtins/csv-lookup/README.md +31 -11
  140. package/src/if-run/builtins/divide/README.md +34 -12
  141. package/src/if-run/builtins/exponent/README.md +29 -11
  142. package/src/if-run/builtins/interpolation/README.md +37 -22
  143. package/src/if-run/builtins/mock-observations/README.md +27 -7
  144. package/src/if-run/builtins/multiply/README.md +27 -9
  145. package/src/if-run/builtins/regex/README.md +31 -11
  146. package/src/if-run/builtins/sci/README.md +29 -8
  147. package/src/if-run/builtins/sci-embodied/README.md +76 -75
  148. package/src/if-run/builtins/shell/README.md +15 -7
  149. package/src/if-run/builtins/subtract/README.md +28 -11
  150. package/src/if-run/builtins/sum/README.md +47 -14
  151. package/src/if-run/builtins/time-converter/README.md +136 -0
  152. package/src/if-run/builtins/time-sync/README.md +44 -22
  153. package/.gitmodules +0 -3
  154. package/build/common/config/index.d.ts +0 -1
  155. package/build/common/config/index.js +0 -6
  156. package/build/common/config/strings.d.ts +0 -8
  157. package/build/common/config/strings.js +0 -16
  158. package/build/common/lib/load.d.ts +0 -6
  159. package/build/common/lib/load.js +0 -18
  160. package/build/common/types/manifest.d.ts +0 -13
  161. package/build/common/types/manifest.js +0 -3
  162. package/build/common/util/debug-logger.d.ts +0 -4
  163. package/build/common/util/debug-logger.js +0 -115
  164. package/build/common/util/fs.d.ts +0 -20
  165. package/build/common/util/fs.js +0 -94
  166. package/build/common/util/helpers.d.ts +0 -15
  167. package/build/common/util/helpers.js +0 -80
  168. package/build/common/util/logger.d.ts +0 -5
  169. package/build/common/util/logger.js +0 -39
  170. package/build/common/util/validations.d.ts +0 -367
  171. package/build/common/util/validations.js +0 -141
  172. package/build/common/util/yaml.d.ts +0 -12
  173. package/build/common/util/yaml.js +0 -59
  174. package/build/if-check/config/config.d.ts +0 -6
  175. package/build/if-check/config/config.js +0 -31
  176. package/build/if-check/config/index.d.ts +0 -2
  177. package/build/if-check/config/index.js +0 -8
  178. package/build/if-check/config/strings.d.ts +0 -12
  179. package/build/if-check/config/strings.js +0 -16
  180. package/build/if-check/index.d.ts +0 -2
  181. package/build/if-check/index.js +0 -98
  182. package/build/if-check/types/process-args.d.ts +0 -4
  183. package/build/if-check/types/process-args.js +0 -3
  184. package/build/if-check/util/args.d.ts +0 -10
  185. package/build/if-check/util/args.js +0 -56
  186. package/build/if-check/util/helpers.d.ts +0 -4
  187. package/build/if-check/util/helpers.js +0 -18
  188. package/build/if-check/util/npm.d.ts +0 -4
  189. package/build/if-check/util/npm.js +0 -59
  190. package/build/if-csv/config/config.d.ts +0 -6
  191. package/build/if-csv/config/config.js +0 -37
  192. package/build/if-csv/config/index.d.ts +0 -2
  193. package/build/if-csv/config/index.js +0 -8
  194. package/build/if-csv/config/strings.d.ts +0 -4
  195. package/build/if-csv/config/strings.js +0 -8
  196. package/build/if-csv/index.d.ts +0 -2
  197. package/build/if-csv/index.js +0 -63
  198. package/build/if-csv/types/csv.d.ts +0 -7
  199. package/build/if-csv/types/csv.js +0 -3
  200. package/build/if-csv/types/process-args.d.ts +0 -5
  201. package/build/if-csv/types/process-args.js +0 -3
  202. package/build/if-csv/util/args.d.ts +0 -12
  203. package/build/if-csv/util/args.js +0 -51
  204. package/build/if-csv/util/helpers.d.ts +0 -9
  205. package/build/if-csv/util/helpers.js +0 -95
  206. package/build/if-diff/config/config.d.ts +0 -6
  207. package/build/if-diff/config/config.js +0 -31
  208. package/build/if-diff/config/index.d.ts +0 -2
  209. package/build/if-diff/config/index.js +0 -8
  210. package/build/if-diff/config/strings.d.ts +0 -6
  211. package/build/if-diff/config/strings.js +0 -10
  212. package/build/if-diff/index.d.ts +0 -2
  213. package/build/if-diff/index.js +0 -46
  214. package/build/if-diff/lib/compare.d.ts +0 -10
  215. package/build/if-diff/lib/compare.js +0 -56
  216. package/build/if-diff/lib/load.d.ts +0 -55
  217. package/build/if-diff/lib/load.js +0 -51
  218. package/build/if-diff/types/args.d.ts +0 -5
  219. package/build/if-diff/types/args.js +0 -3
  220. package/build/if-diff/types/compare.d.ts +0 -7
  221. package/build/if-diff/types/compare.js +0 -3
  222. package/build/if-diff/types/process-args.d.ts +0 -4
  223. package/build/if-diff/types/process-args.js +0 -3
  224. package/build/if-diff/util/args.d.ts +0 -5
  225. package/build/if-diff/util/args.js +0 -51
  226. package/build/if-diff/util/helpers.d.ts +0 -13
  227. package/build/if-diff/util/helpers.js +0 -75
  228. package/build/if-env/config/config.d.ts +0 -6
  229. package/build/if-env/config/config.js +0 -37
  230. package/build/if-env/config/index.d.ts +0 -2
  231. package/build/if-env/config/index.js +0 -8
  232. package/build/if-env/config/strings.d.ts +0 -7
  233. package/build/if-env/config/strings.js +0 -11
  234. package/build/if-env/index.d.ts +0 -2
  235. package/build/if-env/index.js +0 -40
  236. package/build/if-env/types/if-env.d.ts +0 -8
  237. package/build/if-env/types/if-env.js +0 -3
  238. package/build/if-env/types/npm.d.ts +0 -9
  239. package/build/if-env/types/npm.js +0 -3
  240. package/build/if-env/types/process-args.d.ts +0 -5
  241. package/build/if-env/types/process-args.js +0 -3
  242. package/build/if-env/util/args.d.ts +0 -12
  243. package/build/if-env/util/args.js +0 -47
  244. package/build/if-env/util/helpers.d.ts +0 -20
  245. package/build/if-env/util/helpers.js +0 -94
  246. package/build/if-env/util/npm.d.ts +0 -24
  247. package/build/if-env/util/npm.js +0 -126
  248. package/build/if-run/builtins/coefficient/index.d.ts +0 -2
  249. package/build/if-run/builtins/coefficient/index.js +0 -67
  250. package/build/if-run/builtins/copy-param/index.d.ts +0 -2
  251. package/build/if-run/builtins/copy-param/index.js +0 -70
  252. package/build/if-run/builtins/csv-lookup/index.d.ts +0 -2
  253. package/build/if-run/builtins/csv-lookup/index.js +0 -190
  254. package/build/if-run/builtins/divide/index.d.ts +0 -2
  255. package/build/if-run/builtins/divide/index.js +0 -80
  256. package/build/if-run/builtins/exponent/index.d.ts +0 -2
  257. package/build/if-run/builtins/exponent/index.js +0 -60
  258. package/build/if-run/builtins/export-log.d.ts +0 -4
  259. package/build/if-run/builtins/export-log.js +0 -44
  260. package/build/if-run/builtins/export-yaml.d.ts +0 -4
  261. package/build/if-run/builtins/export-yaml.js +0 -30
  262. package/build/if-run/builtins/index.d.ts +0 -15
  263. package/build/if-run/builtins/index.js +0 -34
  264. package/build/if-run/builtins/interpolation/index.d.ts +0 -2
  265. package/build/if-run/builtins/interpolation/index.js +0 -151
  266. package/build/if-run/builtins/mock-observations/helpers/common-generator.d.ts +0 -3
  267. package/build/if-run/builtins/mock-observations/helpers/common-generator.js +0 -29
  268. package/build/if-run/builtins/mock-observations/helpers/rand-int-generator.d.ts +0 -3
  269. package/build/if-run/builtins/mock-observations/helpers/rand-int-generator.js +0 -48
  270. package/build/if-run/builtins/mock-observations/index.d.ts +0 -2
  271. package/build/if-run/builtins/mock-observations/index.js +0 -116
  272. package/build/if-run/builtins/mock-observations/interfaces/index.d.ts +0 -6
  273. package/build/if-run/builtins/mock-observations/interfaces/index.js +0 -3
  274. package/build/if-run/builtins/multiply/index.d.ts +0 -2
  275. package/build/if-run/builtins/multiply/index.js +0 -59
  276. package/build/if-run/builtins/regex/index.d.ts +0 -2
  277. package/build/if-run/builtins/regex/index.js +0 -76
  278. package/build/if-run/builtins/sci/config.d.ts +0 -1
  279. package/build/if-run/builtins/sci/config.js +0 -44
  280. package/build/if-run/builtins/sci/index.d.ts +0 -2
  281. package/build/if-run/builtins/sci/index.js +0 -92
  282. package/build/if-run/builtins/sci-embodied/index.d.ts +0 -2
  283. package/build/if-run/builtins/sci-embodied/index.js +0 -156
  284. package/build/if-run/builtins/shell/index.d.ts +0 -2
  285. package/build/if-run/builtins/shell/index.js +0 -60
  286. package/build/if-run/builtins/subtract/index.d.ts +0 -2
  287. package/build/if-run/builtins/subtract/index.js +0 -61
  288. package/build/if-run/builtins/sum/index.d.ts +0 -2
  289. package/build/if-run/builtins/sum/index.js +0 -66
  290. package/build/if-run/builtins/time-sync/index.d.ts +0 -17
  291. package/build/if-run/builtins/time-sync/index.js +0 -339
  292. package/build/if-run/config/config.d.ts +0 -9
  293. package/build/if-run/config/config.js +0 -73
  294. package/build/if-run/config/index.d.ts +0 -2
  295. package/build/if-run/config/index.js +0 -8
  296. package/build/if-run/config/strings.d.ts +0 -64
  297. package/build/if-run/config/strings.js +0 -76
  298. package/build/if-run/index.d.ts +0 -2
  299. package/build/if-run/index.js +0 -63
  300. package/build/if-run/lib/aggregate.d.ts +0 -15
  301. package/build/if-run/lib/aggregate.js +0 -123
  302. package/build/if-run/lib/compute.d.ts +0 -5
  303. package/build/if-run/lib/compute.js +0 -136
  304. package/build/if-run/lib/environment.d.ts +0 -5
  305. package/build/if-run/lib/environment.js +0 -75
  306. package/build/if-run/lib/exhaust.d.ts +0 -7
  307. package/build/if-run/lib/exhaust.js +0 -27
  308. package/build/if-run/lib/explain.d.ts +0 -9
  309. package/build/if-run/lib/explain.js +0 -43
  310. package/build/if-run/lib/initialize.d.ts +0 -6
  311. package/build/if-run/lib/initialize.js +0 -109
  312. package/build/if-run/lib/regroup.d.ts +0 -5
  313. package/build/if-run/lib/regroup.js +0 -64
  314. package/build/if-run/types/aggregation.d.ts +0 -5
  315. package/build/if-run/types/aggregation.js +0 -6
  316. package/build/if-run/types/compute.d.ts +0 -29
  317. package/build/if-run/types/compute.js +0 -3
  318. package/build/if-run/types/environment.d.ts +0 -18
  319. package/build/if-run/types/environment.js +0 -3
  320. package/build/if-run/types/exhaust-plugin-interface.d.ts +0 -7
  321. package/build/if-run/types/exhaust-plugin-interface.js +0 -3
  322. package/build/if-run/types/explain.d.ts +0 -10
  323. package/build/if-run/types/explain.js +0 -3
  324. package/build/if-run/types/interface.d.ts +0 -3
  325. package/build/if-run/types/interface.js +0 -6
  326. package/build/if-run/types/plugin-storage.d.ts +0 -6
  327. package/build/if-run/types/plugin-storage.js +0 -3
  328. package/build/if-run/types/process-args.d.ts +0 -25
  329. package/build/if-run/types/process-args.js +0 -3
  330. package/build/if-run/types/time-sync.d.ts +0 -17
  331. package/build/if-run/types/time-sync.js +0 -3
  332. package/build/if-run/util/aggregation-helper.d.ts +0 -7
  333. package/build/if-run/util/aggregation-helper.js +0 -47
  334. package/build/if-run/util/args.d.ts +0 -9
  335. package/build/if-run/util/args.js +0 -60
  336. package/build/if-run/util/helpers.d.ts +0 -14
  337. package/build/if-run/util/helpers.js +0 -57
  338. package/build/if-run/util/log-memoize.d.ts +0 -3
  339. package/build/if-run/util/log-memoize.js +0 -19
  340. package/build/if-run/util/os-checker.d.ts +0 -7
  341. package/build/if-run/util/os-checker.js +0 -97
  342. package/build/if-run/util/plugin-storage.d.ts +0 -14
  343. package/build/if-run/util/plugin-storage.js +0 -34
  344. package/grafana/IF_GRAFANA_SETUP.md +0 -71
  345. package/grafana/if_grafana_config.json +0 -370
  346. package/manifests/examples/builtins/divide/failure-denominator-equal-zero.yml +0 -38
  347. package/manifests/examples/builtins/interpolation/interpolation.yml +0 -24
  348. package/manifests/examples/builtins/sci-embodied/failure-invalid-default-emission-value.yml +0 -23
  349. package/manifests/examples/builtins/sci-embodied/failure-missing-expected-lifespan.yml +0 -23
  350. package/manifests/examples/pipelines/scenario-1.yml +0 -34
  351. package/manifests/examples/pipelines/scenario-2.yml +0 -52
  352. package/manifests/outputs/bugs/sci-embodied-missing-resources-total.yaml +0 -72
  353. package/manifests/outputs/builtins/sci-embodied/failure-missing-expected-lifespan.yaml +0 -69
  354. package/manifests/outputs/pipelines/mock-obs-time-sync.yaml +0 -449
@@ -2,135 +2,136 @@
2
2
 
3
3
  Software systems cause emissions through the hardware that they operate on, both through the energy that the physical hardware consumes and the emissions associated with manufacturing the hardware. Embodied carbon refers to the carbon emitted during the manufacture and eventual disposal of a component. It is added to the operational carbon (carbon emitted when a component is used) to give an overall SCI score.
4
4
 
5
- Read more on [embodied carbon](https://github.com/Green-Software-Foundation/sci/blob/main/Software_Carbon_Intensity/Software_Carbon_Intensity_Specification.md#embodied-emissions)
5
+ Read more on [embodied carbon](https://github.com/Green-Software-Foundation/sci/blob/main/Software_Carbon_Intensity/Software_Carbon_Intensity_Specification.md#embodied-emissions).
6
6
 
7
- ## Parameters
7
+ Our plugin follows the Cloud Carbon Footprint methodology for calculating embodied carbon and extends it to scale down the total embodied carbon for a piece of hardware by the portion of it that should be allocated to a particular application, using a `usage-ratio` and `time`. The `usage-ratio` is a term that can be used to scale by, for example, the storage you actually use on a shared server, rather than the total storage available for that hardware, or the time you are active compared to the hardware lifespan.
8
8
 
9
- ### Plugin config
10
9
 
11
- Not Needed
10
+ ## Parameters
12
11
 
13
- ### Plugin parameter metadata
12
+ ### Plugin Configuration
14
13
 
15
- The `parameter-metadata` section contains information about `description`, `unit` and `aggregation-method` of the parameters of the inputs and outputs
14
+ The `SciEmbodied` plugin requires a configuration object and parameter metadata (optional) to do the calculation.
16
15
 
17
- - `inputs`: describe the parameters of the `inputs`. Each parameter has:
16
+ ### Plugin Parameter Metadata
18
17
 
19
- - `description`: description of the parameter
20
- - `unit`: unit of the parameter
21
- - `aggregation-method`: aggregation method of the parameter (it can be `sum`, `avg` or `none`)
18
+ The `parameter-metadata` section contains information about the `description`, `unit`, and `aggregation-method` of the input and output parameters.
22
19
 
23
- - `outputs`: describe the `carbon-embodied` parameter. The parameter has the following attributes:
24
- - `description`: description of the parameter
25
- - `unit`: unit of the parameter
26
- - `aggregation-method`: aggregation method of the parameter (it can be `sum`, `avg` or `none`)
20
+ - `inputs`: Describes the parameters for the input data. Each parameter includes:
21
+ - `description`: A brief description of the parameter.
22
+ - `unit`: The unit of measurement for the parameter.
23
+ - `aggregation-method`: The method used to aggregate this parameter (`sum`, `avg`, or `none`).
27
24
 
28
- ### Inputs
25
+ - `outputs`: Describes the `embodied-carbon` parameter, which includes:
26
+ - `description`: A brief description of the parameter.
27
+ - `unit`: The unit of measurement for the parameter.
28
+ - `aggregation-method`: The method used to aggregate this parameter (`sum`, `avg`, or `none`).
29
29
 
30
- - `device/emissions-embodied`: the sum of Life Cycle Assessment (LCA) emissions for the component
31
- - `device/expected-lifespan`: the length of time, in seconds, between a component's manufacture and its disposal
32
- - `resources-reserved`: the number of resources reserved for use by the software
33
- - `resources-total`: the total number of resources available
34
- - `duration`: the amount of time covered by an observation, in this context it is used as the share of the total life span of the hardware reserved for use by an application, in seconds.
30
+ ### Mapping
35
31
 
36
- > Note that if you have a plugin pipeline that adds `vcpus-allocated` and `vcpus-total` to each observation, such as the `cloud-metadata` plugin, those values will be used **in preference** to the given `resources-reserved` and `resources-total` fields.
32
+ The `mapping` block is an optional block. It is added in the plugin section and allows the plugin to receive a parameter from the input with a different name than the one the plugin uses for data manipulation. The parameter with the mapped name will not appear in the outputs. It also maps the output parameter of the plugin. The structure of the `mapping` block is:
37
33
 
38
- ## Returns
34
+ ```yaml
35
+ sci-embodied:
36
+ method: SciEmbodied
37
+ path: 'builtins'
38
+ mapping:
39
+ 'parameter-name-in-the-plugin': 'parameter-name-in-the-input'
40
+ ```
39
41
 
40
- - `carbon-embodied`: the carbon emitted in manufacturing and disposing of a component, in gCO2eq
42
+ ### Config
41
43
 
42
- ## Calculation
44
+ `baseline-vcpus`: the number of CPUs to use in the baseline server, defaults tothe CCF value of 1,
45
+ `baseline-memory`: the amount of memory to use in the baseline server, defaults tothe CCF value of 16,
46
+ `baseline-emissions`: the embodied carbon assumed to represent a baseline server, in g
47
+ `lifespan`: the lifespan of the device, in seconds. Defaults to 4 years (126144000 seconds),
48
+ `time`: the time to consider when scaling the total device embodied carbon, if not given defaults to `duration`
49
+ `vcpu-emissions-constant`: emissions for a CPU in gCO2e. Defaults tothe CCF value (100000),
50
+ `memory-emissions-constant`: value used in calculating emissions due to memory, defaults to the CCf value of 533/384
51
+ `ssd-emissions-constant`: emissions for a SSD in gCO2e. Defaults tothe CCF value (50000),
52
+ `hdd-emissions-constant`: emissions for a CPU in gCO2e. Defaults tothe CCF value (100000),
53
+ `gpu-emissions-constant`: emissions for a GPU in gCO2e. Defaults tothe CCF value (150000),
54
+ `output-parameter`: name to give the output value, defaults to `embodied-carbon`
43
55
 
44
- To calculate the embodied carbon, `m` for a software application, use the equation:
56
+ Note that if you do not provide any config at all, we will fallback to defaults for everything, equivalent to setting the baseline server equal to the CCF version, which has 1000000g of embodied emissions.
45
57
 
46
- ```
47
- m = te * ts * rs
48
- ```
58
+ ### Inputs
49
59
 
50
- Where:
60
+ - `vCPUs`: number of CPUs available on device
61
+ - `memory`: amount of RAM available on device, in GB
62
+ - `ssd`: number of SSD drives mounted on device
63
+ - `hdd`: number of HDD drives mounted on device
64
+ - `gpu`: number of GPUs available on device
65
+ - `duration`: The length of time the hardware is reserved for use by the software, in seconds.
66
+ - `time`: the time to use for scalign the total embodied carbon per timestap, if you do not want to use `duration`
67
+ - `usage-ratio`: the ratio by which to scale down the total embodied carbon according to your usage, e.g. for a shared storage server the total storage divided by your actual storage.
51
68
 
52
- - `device/emissions-embodied` = Total embodied emissions; the sum of Life Cycle Assessment (LCA) emissions for the component.
69
+ Note that if you do not provide any inputs at all, we fall back to defaults that are equivalent to using the full resources of the baseline server, scaled only by `duration`.
53
70
 
54
- - `timeShare` = Time-share; the share of the total life span of the hardware reserved for use by an application.
71
+ ### Outputs
55
72
 
56
- - `timeShare` is calculated as `duration/'device/expected-lifespan'`, where:
57
- - `duration` = the length of time the hardware is reserved for use by the software.
58
- - `device/expected-lifespan` = Expected lifespan: the length of time, in seconds, between a component's manufacture and its disposal.
73
+ - `embodied-carbon`: The total embodied emissions for the component, measured in gCO2e, per timestep.
59
74
 
60
- - `resourceShare` = Resource-share; the share of the total available resources of the hardware reserved for use by an application.
61
- - `resourceShare` is calculated as `resources-reserved/resources-total`, where:
62
- - `resources-reserved` = Resources reserved; the number of resources reserved for use by the software.
63
- - `resources-total` = Total Resources; the total number of resources available.
75
+ ## Calculation
64
76
 
65
- ## Implementation
77
+ The plugin calculates the total embodied carbon emissions using the following steps:
66
78
 
67
- IF implements the plugin based on the logic described above. To run the plugin, you must first create an instance of `SciEmbodied`. Then, you can call `execute()` to return `m`.
79
+ - CPU emissions (`cpuE`) are calculated based on the difference between allocated vCPUs and baseline vCPUs.
80
+ - Memory emissions (`memoryE`) are calculated based on the difference between allocated memory and baseline memory.
81
+ - Emissions for HDD, SSD, and GPU are also calculated based on their respective differences from baseline values.
82
+ - The total embodied emissions are calculated by summing the baseline emissions with the above components scaling by the usage ratio and time.
68
83
 
69
- ## Usage
84
+ ## Implementation
70
85
 
71
- The following snippet demonstrates how to call the `sci-embodied` plugin from Typescript.
86
+ The plugin can be instantiated and executed as follows:
72
87
 
73
88
  ```typescript
74
89
  import {SciEmbodied} from 'builtins';
75
90
 
76
- const sciEmbodied = SciEmbodied();
91
+ const sciEmbodied = SciEmbodied(config, parametersMetadata, {});
77
92
  const results = await sciEmbodied.execute([
78
93
  {
79
- 'device/emissions-embodied': 200, // in gCO2e for total resource units
80
- duration: 60 * 60 * 24 * 30, // time reserved in seconds, can point to another field "duration"
81
- 'device/expected-lifespan': 60 * 60 * 24 * 365 * 4, // lifespan in seconds (4 years)
82
- 'resources-reserved': 1, // resource units reserved / used
83
- 'resources-total': 1, // total resource units available
94
+ duration: 3600, // time reserved in seconds
95
+ vCPUs: 2, // allocated vCPUs
96
+ memory: 32, // allocated memory in GB
97
+ ssd: 100, // allocated SSD storage in GB
98
+ hdd: 1000, // allocated HDD storage in GB
99
+ gpu: 1, // allocated GPUs
84
100
  },
85
101
  ]);
102
+
103
+ console.log(results);
86
104
  ```
87
105
 
88
- ## Example manifest
106
+ # Example Manifest
89
107
 
90
- 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 `sci-embodied`:
108
+ 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 `if-run` and does not have to be done explicitly by the user. The following is an example `manifest` that calls `sci-embodied`:
91
109
 
92
110
  ```yaml
93
111
  name: sci-embodied
94
- description: simple demo invoking sci-embodied
112
+ description: demo invoking sci-embodied
95
113
  tags:
96
114
  initialize:
97
115
  plugins:
98
116
  sci-embodied:
99
117
  method: SciEmbodied
100
118
  path: 'builtins'
119
+ mapping:
120
+ device/emissions-embodied: device/carbon-footprint
101
121
  tree:
102
122
  children:
103
123
  child:
104
124
  pipeline:
105
125
  compute:
106
- - sci-embodied # duration & config -> embodied
107
- defaults:
108
- device/emissions-embodied: 1533.120 # gCO2eq
109
- device/expected-lifespan: 3 # 3 years in seconds
110
- resources-reserved: 1
111
- resources-total: 8
126
+ - sci-embodied
112
127
  inputs:
113
- - timestamp: 2023-07-06T00:00
128
+ - timestamp: 2024-08-19T00:00
114
129
  duration: 3600
115
130
  ```
116
131
 
117
- You can run this example `manifest` by executing the following command from the project root:
132
+ To run this example manifest, use the following command:
118
133
 
119
- ```sh
134
+ ```bash
120
135
  npm i -g @grnsft/if
121
- if-run --manifest manifests/plugins/sci-embodied.yml --output manifests/outputs/sci-embodied.yml
136
+ if-run --manifest manifests/plugins/sci-embodied/success.yml --output manifests/outputs/success.yml
122
137
  ```
123
-
124
- The results will be saved to a new `yaml` file in `./examples/outputs`.
125
-
126
- ## Errors
127
-
128
- `SciEmbodied` uses one of IF's error classes
129
-
130
- ### `SciEmbodiedError`
131
-
132
- This error class is used to describe a problem with one of the input values to `sci-embodied`. This is typically due to an incorrect type or a reference to a value that is not available.
133
-
134
- You will receive a specific error message explaining which parameter is problematic, and you can check and replace where appropriate.
135
-
136
- For more information on our error classes, please visit [our docs](https://if.greensoftware.foundation/reference/errors
@@ -4,7 +4,7 @@ The `shell` is a wrapper enabling plugins implemented in any other programming l
4
4
 
5
5
  ## Parameters
6
6
 
7
- ### Plugin global config
7
+ ### Plugin config
8
8
 
9
9
  The plugin should be initialized as follows:
10
10
 
@@ -14,7 +14,7 @@ initialize:
14
14
  shell:
15
15
  method: Shell
16
16
  path: 'builtin'
17
- global-config:
17
+ config:
18
18
  command: python3 /usr/local/bin/sampler
19
19
  ```
20
20
 
@@ -30,12 +30,16 @@ The `parameter-metadata` section contains information about `description`, `unit
30
30
 
31
31
  - `description`: description of the parameter
32
32
  - `unit`: unit of the parameter
33
- - `aggregation-method`: aggregation method of the parameter (it can be `sum`, `avg` or `none`)
33
+ - `aggregation-method`: aggregation method object of the parameter
34
+ - `time`: this value is used for `horizontal` aggregation. It can be of the following values: `sum`, `avg`, `copy`, or `none`.
35
+ - `component`: this value is used for `vertical` aggregation. It can be of the following values: `sum`, `avg`, `copy`, or `none`.
34
36
 
35
37
  - `outputs`: describe the output parameter. The parameter has the following attributes:
36
38
  - `description`: description of the parameter
37
39
  - `unit`: unit of the parameter
38
- - `aggregation-method`: aggregation method of the parameter (it can be `sum`, `avg` or `none`)
40
+ - `aggregation-method`: aggregation method object of the parameter
41
+ - `time`: this value is used for `horizontal` aggregation. It can be of the following values: `sum`, `avg`, `copy`, or `none`.
42
+ - `component`: this value is used for `vertical` aggregation. It can be of the following values: `sum`, `avg`, `copy`, or `none`.
39
43
 
40
44
  ### Inputs
41
45
 
@@ -53,7 +57,11 @@ The specific return types depend on the plugin being invoked. Typically, we woul
53
57
  To run the plugin, you must first create an instance of `Shell` and call its `execute()` to run the external plugin.
54
58
 
55
59
  ```typescript
56
- const output = Shell({command: '/usr/local/bin/sampler'});
60
+ const config = {
61
+ command: '/usr/local/bin/sampler',
62
+ };
63
+ const parametersMetadata = {inputs: {}, outputs: {}};
64
+ const output = Shell(config, parametersMetadata);
57
65
  const result = await output.execute([
58
66
  {
59
67
  timestamp: '2021-01-01T00:00:00Z',
@@ -85,7 +93,7 @@ initialize:
85
93
  sampler:
86
94
  method: Shell
87
95
  path: 'builtin'
88
- global-config:
96
+ config:
89
97
  command: python3 /usr/local/bin/sampler
90
98
  tree:
91
99
  children:
@@ -112,7 +120,7 @@ initialize:
112
120
  sampler:
113
121
  method: Shell
114
122
  path: 'builtin'
115
- global-config:
123
+ config:
116
124
  command: python3 /usr/local/bin/sampler
117
125
  tree:
118
126
  children:
@@ -10,7 +10,7 @@ For example, you could subtract `cpu/energy` and `network/energy` and name the r
10
10
 
11
11
  ### Plugin config
12
12
 
13
- Two parameters are required in global config: `input-parameters` and `output-parameter`.
13
+ Two parameters are required in config: `input-parameters` and `output-parameter`.
14
14
 
15
15
  `input-parameters`: an array of strings. Each string should match an existing key in the `inputs` array
16
16
  `output-parameter`: a string defining the name to use to add the result of the diff to the output array.
@@ -19,16 +19,32 @@ Two parameters are required in global config: `input-parameters` and `output-par
19
19
 
20
20
  The `parameter-metadata` section contains information about `description`, `unit` and `aggregation-method` of the parameters of the inputs and outputs
21
21
 
22
- - `inputs`: describe parameters of the `input-parameters` of the global config. Each parameter has the following attributes:
22
+ - `inputs`: describe parameters of the `input-parameters` of the config. Each parameter has the following attributes:
23
23
 
24
24
  - `description`: description of the parameter
25
25
  - `unit`: unit of the parameter
26
- - `aggregation-method`: aggregation method of the parameter (it can be `sum`, `avg` or `none`)
26
+ - `aggregation-method`: aggregation method object of the parameter
27
+ - `time`: this value is used for `horizontal` aggregation. It can be of the following values: `sum`, `avg`, `copy`, or `none`.
28
+ - `component`: this value is used for `vertical` aggregation. It can be of the following values: `sum`, `avg`, `copy`, or `none`.
27
29
 
28
- - `outputs`: describe the parameter of the `output-parameter` of the global config. The parameter has the following attributes:
30
+ - `outputs`: describe the parameter of the `output-parameter` of the config. The parameter has the following attributes:
29
31
  - `description`: description of the parameter
30
32
  - `unit`: unit of the parameter
31
- - `aggregation-method`: aggregation method of the parameter (it can be `sum`, `avg` or `none`)
33
+ - `aggregation-method`: aggregation method object of the parameter
34
+ - `time`: this value is used for `horizontal` aggregation. It can be of the following values: `sum`, `avg`, `copy`, or `none`.
35
+ - `component`: this value is used for `vertical` aggregation. It can be of the following values: `sum`, `avg`, `copy`, or `none`.
36
+
37
+ ### Mapping
38
+
39
+ The `mapping` block is an optional block. It is added in the plugin section and allows the plugin to receive a parameter from the input with a different name than the one the plugin uses for data manipulation. The parameter with the mapped name will not appear in the outputs. It also maps the output parameter of the plugin. The structure of the `mapping` block is:
40
+
41
+ ```yaml
42
+ subtract:
43
+ method: Subtract
44
+ path: 'builtin'
45
+ mapping:
46
+ 'parameter-name-in-the-plugin': 'parameter-name-in-the-input'
47
+ ```
32
48
 
33
49
  ### Inputs
34
50
 
@@ -36,7 +52,7 @@ All of `input-parameters` must be available in the input array.
36
52
 
37
53
  ## Returns
38
54
 
39
- - `output-parameter`: the subtraction of all `input-parameters` with the parameter name defined by `output-parameter` in global config.
55
+ - `output-parameter`: the subtraction of all `input-parameters` with the parameter name defined by `output-parameter` in config.
40
56
 
41
57
  ## Calculation
42
58
 
@@ -55,9 +71,10 @@ const config = {
55
71
  inputParameters: ['cpu/energy', 'network/energy'],
56
72
  outputParameter: 'offset/energy',
57
73
  };
58
-
59
- const subtract = Subtract(config);
60
- const result = subtract subtract.execute([
74
+ const parametersMetadata = {inputs: {}, outputs: {}};
75
+ const mapping = {};
76
+ const subtract = Subtract(config, parametersMetadata, mapping);
77
+ const result = await subtract.execute([
61
78
  {
62
79
  duration: 3600,
63
80
  timestamp: '2021-01-01T00:00:00Z',
@@ -80,7 +97,7 @@ initialize:
80
97
  subtract:
81
98
  method: Subtract
82
99
  path: 'builtin'
83
- global-config:
100
+ config:
84
101
  input-parameters: ['cpu/energy', 'network/energy']
85
102
  output-parameter: 'energy/diff'
86
103
  tree:
@@ -113,4 +130,4 @@ The results will be saved to a new `yaml` file in `manifests/outputs`.
113
130
 
114
131
  This error arises when an invalid value is passed to `Subtract`. 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.
115
132
 
116
- For more information on our error classes, please visit [our docs](https://if.greensoftware.foundation/reference/errors
133
+ For more information on our error classes, please visit [our docs](https://if.greensoftware.foundation/reference/errors)
@@ -10,7 +10,7 @@ For example, you could add `cpu/energy` and `network/energy` and name the result
10
10
 
11
11
  ### Plugin config
12
12
 
13
- Two parameters are required in global config: `input-parameters` and `output-parameter`.
13
+ Two parameters are required in config: `input-parameters` and `output-parameter`.
14
14
 
15
15
  `input-parameters`: an array of strings. Each string should match an existing key in the `inputs` array
16
16
  `output-parameter`: a string defining the name to use to add the result of summing the input parameters to the output array.
@@ -19,16 +19,32 @@ Two parameters are required in global config: `input-parameters` and `output-par
19
19
 
20
20
  The `parameter-metadata` section contains information about `description`, `unit` and `aggregation-method` of the parameters of the inputs and outputs
21
21
 
22
- - `inputs`: describe parameters of the `input-parameters` of the global config. Each parameter has:
22
+ - `inputs`: describe parameters of the `input-parameters` of the config. Each parameter has:
23
23
 
24
24
  - `description`: description of the parameter
25
25
  - `unit`: unit of the parameter
26
- - `aggregation-method`: aggregation method of the parameter (it can be `sum`, `avg` or `none`)
26
+ - `aggregation-method`: aggregation method object of the parameter
27
+ - `time`: this value is used for `horizontal` aggregation. It can be of the following values: `sum`, `avg`, `copy`, or `none`.
28
+ - `component`: this value is used for `vertical` aggregation. It can be of the following values: `sum`, `avg`, `copy`, or `none`.
27
29
 
28
- - `outputs`: describe the parameter of the `output-parameter` of the global config. The parameter has the following attributes:
30
+ - `outputs`: describe the parameter of the `output-parameter` of the config. The parameter has the following attributes:
29
31
  - `description`: description of the parameter
30
32
  - `unit`: unit of the parameter
31
- - `aggregation-method`: aggregation method of the parameter (it can be `sum`, `avg` or `none`)
33
+ - `aggregation-method`: aggregation method object of the parameter
34
+ - `time`: this value is used for `horizontal` aggregation. It can be of the following values: `sum`, `avg`, `copy`, or `none`.
35
+ - `component`: this value is used for `vertical` aggregation. It can be of the following values: `sum`, `avg`, `copy`, or `none`.
36
+
37
+ ### Mapping
38
+
39
+ The `mapping` block is an optional block. It is added in the plugin section and allows the plugin to receive a parameter from the input with a different name than the one the plugin uses for data manipulation. The parameter with the mapped name will not appear in the outputs. It also maps the output parameter of the plugin. The structure of the `mapping` block is:
40
+
41
+ ```yaml
42
+ sum:
43
+ method: Sum
44
+ path: 'builtin'
45
+ mapping:
46
+ 'parameter-name-in-the-plugin': 'parameter-name-in-the-input'
47
+ ```
32
48
 
33
49
  ### Inputs
34
50
 
@@ -36,7 +52,7 @@ All of `input-parameters` must be available in the input array.
36
52
 
37
53
  ## Returns
38
54
 
39
- - `output-parameter`: the sum of all `input-parameters` with the parameter name defined by `output-parameter` in global config.
55
+ - `output-parameter`: the sum of all `input-parameters` with the parameter name defined by `output-parameter` in config.
40
56
 
41
57
  ## Calculation
42
58
 
@@ -53,9 +69,14 @@ const config = {
53
69
  inputParameters: ['cpu/energy', 'network/energy'],
54
70
  outputParameter: 'energy',
55
71
  };
72
+ const parametersMetadata = {inputs: {}, outputs: {}};
73
+ const = mapping {
74
+ 'cpu/energy': 'energy-from-cpu',
75
+ 'network/energy': 'energy-from-network',
76
+ };
56
77
 
57
- const sum = Sum(config, parametersMetadata);
58
- const result = sum.execute([
78
+ const sum = Sum(config, parametersMetadata, mapping);
79
+ const result = await sum.execute([
59
80
  {
60
81
  timestamp: '2021-01-01T00:00:00Z',
61
82
  duration: 3600,
@@ -78,7 +99,7 @@ initialize:
78
99
  sum:
79
100
  method: Sum
80
101
  path: 'builtin'
81
- global-config:
102
+ config:
82
103
  input-parameters: ['cpu/energy', 'network/energy']
83
104
  output-parameter: 'energy'
84
105
  parameter-metadata:
@@ -86,16 +107,28 @@ initialize:
86
107
  cpu/energy:
87
108
  description: energy consumed by the cpu
88
109
  unit: kWh
89
- aggregation-method: sum
110
+ aggregation-method:
111
+ time: sum
112
+ component: sum
113
+ aggregation-method:
114
+ time: sum
115
+ component: sum
90
116
  network/energy:
91
117
  description: energy consumed by data ingress and egress
92
118
  unit: kWh
93
- aggregation-method: sum
119
+ aggregation-method:
120
+ time: sum
121
+ component: sum
122
+ aggregation-method:
123
+ time: sum
124
+ component: sum
94
125
  outputs:
95
126
  energy:
96
127
  description: sum of energy components
97
128
  unit: kWh
98
- aggregation-method: sum
129
+ aggregation-method:
130
+ time: sum
131
+ component: sum
99
132
  tree:
100
133
  children:
101
134
  child:
@@ -121,9 +154,9 @@ The results will be saved to a new `yaml` file in `./examples/outputs`.
121
154
 
122
155
  `Sum` exposes two of the IF error classes.
123
156
 
124
- ### GlobalConfigError
157
+ ### ConfigError
125
158
 
126
- You will receive an error starting `GlobalConfigError: ` if you have not provided the expected configuration data in the plugin's `initialize` block.
159
+ You will receive an error starting `ConfigError: ` if you have not provided the expected configuration data in the plugin's `initialize` block.
127
160
 
128
161
  The required parameters are:
129
162
 
@@ -0,0 +1,136 @@
1
+ # Time Converter
2
+
3
+ `time-conversion` is a generic plugin for converting time values from a specified time unit to a new given time unit.
4
+
5
+ You provide the energy value, the time unit associated with this energy, and a new time unit to which you want to convert it.
6
+
7
+ For example, you could add `energy-per-year`, the time unit `year`, and the new time unit `duration`. The `energy-per-duration` would then be added to every observation in your input array as the converted value of `energy-per-year`, `year` and `duration`.
8
+
9
+ ## Parameters
10
+
11
+ ### Plugin config
12
+
13
+ These parameters are required in config:
14
+
15
+ - `input-parameter`: a string that should match an existing key in the `inputs` array
16
+ - `original-time-unit`: a string that defines the time unit of the `input-parameter`. The original time unit should be a valid unit, like `year`, `month`, `day`, `hour` and so on
17
+ - `new-time-unit`: a string that defines the new time unit that the `input-parameter` value should be converted to. The time unit can be `duration`(in which case it grabs the value from the `duration` in the input), or can be other time unit like `second`, `month`, `day`, `week` and so on
18
+ - `output-parameter`: a string defining the name to use to add the result of converting the input parameter to the output array
19
+
20
+ ### Plugin parameter metadata
21
+
22
+ The `parameter-metadata` section contains information about `description` and `unit` of the parameters of the inputs and outputs
23
+
24
+ - `inputs`: describe parameters of the `input-parameter` of the config. Each parameter has:
25
+
26
+ - `description`: description of the parameter
27
+ - `unit`: unit of the parameter
28
+ - `aggregation-method`: the aggregation method of the parameter (can be `sum`, `avg` or `none`)
29
+
30
+ - `outputs`: describe the parameter of the `output-parameter` of the config. The parameter has the following attributes:
31
+ - `description`: description of the parameter
32
+ - `unit`: unit of the parameter
33
+ - `aggregation-method`: the aggregation method of the parameter (can be `sum`, `avg` or `none`)
34
+
35
+ ### Inputs
36
+
37
+ The `input-parameter` must be available in the input array.
38
+
39
+ ## Returns
40
+
41
+ - `output-parameter`: the converted energy of the `input-parameter` with the parameter name defined by `output-parameter` in config.
42
+
43
+ ## Calculation
44
+
45
+ ```pseudocode
46
+ output = input-parameter / original-time-unit * new-time-unit
47
+ ```
48
+
49
+ ## Implementation
50
+
51
+ To run the plugin, you must first create an instance of `TimeConverter`. Then, you can call `execute()`.
52
+
53
+ ```typescript
54
+ const config = {
55
+ 'input-parameter': 'energy-per-year',
56
+ 'original-time-unit': 'year',
57
+ 'new-time-unit': 'duration',
58
+ 'output-parameter': 'energy-per-duration',
59
+ };
60
+
61
+ const timeConverter = TimeConverter(config, parametersMetadata);
62
+ const result = await timeConverter.execute([
63
+ {
64
+ timestamp: '2021-01-01T00:00:00Z',
65
+ duration: 3600,
66
+ 'energy-per-year': 10000,
67
+ },
68
+ ]);
69
+ ```
70
+
71
+ ## Example manifest
72
+
73
+ 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 `time-coverstion`:
74
+
75
+ ```yaml
76
+ name: time-coverstion demo
77
+ description:
78
+ tags:
79
+ initialize:
80
+ plugins:
81
+ time-converter:
82
+ method: TimeConverter
83
+ path: builtin
84
+ config:
85
+ input-parameter: 'energy-per-year'
86
+ original-time-unit: 'year'
87
+ new-time-unit: 'duration'
88
+ output-parameter: 'energy-per-duration'
89
+ tree:
90
+ children:
91
+ child:
92
+ pipeline:
93
+ - time-converter
94
+ config:
95
+ defaults:
96
+ energy-per-year: 10000
97
+ inputs:
98
+ - timestamp: 2023-08-06T00:00
99
+ duration: 3600
100
+ ```
101
+
102
+ You can run this example by saving it as `./examples/manifests/time-coverstion.yml` and executing the following command from the project root:
103
+
104
+ ```sh
105
+ if-run --manifest ./examples/manifests/time-coverstion.yml --output ./examples/outputs/time-coverstion.yml
106
+ ```
107
+
108
+ The results will be saved to a new `yaml` file in `./examples/outputs`.
109
+
110
+ ## Errors
111
+
112
+ `TimeConverter` exposes two of the IF error classes.
113
+
114
+ ### ConfigError
115
+
116
+ You will receive an error starting `ConfigError: ` if you have not provided the expected configuration data in the plugin's `initialize` block.
117
+
118
+ The required parameters are:
119
+
120
+ - `input-parameter`: this must be a string, which is the name of parameter in the `inputs` array
121
+ - `original-time-unit`: this must be a string of time units (`minutes`, `seconds` and so on)
122
+ - `new-time-unit`: this must be a string of time units (e.g. `duration`, `minutes`, `seconds` and so on)
123
+ - `output-parameter`: this must be a string
124
+
125
+ You can fix this error by checking you are providing valid values for each parameter in the config.
126
+
127
+ ### `MissingInputDataError`
128
+
129
+ This error arises when a necessary piece of input data is missing from the `inputs` array.
130
+ Every element in the `inputs` array must contain:
131
+
132
+ - `timestamp`
133
+ - `duration`
134
+ - whatever values you passed to `input-parameter`
135
+
136
+ For more information on our error classes, please visit [our docs](https://if.greensoftware.foundation/reference/errors).