@grnsft/if 0.1.9 → 0.2.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 (176) hide show
  1. package/.commitlintrc.js +45 -0
  2. package/.husky/commit-msg +4 -0
  3. package/.husky/pre-commit +6 -0
  4. package/CONTRIBUTING.md +81 -98
  5. package/README.md +16 -12
  6. package/build/config/config.d.ts +4 -3
  7. package/build/config/config.js +11 -10
  8. package/build/config/params.js +17 -17
  9. package/build/config/strings.d.ts +9 -8
  10. package/build/config/strings.js +13 -12
  11. package/build/index.js +19 -69
  12. package/build/lib/aggregate.d.ts +6 -0
  13. package/build/lib/aggregate.js +72 -0
  14. package/build/lib/compute.d.ts +5 -0
  15. package/build/lib/compute.js +84 -0
  16. package/build/lib/exhaust.d.ts +6 -0
  17. package/build/lib/exhaust.js +47 -0
  18. package/build/lib/initialize.d.ts +6 -0
  19. package/build/lib/initialize.js +98 -0
  20. package/build/lib/load.d.ts +6 -0
  21. package/build/lib/load.js +24 -0
  22. package/build/lib/parameterize.d.ts +5 -0
  23. package/build/lib/parameterize.js +49 -0
  24. package/build/models/export-csv.d.ts +2 -0
  25. package/build/models/export-csv.js +129 -0
  26. package/build/models/export-log.d.ts +4 -0
  27. package/build/models/export-log.js +18 -0
  28. package/build/models/export-yaml.d.ts +4 -0
  29. package/build/models/export-yaml.js +24 -0
  30. package/build/models/group-by.d.ts +11 -0
  31. package/build/models/group-by.js +56 -0
  32. package/build/models/index.d.ts +2 -1
  33. package/build/models/index.js +5 -3
  34. package/build/models/time-sync.d.ts +2 -57
  35. package/build/models/time-sync.js +204 -158
  36. package/build/types/aggregation.js +5 -0
  37. package/build/types/compute.d.ts +25 -0
  38. package/build/types/compute.js +3 -0
  39. package/build/types/exhaust-plugin-interface.d.ts +7 -0
  40. package/build/types/exhaust-plugin-interface.js +3 -0
  41. package/build/types/group-by.d.ts +3 -0
  42. package/build/types/group-by.js +3 -0
  43. package/build/types/initialize.d.ts +4 -0
  44. package/build/types/initialize.js +3 -0
  45. package/build/types/interface.d.ts +8 -0
  46. package/build/types/interface.js +3 -0
  47. package/build/types/load.d.ts +7 -0
  48. package/build/types/load.js +3 -0
  49. package/build/types/manifest.d.ts +40 -0
  50. package/build/types/manifest.js +3 -0
  51. package/build/types/parameters.d.ts +4 -5
  52. package/build/types/parameters.js +1 -1
  53. package/build/types/process-args.d.ts +3 -5
  54. package/build/types/process-args.js +1 -1
  55. package/build/types/time-sync.d.ts +9 -2
  56. package/build/types/time-sync.js +1 -1
  57. package/build/util/aggregation-helper.d.ts +6 -0
  58. package/build/util/aggregation-helper.js +56 -0
  59. package/build/util/args.d.ts +6 -3
  60. package/build/util/args.js +21 -17
  61. package/build/util/errors.d.ts +1 -1
  62. package/build/util/errors.js +8 -4
  63. package/build/util/helpers.d.ts +4 -0
  64. package/build/util/helpers.js +23 -4
  65. package/build/util/json.d.ts +4 -0
  66. package/build/util/json.js +16 -0
  67. package/build/util/logger.d.ts +5 -0
  68. package/build/util/logger.js +40 -0
  69. package/build/util/validations.d.ts +22 -19
  70. package/build/util/validations.js +41 -34
  71. package/examples/{impls/test → manifests}/azure-importer.yml +8 -8
  72. package/examples/manifests/basic-demo.yml +75 -0
  73. package/examples/manifests/basic.yml +27 -0
  74. package/examples/manifests/boavizta-pipeline.yml +85 -0
  75. package/examples/{impls/test → manifests}/boavizta.yml +11 -12
  76. package/examples/{impls/test → manifests}/ccf.yml +9 -10
  77. package/examples/manifests/cim.yml +20 -0
  78. package/examples/manifests/cloud-metadata.yml +41 -0
  79. package/examples/manifests/co2js.yml +30 -0
  80. package/examples/manifests/coefficient.yml +23 -0
  81. package/examples/manifests/csv-export.yml +34 -0
  82. package/examples/manifests/e-mem.yml +21 -0
  83. package/examples/{impls/test → manifests}/e-net.yml +9 -8
  84. package/examples/manifests/generics.yml +71 -0
  85. package/examples/manifests/group-by.yml +48 -0
  86. package/examples/manifests/mock-observation.yml +33 -0
  87. package/examples/manifests/multiply.yml +23 -0
  88. package/examples/manifests/nesting-demo.yml +89 -0
  89. package/examples/manifests/nesting.yml +215 -0
  90. package/examples/manifests/pipeline-demo-1.yml +85 -0
  91. package/examples/manifests/pipeline-demo-2.yml +149 -0
  92. package/examples/manifests/pipeline-demo.yml +128 -0
  93. package/examples/manifests/pipeline-teads-sci.yml +82 -0
  94. package/examples/manifests/pipeline-with-generics.yml +147 -0
  95. package/examples/manifests/pipeline-with-mocks.yml +146 -0
  96. package/examples/{impls/test → manifests}/sci-e.yml +6 -8
  97. package/examples/manifests/sci-m.yml +23 -0
  98. package/examples/{impls/test → manifests}/sci-o.yml +10 -10
  99. package/examples/{impls/test → manifests}/sci.yml +10 -9
  100. package/examples/manifests/shell.yml +20 -0
  101. package/examples/manifests/sum.yml +23 -0
  102. package/examples/{impls/test → manifests}/tdp-finder.yml +6 -7
  103. package/examples/manifests/teads-aws.yml +22 -0
  104. package/examples/manifests/teads-curve.yml +20 -0
  105. package/examples/manifests/time-sync.yml +32 -0
  106. package/examples/manifests/watt-time.yml +42 -0
  107. package/jest.config.js +6 -1
  108. package/package.json +13 -8
  109. package/src/__tests__/integration/templates/integration.yaml +16 -0
  110. package/src/models/README.md +6 -6
  111. package/tsconfig.test.json +1 -1
  112. package/Makefile +0 -16
  113. package/build/lib/aggregator.d.ts +0 -7
  114. package/build/lib/aggregator.js +0 -46
  115. package/build/lib/models-universe.d.ts +0 -40
  116. package/build/lib/models-universe.js +0 -145
  117. package/build/lib/observatory.d.ts +0 -20
  118. package/build/lib/observatory.js +0 -31
  119. package/build/lib/supercomputer.d.ts +0 -39
  120. package/build/lib/supercomputer.js +0 -116
  121. package/build/types/aggregator.js +0 -5
  122. package/build/types/impl.d.ts +0 -92
  123. package/build/types/impl.js +0 -19
  124. package/build/types/model-interface.d.ts +0 -13
  125. package/build/types/model-interface.js +0 -3
  126. package/build/types/models-universe.d.ts +0 -20
  127. package/build/types/models-universe.js +0 -3
  128. package/build/types/supercomputer.d.ts +0 -4
  129. package/build/types/supercomputer.js +0 -3
  130. package/build/util/param-selectors.d.ts +0 -5
  131. package/build/util/param-selectors.js +0 -14
  132. package/examples/impls/case-studies/accenture.yml +0 -155
  133. package/examples/impls/case-studies/aggregation.yml +0 -97
  134. package/examples/impls/case-studies/aveva.yaml +0 -48
  135. package/examples/impls/case-studies/azure-yassine.yaml +0 -67
  136. package/examples/impls/case-studies/boavizta.yml +0 -26
  137. package/examples/impls/case-studies/dow_msft.yml +0 -173
  138. package/examples/impls/case-studies/farm-insights.yaml +0 -35
  139. package/examples/impls/case-studies/gsf-website.yaml +0 -93
  140. package/examples/impls/case-studies/msft-eshoppen.yaml +0 -162
  141. package/examples/impls/case-studies/msft-green-ai.yaml +0 -58
  142. package/examples/impls/case-studies/ntt-data-on-premise.yaml +0 -201
  143. package/examples/impls/test/aggregation-test.yml +0 -109
  144. package/examples/impls/test/aggregation-test2.yml +0 -52
  145. package/examples/impls/test/cim.yml +0 -19
  146. package/examples/impls/test/e-mem.yml +0 -19
  147. package/examples/impls/test/if-demo.yml +0 -59
  148. package/examples/impls/test/large-impl.yml +0 -257303
  149. package/examples/impls/test/metadata.yml +0 -21
  150. package/examples/impls/test/nesting.yml +0 -113
  151. package/examples/impls/test/new-params-test.yml +0 -35
  152. package/examples/impls/test/sci-m.yml +0 -24
  153. package/examples/impls/test/shell.yml +0 -19
  154. package/examples/impls/test/teads-cpu.yml +0 -18
  155. package/examples/impls/test/time-sync-avoid-padding.yml +0 -50
  156. package/examples/impls/test/time-sync.yml +0 -76
  157. package/examples/ompls/aggregation-test.yml +0 -340
  158. package/examples/ompls/aggregation-test2.yml +0 -83
  159. package/examples/ompls/azure-importer.yml +0 -145
  160. package/examples/ompls/boavizta.yml +0 -32
  161. package/examples/ompls/ccf.yml +0 -29
  162. package/examples/ompls/cim.yml +0 -29
  163. package/examples/ompls/complex-pipeline.yml +0 -105
  164. package/examples/ompls/e-mem.yml +0 -26
  165. package/examples/ompls/full-sci.yml +0 -64
  166. package/examples/ompls/if-demo.yml +0 -517
  167. package/examples/ompls/metadata.yml +0 -29
  168. package/examples/ompls/nesting.yml +0 -113
  169. package/examples/ompls/sci-e.yml +0 -23
  170. package/examples/ompls/sci-m.yml +0 -33
  171. package/examples/ompls/sci-o.yml +0 -29
  172. package/examples/ompls/sci.yml +0 -37
  173. package/examples/ompls/shell.yml +0 -23
  174. package/examples/ompls/teads-cpu.yml +0 -24
  175. package/examples/ompls/time-sync.yml +0 -212
  176. /package/build/types/{aggregator.d.ts → aggregation.d.ts} +0 -0
