@grnsft/if 1.0.0-beta.0 → 1.0.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 (263) hide show
  1. package/.env +5 -0
  2. package/README.md +1 -1
  3. package/adopters.md +3 -0
  4. package/build/common/config/strings.js +3 -4
  5. package/build/common/util/helpers.d.ts +5 -0
  6. package/build/common/util/helpers.js +24 -2
  7. package/build/if-check/config/config.js +7 -1
  8. package/build/if-check/util/args.js +3 -2
  9. package/build/if-check/util/npm.js +4 -4
  10. package/build/if-csv/config/config.js +7 -1
  11. package/build/if-csv/util/args.js +3 -2
  12. package/build/if-diff/config/config.js +7 -1
  13. package/build/if-diff/util/args.js +3 -2
  14. package/build/if-env/config/config.js +7 -1
  15. package/build/if-env/util/args.js +3 -2
  16. package/build/if-merge/config/config.js +7 -1
  17. package/build/if-merge/util/args.js +3 -2
  18. package/build/if-merge/util/helpers.js +4 -1
  19. package/build/if-run/builtins/csv-import/index.d.ts +16 -0
  20. package/build/if-run/builtins/csv-import/index.js +69 -0
  21. package/build/if-run/builtins/csv-lookup/index.js +10 -87
  22. package/build/if-run/builtins/index.d.ts +1 -0
  23. package/build/if-run/builtins/index.js +4 -2
  24. package/build/if-run/builtins/util/csv-helpers.d.ts +26 -0
  25. package/build/if-run/builtins/util/csv-helpers.js +92 -0
  26. package/build/if-run/config/config.js +1 -7
  27. package/build/if-run/config/strings.d.ts +1 -0
  28. package/build/if-run/config/strings.js +2 -1
  29. package/build/if-run/lib/compute.js +23 -16
  30. package/build/if-run/lib/regroup.d.ts +5 -0
  31. package/build/if-run/lib/regroup.js +14 -2
  32. package/build/if-run/util/args.d.ts +1 -1
  33. package/build/if-run/util/args.js +5 -4
  34. package/coverage/clover.xml +2062 -0
  35. package/coverage/coverage-final.json +58 -0
  36. package/coverage/lcov-report/base.css +224 -0
  37. package/coverage/lcov-report/block-navigation.js +87 -0
  38. package/coverage/lcov-report/builtins/coefficient/index.html +116 -0
  39. package/coverage/lcov-report/builtins/coefficient/index.ts.html +298 -0
  40. package/coverage/lcov-report/builtins/csv-lookup/index.html +116 -0
  41. package/coverage/lcov-report/builtins/csv-lookup/index.ts.html +826 -0
  42. package/coverage/lcov-report/builtins/divide/index.html +116 -0
  43. package/coverage/lcov-report/builtins/divide/index.ts.html +358 -0
  44. package/coverage/lcov-report/builtins/exponent/index.html +116 -0
  45. package/coverage/lcov-report/builtins/exponent/index.ts.html +361 -0
  46. package/coverage/lcov-report/builtins/export-csv-raw.ts.html +553 -0
  47. package/coverage/lcov-report/builtins/export-csv.ts.html +436 -0
  48. package/coverage/lcov-report/builtins/export-log.ts.html +148 -0
  49. package/coverage/lcov-report/builtins/export-yaml.ts.html +193 -0
  50. package/coverage/lcov-report/builtins/group-by.ts.html +370 -0
  51. package/coverage/lcov-report/builtins/index.html +206 -0
  52. package/coverage/lcov-report/builtins/index.ts.html +130 -0
  53. package/coverage/lcov-report/builtins/interpolation/index.html +116 -0
  54. package/coverage/lcov-report/builtins/interpolation/index.ts.html +676 -0
  55. package/coverage/lcov-report/builtins/interpolation/types.ts.html +100 -0
  56. package/coverage/lcov-report/builtins/mock-observations/helpers/common-generator.ts.html +184 -0
  57. package/coverage/lcov-report/builtins/mock-observations/helpers/index.html +131 -0
  58. package/coverage/lcov-report/builtins/mock-observations/helpers/rand-int-generator.ts.html +289 -0
  59. package/coverage/lcov-report/builtins/mock-observations/index.html +116 -0
  60. package/coverage/lcov-report/builtins/mock-observations/index.ts.html +619 -0
  61. package/coverage/lcov-report/builtins/multiply/index.html +116 -0
  62. package/coverage/lcov-report/builtins/multiply/index.ts.html +343 -0
  63. package/coverage/lcov-report/builtins/regex/index.html +116 -0
  64. package/coverage/lcov-report/builtins/regex/index.ts.html +373 -0
  65. package/coverage/lcov-report/builtins/sci/config.ts.html +205 -0
  66. package/coverage/lcov-report/builtins/sci/index.html +116 -0
  67. package/coverage/lcov-report/builtins/sci/index.ts.html +325 -0
  68. package/coverage/lcov-report/builtins/sci-embodied/index.html +116 -0
  69. package/coverage/lcov-report/builtins/sci-embodied/index.ts.html +478 -0
  70. package/coverage/lcov-report/builtins/shell/index.html +116 -0
  71. package/coverage/lcov-report/builtins/shell/index.ts.html +280 -0
  72. package/coverage/lcov-report/builtins/subtract/index.html +116 -0
  73. package/coverage/lcov-report/builtins/subtract/index.ts.html +379 -0
  74. package/coverage/lcov-report/builtins/sum/index.html +116 -0
  75. package/coverage/lcov-report/builtins/sum/index.ts.html +334 -0
  76. package/coverage/lcov-report/builtins/time-sync.ts.html +1462 -0
  77. package/coverage/lcov-report/common/config/index.html +131 -0
  78. package/coverage/lcov-report/common/config/index.ts.html +88 -0
  79. package/coverage/lcov-report/common/config/strings.ts.html +121 -0
  80. package/coverage/lcov-report/common/lib/index.html +116 -0
  81. package/coverage/lcov-report/common/lib/load.ts.html +139 -0
  82. package/coverage/lcov-report/common/util/debug-logger.ts.html +514 -0
  83. package/coverage/lcov-report/common/util/fs.ts.html +289 -0
  84. package/coverage/lcov-report/common/util/helpers.ts.html +355 -0
  85. package/coverage/lcov-report/common/util/index.html +191 -0
  86. package/coverage/lcov-report/common/util/logger.ts.html +151 -0
  87. package/coverage/lcov-report/common/util/validations.ts.html +628 -0
  88. package/coverage/lcov-report/common/util/yaml.ts.html +226 -0
  89. package/coverage/lcov-report/config/config.ts.html +463 -0
  90. package/coverage/lcov-report/config/index.html +161 -0
  91. package/coverage/lcov-report/config/index.ts.html +94 -0
  92. package/coverage/lcov-report/config/params.ts.html +697 -0
  93. package/coverage/lcov-report/config/strings.ts.html +490 -0
  94. package/coverage/lcov-report/favicon.png +0 -0
  95. package/coverage/lcov-report/if-check/config/config.ts.html +184 -0
  96. package/coverage/lcov-report/if-check/config/index.html +146 -0
  97. package/coverage/lcov-report/if-check/config/index.ts.html +91 -0
  98. package/coverage/lcov-report/if-check/config/strings.ts.html +142 -0
  99. package/coverage/lcov-report/if-check/util/args.ts.html +310 -0
  100. package/coverage/lcov-report/if-check/util/helpers.ts.html +136 -0
  101. package/coverage/lcov-report/if-check/util/index.html +146 -0
  102. package/coverage/lcov-report/if-check/util/npm.ts.html +376 -0
  103. package/coverage/lcov-report/if-csv/util/args.ts.html +256 -0
  104. package/coverage/lcov-report/if-csv/util/helpers.ts.html +346 -0
  105. package/coverage/lcov-report/if-csv/util/index.html +131 -0
  106. package/coverage/lcov-report/if-diff/config/config.ts.html +184 -0
  107. package/coverage/lcov-report/if-diff/config/index.html +146 -0
  108. package/coverage/lcov-report/if-diff/config/index.ts.html +91 -0
  109. package/coverage/lcov-report/if-diff/config/strings.ts.html +100 -0
  110. package/coverage/lcov-report/if-diff/lib/compare.ts.html +286 -0
  111. package/coverage/lcov-report/if-diff/lib/index.html +131 -0
  112. package/coverage/lcov-report/if-diff/lib/load.ts.html +199 -0
  113. package/coverage/lcov-report/if-diff/util/args.ts.html +274 -0
  114. package/coverage/lcov-report/if-diff/util/helpers.ts.html +337 -0
  115. package/coverage/lcov-report/if-diff/util/index.html +131 -0
  116. package/coverage/lcov-report/if-env/config/config.ts.html +211 -0
  117. package/coverage/lcov-report/if-env/config/index.html +146 -0
  118. package/coverage/lcov-report/if-env/config/index.ts.html +91 -0
  119. package/coverage/lcov-report/if-env/config/strings.ts.html +109 -0
  120. package/coverage/lcov-report/if-env/util/args.ts.html +256 -0
  121. package/coverage/lcov-report/if-env/util/index.html +131 -0
  122. package/coverage/lcov-report/if-env/util/npm.ts.html +526 -0
  123. package/coverage/lcov-report/if-merge/util/args.ts.html +301 -0
  124. package/coverage/lcov-report/if-merge/util/helpers.ts.html +313 -0
  125. package/coverage/lcov-report/if-merge/util/index.html +131 -0
  126. package/coverage/lcov-report/if-run/builtins/coefficient/index.html +116 -0
  127. package/coverage/lcov-report/if-run/builtins/coefficient/index.ts.html +286 -0
  128. package/coverage/lcov-report/if-run/builtins/copy-param/index.html +116 -0
  129. package/coverage/lcov-report/if-run/builtins/copy-param/index.ts.html +301 -0
  130. package/coverage/lcov-report/if-run/builtins/csv-import/index.html +116 -0
  131. package/coverage/lcov-report/if-run/builtins/csv-import/index.ts.html +364 -0
  132. package/coverage/lcov-report/if-run/builtins/csv-lookup/index.html +116 -0
  133. package/coverage/lcov-report/if-run/builtins/csv-lookup/index.ts.html +478 -0
  134. package/coverage/lcov-report/if-run/builtins/divide/index.html +116 -0
  135. package/coverage/lcov-report/if-run/builtins/divide/index.ts.html +346 -0
  136. package/coverage/lcov-report/if-run/builtins/exponent/index.html +116 -0
  137. package/coverage/lcov-report/if-run/builtins/exponent/index.ts.html +319 -0
  138. package/coverage/lcov-report/if-run/builtins/export-csv-raw.ts.html +553 -0
  139. package/coverage/lcov-report/if-run/builtins/export-csv.ts.html +436 -0
  140. package/coverage/lcov-report/if-run/builtins/export-log.ts.html +148 -0
  141. package/coverage/lcov-report/if-run/builtins/export-yaml.ts.html +193 -0
  142. package/coverage/lcov-report/if-run/builtins/group-by.ts.html +370 -0
  143. package/coverage/lcov-report/if-run/builtins/index.html +146 -0
  144. package/coverage/lcov-report/if-run/builtins/index.ts.html +136 -0
  145. package/coverage/lcov-report/if-run/builtins/interpolation/index.html +116 -0
  146. package/coverage/lcov-report/if-run/builtins/interpolation/index.ts.html +643 -0
  147. package/coverage/lcov-report/if-run/builtins/mock-observations/helpers/common-generator.ts.html +184 -0
  148. package/coverage/lcov-report/if-run/builtins/mock-observations/helpers/index.html +131 -0
  149. package/coverage/lcov-report/if-run/builtins/mock-observations/helpers/rand-int-generator.ts.html +289 -0
  150. package/coverage/lcov-report/if-run/builtins/mock-observations/index.html +116 -0
  151. package/coverage/lcov-report/if-run/builtins/mock-observations/index.ts.html +607 -0
  152. package/coverage/lcov-report/if-run/builtins/multiply/index.html +116 -0
  153. package/coverage/lcov-report/if-run/builtins/multiply/index.ts.html +289 -0
  154. package/coverage/lcov-report/if-run/builtins/regex/index.html +116 -0
  155. package/coverage/lcov-report/if-run/builtins/regex/index.ts.html +298 -0
  156. package/coverage/lcov-report/if-run/builtins/sci/index.html +116 -0
  157. package/coverage/lcov-report/if-run/builtins/sci/index.ts.html +418 -0
  158. package/coverage/lcov-report/if-run/builtins/sci-embodied/index.html +116 -0
  159. package/coverage/lcov-report/if-run/builtins/sci-embodied/index.ts.html +664 -0
  160. package/coverage/lcov-report/if-run/builtins/shell/index.html +116 -0
  161. package/coverage/lcov-report/if-run/builtins/shell/index.ts.html +256 -0
  162. package/coverage/lcov-report/if-run/builtins/subtract/index.html +116 -0
  163. package/coverage/lcov-report/if-run/builtins/subtract/index.ts.html +298 -0
  164. package/coverage/lcov-report/if-run/builtins/sum/index.html +116 -0
  165. package/coverage/lcov-report/if-run/builtins/sum/index.ts.html +238 -0
  166. package/coverage/lcov-report/if-run/builtins/time-converter/config.ts.html +205 -0
  167. package/coverage/lcov-report/if-run/builtins/time-converter/index.html +131 -0
  168. package/coverage/lcov-report/if-run/builtins/time-converter/index.ts.html +328 -0
  169. package/coverage/lcov-report/if-run/builtins/time-sync/index.html +116 -0
  170. package/coverage/lcov-report/if-run/builtins/time-sync/index.ts.html +1804 -0
  171. package/coverage/lcov-report/if-run/builtins/time-sync.ts.html +1462 -0
  172. package/coverage/lcov-report/if-run/builtins/util/csv-helpers.ts.html +376 -0
  173. package/coverage/lcov-report/if-run/builtins/util/index.html +116 -0
  174. package/coverage/lcov-report/if-run/config/config.ts.html +271 -0
  175. package/coverage/lcov-report/if-run/config/index.html +161 -0
  176. package/coverage/lcov-report/if-run/config/index.ts.html +94 -0
  177. package/coverage/lcov-report/if-run/config/params.ts.html +679 -0
  178. package/coverage/lcov-report/if-run/config/strings.ts.html +460 -0
  179. package/coverage/lcov-report/if-run/lib/aggregate.ts.html +577 -0
  180. package/coverage/lcov-report/if-run/lib/compute.ts.html +733 -0
  181. package/coverage/lcov-report/if-run/lib/environment.ts.html +373 -0
  182. package/coverage/lcov-report/if-run/lib/exhaust.ts.html +193 -0
  183. package/coverage/lcov-report/if-run/lib/explain.ts.html +484 -0
  184. package/coverage/lcov-report/if-run/lib/index.html +206 -0
  185. package/coverage/lcov-report/if-run/lib/initialize.ts.html +490 -0
  186. package/coverage/lcov-report/if-run/lib/parameterize.ts.html +322 -0
  187. package/coverage/lcov-report/if-run/lib/regroup.ts.html +349 -0
  188. package/coverage/lcov-report/if-run/lib/time-sync.ts.html +1510 -0
  189. package/coverage/lcov-report/if-run/types/aggregation.ts.html +94 -0
  190. package/coverage/lcov-report/if-run/types/index.html +146 -0
  191. package/coverage/lcov-report/if-run/types/interface.ts.html +112 -0
  192. package/coverage/lcov-report/if-run/types/parameters.ts.html +106 -0
  193. package/coverage/lcov-report/if-run/util/aggregation-helper.ts.html +277 -0
  194. package/coverage/lcov-report/if-run/util/args.ts.html +325 -0
  195. package/coverage/lcov-report/if-run/util/helpers.ts.html +208 -0
  196. package/coverage/lcov-report/if-run/util/index.html +191 -0
  197. package/coverage/lcov-report/if-run/util/json.ts.html +115 -0
  198. package/coverage/lcov-report/if-run/util/log-memoize.ts.html +145 -0
  199. package/coverage/lcov-report/if-run/util/os-checker.ts.html +421 -0
  200. package/coverage/lcov-report/if-run/util/plugin-storage.ts.html +202 -0
  201. package/coverage/lcov-report/index.html +551 -0
  202. package/coverage/lcov-report/lib/aggregate.ts.html +358 -0
  203. package/coverage/lcov-report/lib/compare.ts.html +286 -0
  204. package/coverage/lcov-report/lib/compute.ts.html +436 -0
  205. package/coverage/lcov-report/lib/environment.ts.html +376 -0
  206. package/coverage/lcov-report/lib/exhaust.ts.html +289 -0
  207. package/coverage/lcov-report/lib/index.html +221 -0
  208. package/coverage/lcov-report/lib/initialize.ts.html +430 -0
  209. package/coverage/lcov-report/lib/load.ts.html +268 -0
  210. package/coverage/lcov-report/lib/parameterize.ts.html +316 -0
  211. package/coverage/lcov-report/prettify.css +1 -0
  212. package/coverage/lcov-report/prettify.js +2 -0
  213. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  214. package/coverage/lcov-report/sorter.js +196 -0
  215. package/coverage/lcov-report/types/aggregation.ts.html +94 -0
  216. package/coverage/lcov-report/types/index.html +146 -0
  217. package/coverage/lcov-report/types/interface.ts.html +112 -0
  218. package/coverage/lcov-report/types/parameters.ts.html +106 -0
  219. package/coverage/lcov-report/util/aggregation-helper.ts.html +289 -0
  220. package/coverage/lcov-report/util/args.ts.html +649 -0
  221. package/coverage/lcov-report/util/debug-logger.ts.html +481 -0
  222. package/coverage/lcov-report/util/errors.ts.html +232 -0
  223. package/coverage/lcov-report/util/fs.ts.html +124 -0
  224. package/coverage/lcov-report/util/helpers.ts.html +895 -0
  225. package/coverage/lcov-report/util/index.html +296 -0
  226. package/coverage/lcov-report/util/json.ts.html +115 -0
  227. package/coverage/lcov-report/util/log-memoize.ts.html +145 -0
  228. package/coverage/lcov-report/util/logger.ts.html +151 -0
  229. package/coverage/lcov-report/util/npm.ts.html +499 -0
  230. package/coverage/lcov-report/util/os-checker.ts.html +421 -0
  231. package/coverage/lcov-report/util/plugin-storage.ts.html +202 -0
  232. package/coverage/lcov-report/util/validations.ts.html +544 -0
  233. package/coverage/lcov-report/util/yaml.ts.html +193 -0
  234. package/coverage/lcov.info +3548 -0
  235. package/manifests/examples/builtins/csv-import/success.yaml +22 -0
  236. package/manifests/examples/builtins/csv-import/test.csv +4 -0
  237. package/manifests/outputs/builtins/csv-import/success.yaml +84 -0
  238. package/manifests/regroup.yml +49 -0
  239. package/manifests/test.yml +524 -0
  240. package/package.json +1 -1
  241. package/src/if-run/builtins/csv-import/README.md +190 -0
  242. package/src/if-run/builtins/csv-lookup/README.md +7 -7
  243. package/manifests/outputs/bugs/package.json +0 -24
  244. package/manifests/outputs/builtins/coefficient/package.json +0 -24
  245. package/manifests/outputs/builtins/csv-lookup/cloud-metadata/package.json +0 -24
  246. package/manifests/outputs/builtins/csv-lookup/region-metadata/package.json +0 -24
  247. package/manifests/outputs/builtins/csv-lookup/tdp-finder/package.json +0 -24
  248. package/manifests/outputs/builtins/divide/package.json +0 -24
  249. package/manifests/outputs/builtins/exponent/package.json +0 -24
  250. package/manifests/outputs/builtins/interpolation/package.json +0 -24
  251. package/manifests/outputs/builtins/mock-observations/package.json +0 -24
  252. package/manifests/outputs/builtins/multiply/package.json +0 -24
  253. package/manifests/outputs/builtins/regex/package.json +0 -24
  254. package/manifests/outputs/builtins/sci/package.json +0 -24
  255. package/manifests/outputs/builtins/sci-embodied/package.json +0 -24
  256. package/manifests/outputs/builtins/shell/package.json +0 -24
  257. package/manifests/outputs/builtins/subtract/package.json +0 -24
  258. package/manifests/outputs/builtins/sum/package.json +0 -24
  259. package/manifests/outputs/builtins/time-converter/package.json +0 -24
  260. package/manifests/outputs/builtins/time-sync/package.json +0 -24
  261. package/manifests/outputs/features/package.json +0 -24
  262. package/manifests/outputs/features/regroup/package.json +0 -24
  263. package/manifests/outputs/pipelines/package.json +0 -24