@@ -2,16 +2,16 @@ name: sci-o-demo
2
2
  description:
3
3
  tags:
4
4
  initialize:
5
- models:
6
- - name: sci-e
5
+ plugins:
6
+ sci-e:
7
7
  kind: plugin
8
- model: SciEModel
9
- path: "@grnsft/if-models"
10
- - name: sci-o
8
+ method: SciE
9
+ path: "@grnsft/if-plugins"
10
+ sci-o:
11
11
  verbose: false
12
- model: SciOModel
13
- path: "@grnsft/if-models"
14
- graph:
12
+ method: SciO
13
+ path: "@grnsft/if-plugins"
14
+ tree:
15
15
  children:
16
16
  child:
17
17
  pipeline:
@@ -22,5 +22,5 @@ graph:
22
22
  inputs:
23
23
  - timestamp: 2023-08-06T00:00
24
24
  duration: 3600
25
- energy-cpu: 0.001
26
- grid-carbon-intensity: 800
25
+ cpu/energy: 0.001
26
+ grid/carbon-intensity: 800
@@ -2,25 +2,26 @@ name: sci-demo
2
2
  description: example invoking sci model
3
3
  tags:
4
4
  initialize:
5
- models:
6
- - name: sci
5
+ plugins:
6
+ sci:
7
7
  kind: plugin
8
- model: SciModel
9
- path: "@grnsft/if-models"
10
- graph:
8
+ method: Sci
9
+ path: "@grnsft/if-plugins"
10
+ # global-config:
11
+ # functional-unit-time: 1 minute
12
+ tree:
11
13
  children:
12
14
  child:
13
15
  pipeline:
14
16
  - sci
15
17
  config:
16
18
  sci:
17
- functional-unit-time: 1 minute
18
- functional-duration-time: ""
19
+ functional-unit-time: 1 sec
19
20
  functional-unit: requests # factor to convert per time to per f.unit
20
21
  inputs:
21
22
  - timestamp: 2023-07-06T00:00
22
23
  duration: 3600
23
24
  energy: 5
24
- operational-carbon: 5
25
- embodied-carbon: 0.02
25
+ carbon-operational: 5
26
+ carbon-embodied: 0.02
26
27
  requests: 100
@@ -0,0 +1,20 @@
1
+ name: shell-demo
2
+ description: example impl invoking shell model
3
+ tags:
4
+ initialize:
5
+ plugins:
6
+ shell:
7
+ method: Shell
8
+ path: "@grnsft/if-plugins"
9
+ global-config:
10
+ command: python3 /usr/local/bin/sampler
11
+ tree:
12
+ children:
13
+ child:
14
+ pipeline:
15
+ - shell
16
+ inputs:
17
+ - timestamp: "2023-11-02T10:35:31.820Z"
18
+ duration: 3600
19
+ cpu/energy: 0.002
20
+ memory/energy: 0.000005
@@ -0,0 +1,23 @@
1
+ name: sci-e-demo
2
+ description:
3
+ tags:
4
+ initialize:
5
+ plugins:
6
+ sum:
7
+ method: Sum
8
+ path: "@grnsft/if-plugins"
9
+ global-config:
10
+ input-parameters: ["cpu/energy", "network/energy"]
11
+ output-parameter: "energy"
12
+ tree:
13
+ children:
14
+ child:
15
+ pipeline:
16
+ - sum
17
+ config:
18
+ sum:
19
+ inputs:
20
+ - timestamp: 2023-08-06T00:00
21
+ duration: 3600
22
+ cpu/energy: 0.001
23
+ network/energy: 0.001
@@ -2,18 +2,17 @@ name: tdp-finder
2
2
  description: demo