@@ -0,0 +1,190 @@
1
+ # CSV Import Plugin
2
+
3
+ `csv-import` is a versatile plugin that allows you to extract specific data from a CSV file and seamlessly integrate it into the `input` data of your manifest file.
4
+
5
+ You provide path to the target csv file. The file path can reference either a local file on your system or a URL pointing to an online resource.
6
+
7
+ For example, for the following CSV:
8
+
9
+ | | | | | | | | | | | | | | | | | |
10
+ | ---- | -------------- | --------------- | ---------- | ---------- | ------------ | --------- | ---------------- | ---------- | ---------- | ---------------------- | ---------- | -------------------------- | --------------------------------- | ------------------------------ | -------------------------------- | --------------------- |
11
+ | year | cloud-provider | cloud-region | cfe-region | em-zone-id | wt-region-id | location | geolocation | cfe-hourly | cfe-annual | power-usage-efficiency | net-carbon | grid-carbon-intensity-24x7 | grid-carbon-intensity-consumption | grid-carbon-intensity-marginal | grid-carbon-intensity-production | grid-carbon-intensity |
12
+ | 2022 | Google Cloud | asia-east1 | Taiwan | TW | TW | Taiwan | 25.0375,121.5625 | 0.18 | | | 0 | 453 | | | | 453 |
13
+ | 2022 | Google Cloud | asia-east2 | Hong Kong | HK | HK | Hong Kong | 22.3,114.2 | 0.28 | | | 0 | 453 | | | | 360 |
14
+ | 2022 | Google Cloud | asia-northeast1 | Tokyo | JP-TK | JP-TK | Tokyo | 35.6897,139.692 | 0.28 | | | 0 | 463 | | | | 463 |
15
+
16
+ You could select all the data in the `csv` file using the following configuration:
17
+
18
+ ```yaml
19
+ filepath: https://raw.githubusercontent.com/Green-Software-Foundation/if-data/main/region-metadata.csv
20
+ output: '*'
21
+ ```
22
+
23
+ ## Parameters
24
+
25
+ ### Plugin config
26
+
27
+ - `filepath` - path to a csv file, either on the local filesystem or on the internet
28
+ - `output` - the columns to grab data from and add to output data - should support wildcard or multiple values.
29
+
30
+ The plugin also supports data renaming. This means you can grab data from a named column but push it into your manifest file data under another name, for example, maybe we want to grab data from the `processor-name` column in the target csv and add it to the manifest file data as `processor-id` because this is the name expected by some other plugin in your piepline. You can do this by passing comma separated values in arrays.
31
+
32
+ ```yaml
33
+ output: ['processor-name': 'processor-id']
34
+ ```
35
+
36
+ You can nest arrays to do this renaming for multiple columns.
37
+
38
+ ```yaml
39
+ output:
40
+ [['processor-name', 'processor-model-id'], ['tdp', 'thermal-design-power']]
41
+ ```
42
+
43
+ - `"*"` - indicating all columns should be selected
44
+ - `"tdp"` - indicating that only column `tdp` should be selected
45
+ - `["processor-name", "processor-model-id"]` - indicating that only column `processor-name` should be selected and output as `processor-model-id`
46
+ - `[["processor-name", "processor-model-id"],["tdp", "thermal-design-power"]]` - indicating that the `processor-name` and `tdp` columns should be selected with `processor-name` output as `processor-model-id` and `tdp` as `thermal-design-power`
47
+
48
+ ### Plugin parameter metadata
49
+
50
+ The `parameter-metadata` section contains information about `description`, `unit` and `aggregation-method` of the parameters of the inputs and outputs
51
+
52
+ - `inputs`: describe the parameters of the `inputs`. Each parameter has:
53
+
54
+ - `description`: description of the parameter
55
+ - `unit`: unit of the parameter
56
+ - `aggregation-method`: aggregation method object of the parameter
57
+ - `time`: this value is used for `horizontal` aggregation. It can be of the following values: `sum`, `avg`, `copy`, or `none`.
58
+ - `component`: this value is used for `vertical` aggregation. It can be of the following values: `sum`, `avg`, `copy`, or `none`.
59
+
60
+ - `outputs`: describe the parameters in the `output` of the config block. The parameter has the following attributes:
61
+ - `description`: description of the parameter
62
+ - `unit`: unit of the parameter
63
+ - `aggregation-method`: aggregation method object of the parameter
64
+ - `time`: this value is used for `horizontal` aggregation. It can be of the following values: `sum`, `avg`, `copy`, or `none`.
65
+ - `component`: this value is used for `vertical` aggregation. It can be of the following values: `sum`, `avg`, `copy`, or `none`.
66
+
67
+ ### Mapping
68
+
69
+ 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:
70
+
71
+ ```yaml
72
+ cloud-metadata:
73
+ method: CSVImport
74
+ path: 'builtin'
75
+ mapping:
76
+ 'parameter-name-in-the-plugin': 'parameter-name-in-the-input'
77
+ ```
78
+
79
+ ### Inputs
80
+
81
+ There are no strict requirements on input for this plugin because they depend upon the contents of the target CSV and your input data at the time the CSV import is invoked. Please make sure you are requesting data from columns that exist in the target csv file and that your query values are available in your `input` data.
82
+
83
+ ## Returns
84
+
85
+ The input data with the requested csv content appended to it.
86
+
87
+ ## Plugin logic
88
+
89
+ 1. Validates config which contains `filepath` and `output`.
90
+ 2. Tries to retrieve given file (with url or local path).
91
+ 3. Parses given CSV.
92
+ 4. Filters requested information from CSV.
93
+ 5. Returns enriched input data
94
+
95
+ ## Implementation
96
+
97
+ To run the plugin, you must first create an instance of `CSVImport`. Then, you can call `execute()`.
98
+
99
+ ```typescript
100
+ const config = {
101
+ filepath: 'https://raw.githubusercontent.com/Green-Software-Foundation/if-data/main/cloud-metdata-aws-instances.csv',
102
+ output: ['cpu-tdp', 'tdp'],
103
+ };
104
+ const parametersMetadata = {inputs: {}, outputs: {}};
105
+ const mapping = {};
106
+ const csvImport = CSVImport(config, parametersMetadata, mapping);
107
+
108
+ const result = await csvImport.execute([
109
+ {
110
+ timestamp: '2023-08-06T00:00'
111
+ duration: 3600
112
+ 'cpu/energy': 0.001
113
+ 'cloud/provider': gcp
114
+ 'cloud/region': asia-east
115
+ },
116
+ ]);
117
+ ```
118
+
119
+ ## Example manifest
120
+
121
+ 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` and does not have to be done explicitly by the user. The following is an example manifest that calls `csv-import`:
122
+
123
+ ```yaml
124
+ name: csv-import-demo
125
+ description:
126
+ tags:
127
+ initialize:
128
+ plugins:
129
+ cloud-metadata:
130
+ method: CSVImport
131
+ path: 'builtin'
132
+ config:
133
+ filepath: https://raw.githubusercontent.com/Green-Software-Foundation/if-data/main/region-metadata.csv
134
+ output: '*'
135
+ mapping:
136
+ cloud/region: cloud/area
137
+ tree:
138
+ children:
139
+ child:
140
+ pipeline:
141
+ compute:
142
+ - cloud-metadata
143
+ inputs:
144
+ - timestamp: 2023-08-06T00:00
145
+ duration: 3600
146
+ cloud/provider: Google Cloud
147
+ cloud/area: europe-north1
148
+ ```
149
+
150
+ You can run this example by saving it as `./examples/manifests/csv-import.yml` and executing the following command from the project root:
151
+
152
+ ```sh
153
+ npm i -g @grnsft/if
154
+ if-run --manifest manifests/plugins/csv-import.yml --output manifests/outputs/csv-import
155
+ ```
156
+
157
+ The results will be saved to a new `yaml` file in `manifests/outputs`.
158
+
159
+ ## Errors
160
+
161
+ `CSVImport` exposes five of the IF error classes.
162
+
163
+ ### FetchingFileError
164
+
165
+ 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`.
166
+
167
+ ### ReadFileError
168
+
169
+ 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.
170
+
171
+ ### MissingCSVColumnError
172
+
173
+ This error is caused by `CsvImport` 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.
174
+
175
+ ### CSVParseError
176
+
177
+ 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.
178
+
179
+ ### ConfigError
180
+
181
+ You will receive an error starting `ConfigError: ` if you have not provided the expected configuration data in the plugin's `initialize` block.
182
+
183
+ The required parameters are:
184
+
185
+ - `filepath`: This must be a path to a csv file
186
+ - `output`: this must be a string containing a name or a wildcard character (`"*"`)
187
+
188
+ You can fix this error by checking you are providing valid values for each parameter in the config.
189
+
190
+ For more information on our error classes, please visit [our docs](https://if.greensoftware.foundation/reference/errors)
@@ -2,7 +2,7 @@
2
2
 
3
3
  `csv-lookup` is a generic plugin that enables you to select arbitrary data from a given csv file and add it to your manifest file's `input` data.
4
4
 
5
- You provide path to the target csv file pus some query parameters. The filepath can point to a location on the local filesystem or it can be a URL for an online resource. The query parameters include the column names for the target data you want to return (can be one column name, multiple column names or all column names, indicated using `"*"`), plus the column names and values you want to use as selectors.
5
+ You provide path to the target csv file plus some query parameters. The filepath can point to a location on the local filesystem or it can be a URL for an online resource. The query parameters include the column names for the target data you want to return (can be one column name, multiple column names or all column names, indicated using `"*"`), plus the column names and values you want to use as selectors.
6
6
 
7
7
  For example, for the following CSV:
8
8
 
@@ -33,7 +33,7 @@ Notice that the query parameters are key/value pairs where the key is the column
33
33
  - `query` - an array of key/value pairs where the key is a column name in the target csv and the value is a parameter from inputs
34
34
  - `output` - the columns to grab data from and add to output data - should support wildcard or multiple values.
35
35
 
36
- The plugin also supports data renaming. This means you can grab data from a named column but push it into your manifest file data under another name, for example, maybe we want to grab data from the `processor-name` column int he target csv and add it to the manifest file data as `processor-id` because this is the name expected by some other plugin in your piepline. You can do this by passing comma separated values in arrays.
36
+ The plugin also supports data renaming. This means you can grab data from a named column but push it into your manifest file data under another name, for example, maybe we want to grab data from the `processor-name` column in the target csv and add it to the manifest file data as `processor-id` because this is the name expected by some other plugin in your piepline. You can do this by passing comma separated values in arrays.
37
37
 
38
38
  ```yaml
39
39
  output: ['processor-name': 'processor-id']
@@ -175,25 +175,25 @@ The results will be saved to a new `yaml` file in `manifests/outputs`.
175
175
 
176
176
  ## Errors
177
177
 
178
- Coefficient exposes six of the IF error classes.
178
+ `CSVLookup` exposes six of the IF error classes.
179
179
 
180
180
  ### FetchingFileError
181
181
 
182
182
  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`.
183
183
 
184
- ### ReadFileError,
184
+ ### ReadFileError
185
185
 
186
186
  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.
187
187
 
188
- ### MissingCSVColumnError,
188
+ ### MissingCSVColumnError
189
189
 
190
190
  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.
191
191
 
192
- ### QueryDataNotFoundError,
192
+ ### QueryDataNotFoundError
193
193
 
194
194
  This error is caused by the `CsvLookup` plugin failing to find data that matches your query. Try revising your query parameters.
195
195
 
196
- ### CSVParseError,
196
+ ### CSVParseError
197
197
 
198
198
  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.
199
199
 
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@grnsft/if",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "keywords": [],
9
- "author": {
10
- "name": "Green Software Foundation",
11
- "email": "info@gsf.com"
12
- },
13
- "license": "ISC",
14
- "description": "Impact Framework",
15
- "bugs": {
16
- "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
17
- },
18
- "engines": {
19
- "node": ">=18",
20
- "npm": ">=8"
21
- },
22
- "homepage": "https://greensoftware.foundation",
23
- "dependencies": {}
24
- }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@grnsft/if",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "keywords": [],
9
- "author": {
10
- "name": "Green Software Foundation",
11
- "email": "info@gsf.com"
12
- },
13
- "license": "ISC",
14
- "description": "Impact Framework",
15
- "bugs": {
16
- "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
17
- },
18
- "engines": {
19
- "node": ">=18",
20
- "npm": ">=8"
21
- },
22
- "homepage": "https://greensoftware.foundation",
23
- "dependencies": {}
24
- }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@grnsft/if",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "keywords": [],
9
- "author": {
10
- "name": "Green Software Foundation",
11
- "email": "info@gsf.com"
12
- },
13
- "license": "ISC",
14
- "description": "Impact Framework",
15
- "bugs": {
16
- "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
17
- },
18
- "engines": {
19
- "node": ">=18",
20
- "npm": ">=8"
21
- },
22
- "homepage": "https://greensoftware.foundation",
23
- "dependencies": {}
24
- }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@grnsft/if",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "keywords": [],
9
- "author": {
10
- "name": "Green Software Foundation",
11
- "email": "info@gsf.com"
12
- },
13
- "license": "ISC",
14
- "description": "Impact Framework",
15
- "bugs": {
16
- "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
17
- },
18
- "engines": {
19
- "node": ">=18",
20
- "npm": ">=8"
21
- },
22
- "homepage": "https://greensoftware.foundation",
23
- "dependencies": {}
24
- }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@grnsft/if",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "keywords": [],
9
- "author": {
10
- "name": "Green Software Foundation",
11
- "email": "info@gsf.com"
12
- },
13
- "license": "ISC",
14
- "description": "Impact Framework",
15
- "bugs": {
16
- "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
17
- },
18
- "engines": {
19
- "node": ">=18",
20
- "npm": ">=8"
21
- },
22
- "homepage": "https://greensoftware.foundation",
23
- "dependencies": {}
24
- }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@grnsft/if",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "keywords": [],
9
- "author": {
10
- "name": "Green Software Foundation",
11
- "email": "info@gsf.com"
12
- },
13
- "license": "ISC",
14
- "description": "Impact Framework",
15
- "bugs": {
16
- "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
17
- },
18
- "engines": {
19
- "node": ">=18",
20
- "npm": ">=8"
21
- },
22
- "homepage": "https://greensoftware.foundation",
23
- "dependencies": {}
24
- }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@grnsft/if",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "keywords": [],
9
- "author": {
10
- "name": "Green Software Foundation",
11
- "email": "info@gsf.com"
12
- },
13
- "license": "ISC",
14
- "description": "Impact Framework",
15
- "bugs": {
16
- "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
17
- },
18
- "engines": {
19
- "node": ">=18",
20
- "npm": ">=8"
21
- },
22
- "homepage": "https://greensoftware.foundation",
23
- "dependencies": {}
24
- }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@grnsft/if",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "keywords": [],
9
- "author": {
10
- "name": "Green Software Foundation",
11
- "email": "info@gsf.com"
12
- },
13
- "license": "ISC",
14
- "description": "Impact Framework",
15
- "bugs": {
16
- "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
17
- },
18
- "engines": {
19
- "node": ">=18",
20
- "npm": ">=8"
21
- },
22
- "homepage": "https://greensoftware.foundation",
23
- "dependencies": {}
24
- }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@grnsft/if",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "keywords": [],
9
- "author": {
10
- "name": "Green Software Foundation",
11
- "email": "info@gsf.com"
12
- },
13
- "license": "ISC",
14
- "description": "Impact Framework",
15
- "bugs": {
16
- "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
17
- },
18
- "engines": {
19
- "node": ">=18",
20
- "npm": ">=8"
21
- },
22
- "homepage": "https://greensoftware.foundation",
23
- "dependencies": {}
24
- }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@grnsft/if",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "keywords": [],
9
- "author": {
10
- "name": "Green Software Foundation",
11
- "email": "info@gsf.com"
12
- },
13
- "license": "ISC",
14
- "description": "Impact Framework",
15
- "bugs": {
16
- "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
17
- },
18
- "engines": {
19
- "node": ">=18",
20
- "npm": ">=8"
21
- },
22
- "homepage": "https://greensoftware.foundation",
23
- "dependencies": {}
24
- }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@grnsft/if",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "keywords": [],
9
- "author": {
10
- "name": "Green Software Foundation",
11
- "email": "info@gsf.com"
12
- },
13
- "license": "ISC",
14
- "description": "Impact Framework",
15
- "bugs": {
16
- "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
17
- },
18
- "engines": {
19
- "node": ">=18",
20
- "npm": ">=8"
21
- },
22
- "homepage": "https://greensoftware.foundation",
23
- "dependencies": {}
24
- }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@grnsft/if",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "keywords": [],
9
- "author": {
10
- "name": "Green Software Foundation",
11
- "email": "info@gsf.com"
12
- },
13
- "license": "ISC",
14
- "description": "Impact Framework",
15
- "bugs": {
16
- "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
17
- },
18
- "engines": {
19
- "node": ">=18",
20
- "npm": ">=8"
21
- },
22
- "homepage": "https://greensoftware.foundation",
23
- "dependencies": {}
24
- }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@grnsft/if",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "keywords": [],
9
- "author": {
10
- "name": "Green Software Foundation",
11
- "email": "info@gsf.com"
12
- },
13
- "license": "ISC",
14
- "description": "Impact Framework",
15
- "bugs": {
16
- "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
17
- },
18
- "engines": {
19
- "node": ">=18",
20
- "npm": ">=8"
21
- },
22
- "homepage": "https://greensoftware.foundation",
23
- "dependencies": {}
24
- }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@grnsft/if",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "keywords": [],
9
- "author": {
10
- "name": "Green Software Foundation",
11
- "email": "info@gsf.com"
12
- },
13
- "license": "ISC",
14
- "description": "Impact Framework",
15
- "bugs": {
16
- "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
17
- },
18
- "engines": {
19
- "node": ">=18",
20
- "npm": ">=8"
21
- },
22
- "homepage": "https://greensoftware.foundation",
23
- "dependencies": {}
24
- }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@grnsft/if",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "keywords": [],
9
- "author": {
10
- "name": "Green Software Foundation",
11
- "email": "info@gsf.com"
12
- },
13
- "license": "ISC",
14
- "description": "Impact Framework",
15
- "bugs": {
16
- "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
17
- },
18
- "engines": {
19
- "node": ">=18",
20
- "npm": ">=8"
21
- },
22
- "homepage": "https://greensoftware.foundation",
23
- "dependencies": {}
24
- }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@grnsft/if",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "keywords": [],
9
- "author": {
10
- "name": "Green Software Foundation",
11
- "email": "info@gsf.com"
12
- },
13
- "license": "ISC",
14
- "description": "Impact Framework",
15
- "bugs": {
16
- "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
17
- },
18
- "engines": {
19
- "node": ">=18",
20
- "npm": ">=8"
21
- },
22
- "homepage": "https://greensoftware.foundation",
23
- "dependencies": {}
24
- }