3
3
  tags:
4
4
  initialize:
5
- models:
6
- - name: tdp-finder # a model that returns an embodied value given the sci embodied attribution equation.
7
- model: TdpFinderModel
8
- path: "@grnsft/if-models"
9
- graph:
5
+ plugins:
6
+ tdp-finder: # a model that returns an embodied value given the sci embodied attribution equation.
7
+ method: TdpFinder
8
+ path: "@grnsft/if-plugins"
9
+ tree:
10
10
  children:
11
11
  child:
12
- pipeline:
12
+ pipeline:
13
13
  - tdp-finder
14
14
  config:
15
15
  inputs:
16
16
  - timestamp: 2023-07-06T00:00
17
17
  duration: 300
18
18
  physical-processor: AMD 3020e
19
-
@@ -0,0 +1,22 @@
1
+ name: teads-aws
2
+ description: simple demo invoking TeadsAWS model
3
+ tags:
4
+ initialize:
5
+ plugins:
6
+ teads-aws:
7
+ method: TeadsAWS
8
+ path: "@grnsft/if-unofficial-plugins"
9
+ global-config:
10
+ interpolation: linear
11
+ tree:
12
+ children:
13
+ child:
14
+ pipeline:
15
+ - teads-aws # duration & config -> embodied
16
+ defaults:
17
+ cloud/instance-type: m5n.large
18
+ cpu/expected-lifespan: 252288000
19
+ inputs:
20
+ - timestamp: 2023-07-06T00:00
21
+ duration: 3600
22
+ cpu/utilization: 10
@@ -0,0 +1,20 @@
1
+ name: teads-curve
2
+ description: simple demo invoking teads-curve
3
+ tags:
4
+ initialize:
5
+ plugins:
6
+ teads-curve:
7
+ method: TeadsCurve
8
+ path: "@grnsft/if-unofficial-plugins"
9
+ global-config:
10
+ interpolation: spline
11
+ tree:
12
+ children:
13
+ child:
14
+ pipeline:
15
+ - teads-curve
16
+ inputs:
17
+ - timestamp: 2023-07-06T00:00
18
+ duration: 3600
19
+ cpu/utilization: 50
20
+ cpu/thermal-design-power: 100
@@ -0,0 +1,32 @@
1
+ name: time-sync-demo
2
+ description:
3
+ tags:
4
+ initialize:
5
+ plugins:
6
+ 'time-sync':
7
+ method: TimeSync
8
+ path: "builtin"
9
+ global-config:
10
+ start-time: '2023-12-12T00:00:00.000Z'
11
+ end-time: '2023-12-12T00:01:00.000Z'
12
+ interval: 5
13
+ allow-padding: true
14
+ tree:
15
+ children:
16
+ child:
17
+ pipeline:
18
+ - time-sync
19
+ config:
20
+ inputs:
21
+ - timestamp: '2023-12-12T00:00:00.000Z'
22
+ duration: 1
23
+ energy-cpu: 0.001
24
+ - timestamp: '2023-12-12T00:00:01.000Z'
25
+ duration: 5
26
+ energy-cpu: 0.001
27
+ - timestamp: '2023-12-12T00:00:06.000Z'
28
+ duration: 7
29
+ energy-cpu: 0.001
30
+ - timestamp: '2023-12-12T00:00:13.000Z'
31
+ duration: 30
32
+ energy-cpu: 0.001
@@ -0,0 +1,42 @@
1
+ name: watt-time-demo
2
+ description: null
3
+ tags: null
4
+ initialize:
5
+ plugins:
6
+ mock-observations:
7
+ path: "@grnsft/if-plugins"
8
+ method: MockObservations
9
+ global-config:
10
+ timestamp-from: 2024-02-26T00:00
11
+ timestamp-to: 2024-02-26T00:10
12
+ duration: 60
13
+ components:
14
+ - cloud/instance-type: Standard_A1_v2
15
+ - cloud/instance-type: Standard_A2_v2
16
+ generators:
17
+ common:
18
+ cloud/vendor: azure
19
+ cloud/region: uk-west
20
+ geolocation: 37.7749,-122.4194
21
+ randint:
22
+ cpu/utilization:
23
+ min: 1
24
+ max: 99
25
+ watttime:
26
+ path: "@grnsft/if-unofficial-plugins"
27
+ method: WattTimeGridEmissions
28
+ tree:
29
+ children:
30
+ application:
31
+ pipeline:
32
+ - mock-observations
33
+ - watttime
34
+ config:
35
+ inputs:
36
+ - timestamp: "2024-02-26 00:00:00"
37
+ duration: 60
38
+ cloud/instance-type: Standard_A1_v2
39
+ cloud/vendor: azure
40
+ cloud/region: uk-west
41
+ geolocation: 37.7749,-122.4194
42
+ cpu/utilization: 15
package/jest.config.js CHANGED
@@ -10,5 +10,10 @@ module.exports = {
10
10
  },
11
11
  ],
12
12
  },
13
- modulePathIgnorePatterns: ['./build', './src/__tests__/unit/lib/impls'],
13
+ modulePathIgnorePatterns: [
14
+ './build',
15
+ './src/__tests__/unit/lib/manifest',
16
+ './src/__tests__/integration/helpers',
17
+ './src/__tests__/integration/test-data',
18
+ ],
14
19
  };
package/package.json CHANGED
@@ -1,24 +1,25 @@
1
1
  {
2
2
  "name": "@grnsft/if",
3
3
  "description": "Impact Framework",
4
- "version": "v0.1.9",
4
+ "version": "v0.2.0",
5
5
  "author": {
6
6
  "name": "Green Software Foundation",
7
7
  "email": "info@gsf.com"
8
8
  },
9
9
  "bin": {
10
- "impact-engine": "./build/index.js"
10
+ "if": "./build/index.js"
11
11
  },
12
12
  "bugs": {
13
13
  "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
14
14
  },
15
15
  "dependencies": {
16
- "copyfiles": "^2.4.1",
16
+ "@commitlint/cli": "^18.6.0",
17
+ "@commitlint/config-conventional": "^18.6.0",
17
18
  "js-yaml": "^4.1.0",
18
- "moment": "^2.29.4",
19
- "moment-range": "^4.0.2",
19
+ "luxon": "^3.4.4",
20
20
  "ts-command-line-args": "^2.5.1",
21
21
  "typescript": "^5.1.6",
22
+ "winston": "^3.11.0",
22
23
  "zod": "^3.22.4"
23
24
  },
24
25
  "devDependencies": {
@@ -27,9 +28,11 @@
27
28
  "@jest/globals": "^29.6.1",
28
29
  "@types/jest": "^29.5.7",
29
30
  "@types/js-yaml": "^4.0.5",
31
+ "@types/luxon": "^3.4.2",
30
32
  "@types/node": "^20.8.9",
31
33
  "fixpack": "^4.0.0",
32
34
  "gts": "^5.0.0",
35
+ "husky": "^8.0.0",
33
36
  "jest": "^29.6.1",
34
37
  "ts-jest": "^29.1.1"
35
38
  },
@@ -55,14 +58,16 @@
55
58
  "url": "https://github.com/Green-Software-Foundation/if"
56
59
  },
57
60
  "scripts": {
58
- "build": "rm -rf build && tsc --project tsconfig.build.json && copyfiles -u 2 src/config/units.yaml build/config",
61
+ "build": "rm -rf build && tsc --project tsconfig.build.json",
59
62
  "coverage": "jest --verbose --coverage",
60
63
  "fix": "gts fix",
61
64
  "fix:package": "fixpack",
62
- "impact-engine": "npx ts-node src/index.ts",
65
+ "if": "npx ts-node src/index.ts",
63
66
  "lint": "gts lint",
67
+ "prepare": "husky install",
64
68
  "prepublish": "npm run build",
65
- "test": "jest --verbose"
69
+ "test": "jest --verbose --testPathPattern=src/__tests__/unit",
70
+ "test:integration": "jest --verbose --testPathPattern=src/__tests__/integration"
66
71
  },
67
72
  "stability": "stable",
68
73
  "types": "src/index.d.ts"
@@ -0,0 +1,16 @@
1
+ name: integration-template
2
+ description:
3
+ tags:
4
+ initialize:
5
+ plugins:
6
+ 'sci-e':
7
+ model: ${model}
8
+ path: ${path}
9
+ tree:
10
+ children:
11
+ child:
12
+ pipeline:
13
+ - ${name}
14
+ config:
15
+ inputs:
16
+ - ${input}
@@ -201,8 +201,8 @@ const results = timeSyncModel.execute([
201
201
 
202
202
  IEF users will typically call the model as part of a pipeline defined in an `impl`
203
203
  file. In this case, instantiating and configuring the model is handled by
204
- `impact-engine` and does not have to be done explicitly by the user.
205
- The following is an example `impl` that calls `time-sync`:
204
+ `if` and does not have to be done explicitly by the user.
205
+ The following is an example `manifest` that calls `time-sync`:
206
206
 
207
207
  ```yaml
208
208
  name: time-sync-demo
@@ -212,16 +212,16 @@ initialize:
212
212
  models:
213
213
  - name: teads-curve
214
214
  model: TeadsCurveModel
215
- path: "@grnsft/if-unofficial-models"
215
+ path: "@grnsft/if-unofficial-plugins"
216
216
  - name: sci-e
217
217
  model: SciEModel
218
- path: "@grnsft/if-models"
218
+ path: "@grnsft/if-plugins"
219
219
  - name: sci-m
220
- path: "@grnsft/if-models"
220
+ path: "@grnsft/if-plugins"
221
221
  model: SciMModel
222
222
  - name: sci-o
223
223
  model: SciOModel
224
- path: "@grnsft/if-models"
224
+ path: "@grnsft/if-plugins"
225
225
  - name: time-synchronization
226
226
  model: TimeSyncModel
227
227
  path: builtin
@@ -9,7 +9,7 @@
9
9
  "experimentalDecorators": true,
10
10
  "incremental": true,
11
11
  "lib": [
12
- "es2020"
12
+ "ES2021"
13
13
  ],
14
14
  "module": "CommonJS",
15
15
  "noEmitOnError": true,
package/Makefile DELETED
@@ -1,16 +0,0 @@
1
-
2
-
3
- #Converts the CSV files from CCF Coefficients Database to JSON.
4
- ccf-data:
5
- cat third-party/ccf-coefficients/data/aws-instances.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > lib/ccf/aws-instances.json
6
- cat third-party/ccf-coefficients/output/coefficients-aws-use.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > lib/ccf/aws-use.json
7
- cat third-party/ccf-coefficients/output/coefficients-aws-embodied.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > lib/ccf/aws-embodied.json
8
- cat third-party/ccf-coefficients/data/gcp-instances.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > lib/ccf/gcp-instances.json
9
- cat third-party/ccf-coefficients/output/coefficients-gcp-use.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > lib/ccf/gcp-use.json
10
- cat third-party/ccf-coefficients/output/coefficients-gcp-embodied.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > lib/ccf/gcp-embodied.json
11
- cat third-party/ccf-coefficients/data/azure-instances.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > lib/ccf/azure-instances.json
12
- cat third-party/ccf-coefficients/output/coefficients-azure-use.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > lib/ccf/azure-use.json
13
- cat third-party/ccf-coefficients/output/coefficients-azure-embodied.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > lib/ccf/azure-embodied.json
14
-
15
- install-shell-imp:
16
- cp src/lib/shell-imp/sampler /usr/local/bin/sampler
@@ -1,7 +0,0 @@
1
- import { ModelParams } from '../types/model-interface';
2
- import { Parameters } from '../types/parameters';
3
- /**
4
- * Aggregates child node level metrics. Validates if metric aggregation type is `none`, then rejects with error.
5
- * Otherwise iterates over inputs by aggregating per given `metrics`.
6
- */
7
- export declare const aggregate: (inputs: ModelParams[], metrics: string[], parameters: Parameters) => ModelParams;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.aggregate = void 0;
4
- const errors_1 = require("../util/errors");
5
- const param_selectors_1 = require("../util/param-selectors");
6
- const config_1 = require("../config");
7
- const { InvalidAggregationParams } = errors_1.ERRORS;
8
- const { INVALID_AGGREGATION_METHOD, METRIC_MISSING } = config_1.STRINGS;
9
- /**
10
- * Validates metrics array before applying aggregator.
11
- * If aggregation method is `none`, then throws error.
12
- */
13
- const checkIfMetricsAreValid = (metrics, parameters) => {
14
- metrics.forEach(metric => {
15
- const method = (0, param_selectors_1.getAggregationMethod)(metric, parameters);
16
- if (method === 'none') {
17
- throw new InvalidAggregationParams(INVALID_AGGREGATION_METHOD(method));
18
- }
19
- });
20
- };
21
- /**
22
- * Aggregates child node level metrics. Validates if metric aggregation type is `none`, then rejects with error.
23
- * Otherwise iterates over inputs by aggregating per given `metrics`.
24
- */
25
- const aggregate = (inputs, metrics, parameters) => {
26
- checkIfMetricsAreValid(metrics, parameters);
27
- return inputs.reduce((acc, input, index) => {
28
- for (const metric of metrics) {
29
- if (!(metric in input)) {
30
- throw new InvalidAggregationParams(METRIC_MISSING(metric, index));
31
- }
32
- const accessKey = `aggregated-${metric}`;
33
- acc[accessKey] = acc[accessKey] ?? 0;
34
- acc[accessKey] += parseFloat(input[metric]);
35
- /** Checks for the last iteration. */
36
- if (index === inputs.length - 1) {
37
- if ((0, param_selectors_1.getAggregationMethod)(metric, parameters) === 'avg') {
38
- acc[accessKey] /= inputs.length;
39
- }
40
- }
41
- }
42
- return acc;
43
- }, {});
44
- };
45
- exports.aggregate = aggregate;
46
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWdncmVnYXRvci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvYWdncmVnYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwyQ0FBc0M7QUFDdEMsNkRBQTZEO0FBRTdELHNDQUFrQztBQU1sQyxNQUFNLEVBQUMsd0JBQXdCLEVBQUMsR0FBRyxlQUFNLENBQUM7QU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ldGVycyk7XG5cbiAgcmV0dXJuIGlucHV0cy5yZWR1Y2UoKGFjYywgaW5wdXQsIGluZGV4KSA9PiB7XG4gICAgZm9yIChjb25zdCBtZXRyaWMgb2YgbWV0cmljcykge1xuICAgICAgaWYgKCEobWV0cmljIGluIGlucHV0KSkge1xuICAgICAgICB0aHJvdyBuZXcgSW52YWxpZEFnZ3JlZ2F0aW9uUGFyYW1zKE1FVFJJQ19NSVNTSU5HKG1ldHJpYywgaW5kZXgpKTtcbiAgICAgIH1cblxuICAgICAgY29uc3QgYWNjZXNzS2V5ID0gYGFnZ3JlZ2F0ZWQtJHttZXRyaWN9YDtcbiAgICAgIGFjY1thY2Nlc3NLZXldID0gYWNjW2FjY2Vzc0tleV0gPz8gMDtcbiAgICAgIGFjY1thY2Nlc3NLZXldICs9IHBhcnNlRmxvYXQoaW5wdXRbbWV0cmljXSk7XG5cbiAgICAgIC8qKiBDaGVja3MgZm9yIHRoZSBsYXN0IGl0ZXJhdGlvbi4gKi9cbiAgICAgIGlmIChpbmRleCA9PT0gaW5wdXRzLmxlbmd0aCAtIDEpIHtcbiAgICAgICAgaWYgKGdldEFnZ3JlZ2F0aW9uTWV0aG9kKG1ldHJpYywgcGFyYW1ldGVycykgPT09ICdhdmcnKSB7XG4gICAgICAgICAgYWNjW2FjY2Vzc0tleV0gLz0gaW5wdXRzLmxlbmd0aDtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cblxuICAgIHJldHVybiBhY2M7XG4gIH0sIHt9IGFzIEFnZ3JlZ2F0aW9uUmVzdWx0KTtcbn07XG4iXX0=
@@ -1,40 +0,0 @@
1
- import { ImplInitializeModel, InitalizedModels } from '../types/models-universe';
2
- /**
3
- * Models Initialization Lifecycle.
4
- */
5
- export declare class ModelsUniverse {
6
- /**
7
- * Models list.
8
- */
9
- initalizedModels: InitalizedModels;
10
- /**
11
- * Checks if model is instance of `IOutputModelInterface`.
12
- */
13
- private instanceOfModel;
14
- /**
15
- * Imports module by given `path`.
16
- */
17
- private importModuleFrom;
18
- /**
19
- * Imports `module` from given `path`, then checks if it's `ModelPluginInterface` extension.
20
- */
21
- private importAndVerifyModule;
22
- /**
23
- * Returns plugin model. Checks if model is missing then rejects with error.
24
- * Then checks if `path` is starting with github, then grabs the repository name.
25
- * Imports module, then checks if it's a class which implements input model interface.
26
- */
27
- private handModel;
28
- /**
29
- * Registers all models from `impl`.`initalize` property.
30
- */
31
- bulkWriteDown(modelsToInitalize: ImplInitializeModel[]): Promise<this>;
32
- /**
33
- * Initializes and registers model.
34
- */
35
- private writeDownSingleModel;
36
- /**
37
- * Returns existing model by `name`.
38
- */
39
- getInitializedModel(modelName: string, config: any): Promise<import("../types/model-interface").ModelPluginInterface>;
40
- }