@grnsft/if 0.5.0 → 0.6.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -17
- package/Refactor-migration-guide.md +110 -164
- package/build/common/config/index.d.ts +1 -0
- package/build/common/config/index.js +6 -0
- package/build/common/config/strings.d.ts +8 -0
- package/build/common/config/strings.js +16 -0
- package/build/common/lib/load.d.ts +6 -0
- package/build/common/lib/load.js +18 -0
- package/build/{types → common/types}/manifest.d.ts +4 -1
- package/build/common/types/manifest.js +3 -0
- package/build/common/util/debug-logger.js +115 -0
- package/build/common/util/fs.js +94 -0
- package/build/common/util/helpers.d.ts +15 -0
- package/build/common/util/helpers.js +80 -0
- package/build/{util → common/util}/logger.js +1 -1
- package/build/{util → common/util}/validations.d.ts +149 -47
- package/build/common/util/validations.js +141 -0
- package/build/common/util/yaml.js +59 -0
- package/build/if-check/config/config.d.ts +6 -0
- package/build/if-check/config/config.js +31 -0
- package/build/{config → if-check/config}/index.d.ts +0 -1
- package/build/if-check/config/index.js +8 -0
- package/build/if-check/config/strings.d.ts +12 -0
- package/build/if-check/config/strings.js +16 -0
- package/build/if-check/index.js +98 -0
- package/build/if-check/types/process-args.d.ts +4 -0
- package/build/if-check/types/process-args.js +3 -0
- package/build/if-check/util/args.d.ts +10 -0
- package/build/if-check/util/args.js +56 -0
- package/build/if-check/util/helpers.d.ts +4 -0
- package/build/if-check/util/helpers.js +18 -0
- package/build/if-check/util/npm.d.ts +4 -0
- package/build/if-check/util/npm.js +59 -0
- package/build/if-csv/config/config.d.ts +6 -0
- package/build/if-csv/config/config.js +37 -0
- package/build/if-csv/config/index.d.ts +2 -0
- package/build/if-csv/config/index.js +8 -0
- package/build/if-csv/config/strings.d.ts +4 -0
- package/build/if-csv/config/strings.js +8 -0
- package/build/if-csv/index.js +63 -0
- package/build/if-csv/types/csv.d.ts +7 -0
- package/build/if-csv/types/csv.js +3 -0
- package/build/if-csv/types/process-args.d.ts +5 -0
- package/build/if-csv/types/process-args.js +3 -0
- package/build/if-csv/util/args.d.ts +12 -0
- package/build/if-csv/util/args.js +51 -0
- package/build/if-csv/util/helpers.d.ts +9 -0
- package/build/if-csv/util/helpers.js +95 -0
- package/build/if-diff/config/config.d.ts +6 -0
- package/build/if-diff/config/config.js +31 -0
- package/build/if-diff/config/index.d.ts +2 -0
- package/build/if-diff/config/index.js +8 -0
- package/build/if-diff/config/strings.d.ts +6 -0
- package/build/if-diff/config/strings.js +10 -0
- package/build/if-diff/index.js +46 -0
- package/build/{lib → if-diff/lib}/compare.d.ts +1 -1
- package/build/if-diff/lib/compare.js +56 -0
- package/build/{lib → if-diff/lib}/load.d.ts +16 -18
- package/build/if-diff/lib/load.js +51 -0
- package/build/if-diff/types/args.js +3 -0
- package/build/if-diff/types/compare.js +3 -0
- package/build/if-diff/types/process-args.d.ts +4 -0
- package/build/if-diff/types/process-args.js +3 -0
- package/build/if-diff/util/args.d.ts +5 -0
- package/build/if-diff/util/args.js +51 -0
- package/build/if-diff/util/helpers.d.ts +13 -0
- package/build/if-diff/util/helpers.js +75 -0
- package/build/if-env/config/config.d.ts +6 -0
- package/build/if-env/config/config.js +37 -0
- package/build/if-env/config/index.d.ts +2 -0
- package/build/if-env/config/index.js +8 -0
- package/build/if-env/config/strings.d.ts +7 -0
- package/build/if-env/config/strings.js +11 -0
- package/build/if-env/index.js +40 -0
- package/build/if-env/types/if-env.js +3 -0
- package/build/if-env/types/npm.js +3 -0
- package/build/if-env/types/process-args.d.ts +5 -0
- package/build/if-env/types/process-args.js +3 -0
- package/build/if-env/util/args.d.ts +12 -0
- package/build/if-env/util/args.js +47 -0
- package/build/if-env/util/helpers.d.ts +20 -0
- package/build/if-env/util/helpers.js +94 -0
- package/build/{util → if-env/util}/npm.d.ts +0 -4
- package/build/if-env/util/npm.js +126 -0
- package/build/if-run/builtins/coefficient/index.d.ts +2 -0
- package/build/if-run/builtins/coefficient/index.js +67 -0
- package/build/if-run/builtins/copy-param/index.d.ts +2 -0
- package/build/if-run/builtins/copy-param/index.js +70 -0
- package/build/if-run/builtins/csv-lookup/index.d.ts +2 -0
- package/build/if-run/builtins/csv-lookup/index.js +190 -0
- package/build/if-run/builtins/divide/index.d.ts +2 -0
- package/build/if-run/builtins/divide/index.js +80 -0
- package/build/if-run/builtins/exponent/index.d.ts +2 -0
- package/build/if-run/builtins/exponent/index.js +60 -0
- package/build/{builtins → if-run/builtins}/export-log.d.ts +1 -1
- package/build/{builtins → if-run/builtins}/export-log.js +1 -1
- package/build/{builtins → if-run/builtins}/export-yaml.d.ts +1 -1
- package/build/if-run/builtins/export-yaml.js +30 -0
- package/build/{builtins → if-run/builtins}/index.d.ts +1 -2
- package/build/{builtins → if-run/builtins}/index.js +4 -6
- package/build/if-run/builtins/interpolation/index.d.ts +2 -0
- package/build/if-run/builtins/interpolation/index.js +151 -0
- package/build/if-run/builtins/mock-observations/helpers/common-generator.js +29 -0
- package/build/if-run/builtins/mock-observations/helpers/rand-int-generator.js +48 -0
- package/build/if-run/builtins/mock-observations/index.d.ts +2 -0
- package/build/if-run/builtins/mock-observations/index.js +116 -0
- package/build/if-run/builtins/mock-observations/interfaces/index.js +3 -0
- package/build/if-run/builtins/multiply/index.d.ts +2 -0
- package/build/if-run/builtins/multiply/index.js +59 -0
- package/build/if-run/builtins/regex/index.d.ts +2 -0
- package/build/if-run/builtins/regex/index.js +76 -0
- package/build/if-run/builtins/sci/config.js +44 -0
- package/build/if-run/builtins/sci/index.d.ts +2 -0
- package/build/if-run/builtins/sci/index.js +92 -0
- package/build/if-run/builtins/sci-embodied/index.d.ts +2 -0
- package/build/if-run/builtins/sci-embodied/index.js +156 -0
- package/build/if-run/builtins/shell/index.d.ts +2 -0
- package/build/if-run/builtins/shell/index.js +60 -0
- package/build/if-run/builtins/subtract/index.d.ts +2 -0
- package/build/if-run/builtins/subtract/index.js +61 -0
- package/build/if-run/builtins/sum/index.d.ts +2 -0
- package/build/if-run/builtins/sum/index.js +66 -0
- package/build/if-run/builtins/time-sync/index.d.ts +17 -0
- package/build/if-run/builtins/time-sync/index.js +339 -0
- package/build/if-run/config/config.d.ts +9 -0
- package/build/if-run/config/config.js +73 -0
- package/build/if-run/config/index.d.ts +2 -0
- package/build/if-run/config/index.js +8 -0
- package/build/{config → if-run/config}/strings.d.ts +28 -54
- package/build/if-run/config/strings.js +76 -0
- package/build/if-run/index.d.ts +2 -0
- package/build/if-run/index.js +63 -0
- package/build/if-run/lib/aggregate.d.ts +15 -0
- package/build/if-run/lib/aggregate.js +123 -0
- package/build/if-run/lib/compute.js +136 -0
- package/build/{lib → if-run/lib}/environment.d.ts +1 -1
- package/build/if-run/lib/environment.js +75 -0
- package/build/{lib → if-run/lib}/exhaust.d.ts +1 -1
- package/build/if-run/lib/exhaust.js +27 -0
- package/build/if-run/lib/explain.d.ts +9 -0
- package/build/if-run/lib/explain.js +43 -0
- package/build/if-run/lib/initialize.d.ts +6 -0
- package/build/if-run/lib/initialize.js +109 -0
- package/build/if-run/lib/regroup.d.ts +5 -0
- package/build/if-run/lib/regroup.js +64 -0
- package/build/if-run/types/aggregation.d.ts +5 -0
- package/build/if-run/types/aggregation.js +6 -0
- package/build/{types → if-run/types}/compute.d.ts +12 -8
- package/build/if-run/types/compute.js +3 -0
- package/build/if-run/types/environment.js +3 -0
- package/build/{types → if-run/types}/exhaust-plugin-interface.d.ts +1 -1
- package/build/if-run/types/exhaust-plugin-interface.js +3 -0
- package/build/if-run/types/explain.d.ts +10 -0
- package/build/if-run/types/explain.js +3 -0
- package/build/if-run/types/interface.d.ts +3 -0
- package/build/if-run/types/interface.js +6 -0
- package/build/if-run/types/plugin-storage.js +3 -0
- package/build/if-run/types/process-args.d.ts +25 -0
- package/build/if-run/types/process-args.js +3 -0
- package/build/if-run/types/time-sync.js +3 -0
- package/build/{util → if-run/util}/aggregation-helper.d.ts +2 -1
- package/build/if-run/util/aggregation-helper.js +47 -0
- package/build/if-run/util/args.d.ts +9 -0
- package/build/if-run/util/args.js +60 -0
- package/build/if-run/util/helpers.d.ts +14 -0
- package/build/if-run/util/helpers.js +57 -0
- package/build/if-run/util/log-memoize.js +19 -0
- package/build/if-run/util/os-checker.js +97 -0
- package/build/{util → if-run/util}/plugin-storage.d.ts +1 -1
- package/build/if-run/util/plugin-storage.js +34 -0
- package/jest.config.js +2 -6
- package/manifests/examples/builtins/coefficient/failure-invalid-config-input-param.yml +2 -2
- package/manifests/examples/builtins/coefficient/failure-output-param-is-null.yaml +3 -3
- package/manifests/examples/builtins/coefficient/success.yml +2 -2
- package/manifests/examples/builtins/csv-lookup/cloud-metadata/failure-invalid-instance-type.yaml +3 -3
- package/manifests/examples/builtins/csv-lookup/cloud-metadata/failure-invalid-vendor.yaml +3 -3
- package/manifests/examples/builtins/csv-lookup/cloud-metadata/failure-missing-cloud-vendor.yml +3 -3
- package/manifests/examples/builtins/csv-lookup/cloud-metadata/success.yml +3 -3
- package/manifests/examples/builtins/csv-lookup/region-metadata/failure-missing-column.yml +3 -3
- package/manifests/examples/builtins/csv-lookup/region-metadata/failure-missing-output.yml +3 -3
- package/manifests/examples/builtins/csv-lookup/region-metadata/success-renaming.yml +4 -4
- package/manifests/examples/builtins/csv-lookup/region-metadata/success.yml +3 -3
- package/manifests/examples/builtins/csv-lookup/tdp-finder/failure-missing-input-param.yml +2 -2
- package/manifests/examples/builtins/csv-lookup/tdp-finder/failure-unsupported-physical-processor.yml +2 -2
- package/manifests/examples/builtins/csv-lookup/tdp-finder/success.yml +2 -2
- package/manifests/examples/builtins/divide/failure-denominator-equal-zero.yml +4 -4
- package/manifests/examples/builtins/divide/failure-invalid-config-denominator.yml +5 -5
- package/manifests/examples/builtins/divide/failure-missing-numerator.yml +4 -4
- package/manifests/examples/builtins/divide/success.yml +4 -6
- package/manifests/examples/builtins/exponent/success.yml +5 -7
- package/manifests/examples/builtins/interpolation/interpolation.yml +2 -2
- package/manifests/examples/builtins/interpolation/success.yml +2 -1
- package/manifests/examples/builtins/mock-observations/failure-invalid-config-cpu-range.yml +2 -2
- package/manifests/examples/builtins/mock-observations/failure-invalid-memory-utilization-range.yml +2 -2
- package/manifests/examples/builtins/mock-observations/failure-missing-timestamp-from-param.yml +2 -2
- package/manifests/examples/builtins/mock-observations/success.yml +2 -2
- package/manifests/examples/builtins/multiply/failure-input-parameter-is-missing.yml +2 -4
- package/manifests/examples/builtins/multiply/success-with-multiple-inputs.yml +2 -4
- package/manifests/examples/builtins/multiply/success.yml +3 -4
- package/manifests/examples/builtins/regex/failure-missing-input-param.yml +2 -4
- package/manifests/examples/builtins/regex/failure-not-matching-with-regex.yml +2 -4
- package/manifests/examples/builtins/regex/success.yml +2 -4
- package/manifests/examples/builtins/sci/failure-invalid-config-value.yml +2 -2
- package/manifests/examples/builtins/sci/failure-missing-input-param.yml +3 -2
- package/manifests/examples/builtins/sci/success.yml +2 -3
- package/manifests/examples/builtins/sci-embodied/failure-invalid-default-emission-value.yml +3 -3
- package/manifests/examples/builtins/sci-embodied/failure-missing-expected-lifespan.yml +2 -2
- package/manifests/examples/builtins/sci-embodied/success.yml +2 -2
- package/manifests/examples/builtins/shell/failure-invalid-command.yml +2 -2
- package/manifests/examples/builtins/shell/success.yml +2 -1
- package/manifests/examples/builtins/subtract/success.yml +6 -8
- package/manifests/examples/builtins/sum/failure-missing-input-param.yml +2 -4
- package/manifests/examples/builtins/sum/failure-missing-output-param.yml +3 -5
- package/manifests/examples/builtins/sum/success.yml +2 -4
- package/manifests/examples/builtins/time-sync/failure-config-start-later-end.yml +3 -3
- package/manifests/examples/builtins/time-sync/failure-missing-global-config.yml +3 -3
- package/manifests/examples/builtins/time-sync/success.yml +2 -2
- package/manifests/examples/{builtins/groupby/failure-invalid-config-group.yml → features/regroup/failure-invalid-regroup.yml} +4 -11
- package/manifests/examples/{builtins/groupby → features/regroup}/failure-missing-cloud-instance-type.yml +5 -12
- package/manifests/examples/{builtins/groupby → features/regroup}/success.yml +4 -11
- package/manifests/examples/pipelines/generics.yml +12 -13
- package/manifests/examples/pipelines/instance-metadata.yml +4 -5
- package/manifests/examples/pipelines/nesting.yml +157 -50
- package/manifests/examples/pipelines/outputs-if-diff/pipeline-with-aggregate.yaml +997 -0
- package/manifests/examples/pipelines/outputs-if-diff/pipeline-with-mocks.yaml +1059 -0
- package/manifests/examples/pipelines/pipeline-teads-sci.yml +11 -11
- package/manifests/examples/pipelines/pipeline-with-aggregate.yml +114 -37
- package/manifests/examples/pipelines/pipeline-with-mocks.yml +193 -103
- package/manifests/examples/pipelines/scenario-1.yml +34 -0
- package/manifests/examples/pipelines/scenario-2.yml +52 -0
- package/manifests/examples/pipelines/scenario-3.yml +86 -0
- package/manifests/examples/pipelines/scenario-4.yml +46 -0
- package/manifests/examples/pipelines/scenario-5.yml +46 -0
- package/manifests/examples/pipelines/sci.yml +15 -17
- package/manifests/examples/pipelines/teads-curve.yml +7 -6
- package/manifests/examples/pipelines/zeros.yml +15 -16
- package/manifests/outputs/bugs/aggregation-error-wrong-metric.yaml +51 -59
- package/manifests/outputs/bugs/input-error-missing-duration.yaml +14 -16
- package/manifests/outputs/bugs/mock-observations-failure-duration-is-zero.yaml +14 -16
- package/manifests/outputs/bugs/pipeline-error-naming-mismatch.yaml +14 -16
- package/manifests/outputs/bugs/pipeline-error-uninitialized-plugin.yaml +15 -17
- package/manifests/outputs/bugs/pipeline-ordering-error.yaml +23 -26
- package/manifests/outputs/bugs/sci-embodied-missing-resources-total.yaml +13 -14
- package/manifests/outputs/{plugins → builtins}/coefficient/failure-invalid-config-input-param.yaml +13 -17
- package/manifests/outputs/{plugins → builtins}/coefficient/failure-output-param-is-null.yaml +13 -17
- package/manifests/outputs/{plugins → builtins}/coefficient/success.yaml +11 -16
- package/manifests/outputs/builtins/csv-lookup/cloud-metadata/failure-invalid-instance-type.yaml +76 -0
- package/manifests/outputs/{plugins → builtins}/csv-lookup/cloud-metadata/failure-missing-cloud-vendor.yaml +16 -19
- package/manifests/outputs/{plugins → builtins}/csv-lookup/cloud-metadata/success.yaml +16 -19
- package/manifests/outputs/{plugins → builtins}/csv-lookup/region-metadata/failure-missing-column.yaml +14 -15
- package/manifests/outputs/{plugins → builtins}/csv-lookup/region-metadata/failure-missing-output.yaml +13 -15
- package/manifests/outputs/{plugins → builtins}/csv-lookup/region-metadata/success-renaming.yaml +13 -15
- package/manifests/outputs/{plugins → builtins}/csv-lookup/region-metadata/success.yaml +14 -16
- package/manifests/outputs/{plugins → builtins}/csv-lookup/tdp-finder/failure-missing-input-param.yaml +13 -16
- package/manifests/outputs/{plugins → builtins}/csv-lookup/tdp-finder/failure-unsupported-physical-processor.yaml +13 -15
- package/manifests/outputs/{plugins → builtins}/csv-lookup/tdp-finder/success.yaml +13 -15
- package/manifests/outputs/{plugins → builtins}/divide/failure-invalid-config-denominator.yaml +13 -17
- package/manifests/outputs/{plugins → builtins}/divide/failure-missing-numerator.yaml +13 -15
- package/manifests/outputs/{plugins → builtins}/divide/success-denominator-equal-zero.yaml +14 -18
- package/manifests/outputs/{plugins → builtins}/divide/success.yaml +14 -18
- package/manifests/outputs/{plugins → builtins}/exponent/success.yaml +13 -17
- package/manifests/outputs/{plugins → builtins}/interpolation/interpolation.yaml +14 -16
- package/manifests/outputs/{plugins → builtins}/interpolation/success.yaml +14 -16
- package/manifests/outputs/{plugins → builtins}/mock-observations/failure-invalid-config-cpu-range.yaml +13 -15
- package/manifests/outputs/{plugins → builtins}/mock-observations/failure-invalid-memory-utilization-range.yaml +13 -15
- package/manifests/outputs/{plugins → builtins}/mock-observations/failure-missing-timestamp-from-param.yaml +13 -15
- package/manifests/outputs/builtins/mock-observations/success.yaml +358 -0
- package/manifests/outputs/{plugins → builtins}/multiply/failure-input-parameter-is-missing.yaml +13 -17
- package/manifests/outputs/{plugins → builtins}/multiply/success-with-multiple-inputs.yaml +13 -17
- package/manifests/outputs/{plugins → builtins}/multiply/success.yaml +13 -17
- package/manifests/outputs/{plugins → builtins}/regex/failure-missing-input-param.yaml +13 -17
- package/manifests/outputs/{plugins → builtins}/regex/success.yaml +14 -19
- package/manifests/outputs/{plugins → builtins}/sci/failure-invalid-config-value.yaml +14 -16
- package/manifests/outputs/{plugins → builtins}/sci/failure-missing-input-param.yaml +13 -15
- package/manifests/outputs/{plugins/sci/success.yml.yaml → builtins/sci/success.yaml} +13 -16
- package/manifests/outputs/{plugins → builtins}/sci-embodied/failure-invalid-default-emission-value.yaml +13 -15
- package/manifests/outputs/{plugins → builtins}/sci-embodied/failure-missing-expected-lifespan.yaml +13 -15
- package/manifests/outputs/{plugins → builtins}/sci-embodied/success.yaml +13 -15
- package/manifests/outputs/{plugins → builtins}/shell/failure-invalid-command.yaml +14 -16
- package/manifests/outputs/{plugins → builtins}/shell/success.yaml +14 -16
- package/manifests/outputs/{plugins → builtins}/subtract/success.yaml +13 -17
- package/manifests/outputs/{plugins → builtins}/sum/failure-missing-input-param.yaml +13 -17
- package/manifests/outputs/{plugins → builtins}/sum/failure-missing-output-param.yaml +13 -17
- package/manifests/outputs/{plugins → builtins}/sum/success.yaml +13 -17
- package/manifests/outputs/{plugins → builtins}/time-sync/failure-config-start-later-end.yaml +20 -23
- package/manifests/outputs/{plugins → builtins}/time-sync/success.yaml +38 -35
- package/manifests/outputs/features/aggregate-failure-invalid-metrics.yaml +17 -18
- package/manifests/outputs/features/aggregate-failure-missing-metric-in-inputs.yaml +17 -18
- package/manifests/outputs/features/aggregate-horizontal.yaml +27 -23
- package/manifests/outputs/features/aggregate-vertical.yaml +33 -29
- package/manifests/outputs/features/aggregate.yaml +33 -29
- package/manifests/outputs/{plugins/groupby/failure-invalid-config-group.yaml → features/failure-invalid-regroup.yaml} +16 -25
- package/manifests/outputs/{plugins/groupby → features}/failure-missing-cloud-instance-type.yaml +16 -25
- package/manifests/outputs/pipelines/cloud-metadata-divide.yaml +14 -18
- package/manifests/outputs/pipelines/generics.yaml +239 -0
- package/manifests/outputs/pipelines/instance-metadata.yaml +98 -0
- package/manifests/outputs/pipelines/mock-obs-time-sync.yaml +246 -147
- package/manifests/outputs/pipelines/nesting.yaml +1799 -0
- package/manifests/outputs/pipelines/pipeline-teads-sci.yaml +276 -0
- package/manifests/outputs/pipelines/sci.yaml +297 -0
- package/manifests/outputs/pipelines/teads-curve.yaml +188 -0
- package/manifests/outputs/pipelines/zeros.yaml +198 -0
- package/package.json +15 -16
- package/src/__mocks__/mock-manifest.yaml +2 -3
- package/src/{config → if-env/config}/env-template.yml +2 -3
- package/src/{builtins → if-run/builtins}/coefficient/README.md +31 -9
- package/src/{builtins → if-run/builtins}/copy-param/README.md +30 -11
- package/src/{builtins → if-run/builtins}/csv-lookup/README.md +32 -20
- package/src/{builtins → if-run/builtins}/divide/README.md +21 -8
- package/src/{builtins → if-run/builtins}/exponent/README.md +19 -8
- package/src/{builtins → if-run/builtins}/interpolation/README.md +21 -6
- package/src/{builtins → if-run/builtins}/mock-observations/README.md +18 -4
- package/src/{builtins → if-run/builtins}/multiply/README.md +20 -8
- package/src/{builtins → if-run/builtins}/regex/README.md +19 -9
- package/src/{builtins → if-run/builtins}/sci/README.md +19 -9
- package/src/{builtins → if-run/builtins}/sci-embodied/README.md +17 -5
- package/src/{builtins → if-run/builtins}/shell/README.md +19 -7
- package/src/{builtins → if-run/builtins}/subtract/README.md +17 -6
- package/src/{builtins → if-run/builtins}/sum/README.md +34 -8
- package/src/if-run/builtins/time-sync/README.md +267 -0
- package/build/builtins/coefficient/index.d.ts +0 -2
- package/build/builtins/coefficient/index.js +0 -65
- package/build/builtins/copy-param/index.d.ts +0 -2
- package/build/builtins/copy-param/index.js +0 -68
- package/build/builtins/csv-lookup/index.d.ts +0 -2
- package/build/builtins/csv-lookup/index.js +0 -188
- package/build/builtins/divide/index.d.ts +0 -2
- package/build/builtins/divide/index.js +0 -78
- package/build/builtins/exponent/index.d.ts +0 -2
- package/build/builtins/exponent/index.js +0 -58
- package/build/builtins/export-csv-raw.d.ts +0 -4
- package/build/builtins/export-csv-raw.js +0 -132
- package/build/builtins/export-csv.d.ts +0 -10
- package/build/builtins/export-csv.js +0 -96
- package/build/builtins/export-yaml.js +0 -30
- package/build/builtins/group-by.d.ts +0 -5
- package/build/builtins/group-by.js +0 -71
- package/build/builtins/interpolation/index.d.ts +0 -2
- package/build/builtins/interpolation/index.js +0 -148
- package/build/builtins/mock-observations/helpers/common-generator.js +0 -29
- package/build/builtins/mock-observations/helpers/rand-int-generator.js +0 -48
- package/build/builtins/mock-observations/index.d.ts +0 -2
- package/build/builtins/mock-observations/index.js +0 -114
- package/build/builtins/mock-observations/interfaces/index.js +0 -3
- package/build/builtins/multiply/index.d.ts +0 -2
- package/build/builtins/multiply/index.js +0 -57
- package/build/builtins/regex/index.d.ts +0 -2
- package/build/builtins/regex/index.js +0 -74
- package/build/builtins/sci/config.js +0 -44
- package/build/builtins/sci/index.d.ts +0 -2
- package/build/builtins/sci/index.js +0 -70
- package/build/builtins/sci-embodied/index.d.ts +0 -2
- package/build/builtins/sci-embodied/index.js +0 -114
- package/build/builtins/shell/index.d.ts +0 -2
- package/build/builtins/shell/index.js +0 -58
- package/build/builtins/subtract/index.d.ts +0 -2
- package/build/builtins/subtract/index.js +0 -59
- package/build/builtins/sum/index.d.ts +0 -2
- package/build/builtins/sum/index.js +0 -64
- package/build/builtins/time-sync.d.ts +0 -2
- package/build/builtins/time-sync.js +0 -300
- package/build/check.js +0 -95
- package/build/config/config.d.ts +0 -29
- package/build/config/config.js +0 -147
- package/build/config/index.js +0 -10
- package/build/config/params.d.ts +0 -2
- package/build/config/params.js +0 -196
- package/build/config/strings.js +0 -105
- package/build/diff.js +0 -46
- package/build/env.js +0 -38
- package/build/index.js +0 -48
- package/build/lib/aggregate.d.ts +0 -6
- package/build/lib/aggregate.js +0 -77
- package/build/lib/compare.js +0 -56
- package/build/lib/compute.js +0 -91
- package/build/lib/environment.js +0 -75
- package/build/lib/exhaust.js +0 -53
- package/build/lib/initialize.d.ts +0 -6
- package/build/lib/initialize.js +0 -101
- package/build/lib/load.js +0 -70
- package/build/lib/parameterize.d.ts +0 -6
- package/build/lib/parameterize.js +0 -55
- package/build/types/aggregation.d.ts +0 -2
- package/build/types/aggregation.js +0 -5
- package/build/types/compute.js +0 -3
- package/build/types/environment.js +0 -3
- package/build/types/exhaust-plugin-interface.js +0 -3
- package/build/types/if-env.js +0 -3
- package/build/types/interface.d.ts +0 -4
- package/build/types/interface.js +0 -8
- package/build/types/lib/compare.js +0 -3
- package/build/types/manifest.js +0 -3
- package/build/types/npm.js +0 -3
- package/build/types/parameters.d.ts +0 -5
- package/build/types/parameters.js +0 -5
- package/build/types/plugin-storage.js +0 -3
- package/build/types/process-args.d.ts +0 -33
- package/build/types/process-args.js +0 -3
- package/build/types/time-sync.js +0 -3
- package/build/types/util/args.js +0 -3
- package/build/util/aggregation-helper.js +0 -55
- package/build/util/args.d.ts +0 -37
- package/build/util/args.js +0 -205
- package/build/util/debug-logger.js +0 -118
- package/build/util/fs.js +0 -94
- package/build/util/helpers.d.ts +0 -57
- package/build/util/helpers.js +0 -251
- package/build/util/json.d.ts +0 -4
- package/build/util/json.js +0 -36
- package/build/util/log-memoize.js +0 -19
- package/build/util/npm.js +0 -152
- package/build/util/os-checker.js +0 -97
- package/build/util/plugin-storage.js +0 -34
- package/build/util/validations.js +0 -124
- package/build/util/yaml.js +0 -59
- package/manifests/outputs/bugs/initialize-error-no-config.yaml +0 -78
- package/manifests/outputs/bugs/initialize-error-no-path.yaml +0 -91
- package/manifests/outputs/bugs/initialize-error-no-plugins.yaml +0 -74
- package/manifests/outputs/divide.yaml +0 -93
- package/manifests/outputs/pipelines/mock-obs-group-by-cloud-meta.yaml +0 -645
- package/manifests/outputs/pipelines/mock-obs-groupby.yaml +0 -178
- package/manifests/outputs/plugins/csv-lookup/cloud-metadata/failure-invalid-instance-type.yaml +0 -27
- package/manifests/outputs/plugins/csv-lookup/cloud-metadata/failure-invalid-vendor.yaml +0 -27
- package/manifests/outputs/plugins/groupby/success.yaml +0 -101
- package/manifests/outputs/plugins/mock-observations/success.yaml +0 -220
- package/manifests/outputs/plugins/regex/failure-not-matching-with-regex.yaml +0 -76
- package/manifests/outputs/plugins/time-sync/failure-missing-global-config.yaml +0 -78
- package/src/__tests__/integration/templates/integration.yaml +0 -16
- package/src/builtins/README.md +0 -848
- /package/build/{util → common/util}/debug-logger.d.ts +0 -0
- /package/build/{util → common/util}/fs.d.ts +0 -0
- /package/build/{util → common/util}/logger.d.ts +0 -0
- /package/build/{util → common/util}/yaml.d.ts +0 -0
- /package/build/{index.d.ts → if-check/index.d.ts} +0 -0
- /package/build/{check.d.ts → if-csv/index.d.ts} +0 -0
- /package/build/{diff.d.ts → if-diff/index.d.ts} +0 -0
- /package/build/{types/util → if-diff/types}/args.d.ts +0 -0
- /package/build/{types/lib → if-diff/types}/compare.d.ts +0 -0
- /package/build/{env.d.ts → if-env/index.d.ts} +0 -0
- /package/build/{types → if-env/types}/if-env.d.ts +0 -0
- /package/build/{types → if-env/types}/npm.d.ts +0 -0
- /package/build/{builtins → if-run/builtins}/mock-observations/helpers/common-generator.d.ts +0 -0
- /package/build/{builtins → if-run/builtins}/mock-observations/helpers/rand-int-generator.d.ts +0 -0
- /package/build/{builtins → if-run/builtins}/mock-observations/interfaces/index.d.ts +0 -0
- /package/build/{builtins → if-run/builtins}/sci/config.d.ts +0 -0
- /package/build/{lib → if-run/lib}/compute.d.ts +0 -0
- /package/build/{types → if-run/types}/environment.d.ts +0 -0
- /package/build/{types → if-run/types}/plugin-storage.d.ts +0 -0
- /package/build/{types → if-run/types}/time-sync.d.ts +0 -0
- /package/build/{util → if-run/util}/log-memoize.d.ts +0 -0
- /package/build/{util → if-run/util}/os-checker.d.ts +0 -0
|
@@ -22,6 +22,21 @@ The `shell` plugin interface requires a path to the plugin command. This path is
|
|
|
22
22
|
|
|
23
23
|
- `command`: the path to the plugin executable along with the execution command as it would be entered into a shell.
|
|
24
24
|
|
|
25
|
+
### Plugin parameter metadata
|
|
26
|
+
|
|
27
|
+
The `parameter-metadata` section contains information about `description`, `unit` and `aggregation-method` of the parameters of the inputs and outputs
|
|
28
|
+
|
|
29
|
+
- `inputs`: describe the parameters of the `inputs`. Each parameter has:
|
|
30
|
+
|
|
31
|
+
- `description`: description of the parameter
|
|
32
|
+
- `unit`: unit of the parameter
|
|
33
|
+
- `aggregation-method`: aggregation method of the parameter (it can be `sum`, `avg` or `none`)
|
|
34
|
+
|
|
35
|
+
- `outputs`: describe the output parameter. The parameter has the following attributes:
|
|
36
|
+
- `description`: description of the parameter
|
|
37
|
+
- `unit`: unit of the parameter
|
|
38
|
+
- `aggregation-method`: aggregation method of the parameter (it can be `sum`, `avg` or `none`)
|
|
39
|
+
|
|
25
40
|
### Inputs
|
|
26
41
|
|
|
27
42
|
The parameters included in the `inputs` field in the `manifest` depend entirely on the plugin itself. A typical plugin might expect the following common data to be provided as `inputs`:
|
|
@@ -66,8 +81,6 @@ name: shell-demo
|
|
|
66
81
|
description:
|
|
67
82
|
tags:
|
|
68
83
|
initialize:
|
|
69
|
-
outputs:
|
|
70
|
-
- yaml
|
|
71
84
|
plugins:
|
|
72
85
|
sampler:
|
|
73
86
|
method: Shell
|
|
@@ -78,7 +91,8 @@ tree:
|
|
|
78
91
|
children:
|
|
79
92
|
child:
|
|
80
93
|
pipeline:
|
|
81
|
-
|
|
94
|
+
compute:
|
|
95
|
+
- sampler
|
|
82
96
|
inputs:
|
|
83
97
|
- timestamp: 2023-07-06T00:00
|
|
84
98
|
duration: 1 # Secs
|
|
@@ -94,8 +108,6 @@ name: shell-demo
|
|
|
94
108
|
description:
|
|
95
109
|
tags:
|
|
96
110
|
initialize:
|
|
97
|
-
outputs:
|
|
98
|
-
- yaml
|
|
99
111
|
plugins:
|
|
100
112
|
sampler:
|
|
101
113
|
method: Shell
|
|
@@ -106,7 +118,8 @@ tree:
|
|
|
106
118
|
children:
|
|
107
119
|
child:
|
|
108
120
|
pipeline:
|
|
109
|
-
|
|
121
|
+
compute:
|
|
122
|
+
- sampler
|
|
110
123
|
inputs:
|
|
111
124
|
- timestamp: 2023-07-06T00:00
|
|
112
125
|
duration: 1 # Secs
|
|
@@ -129,7 +142,6 @@ if-run --manifest manifests/plugins/shell.yml --output manifests/outputs/shell.y
|
|
|
129
142
|
|
|
130
143
|
The results will be saved to a new `yaml` file.
|
|
131
144
|
|
|
132
|
-
|
|
133
145
|
## Errors
|
|
134
146
|
|
|
135
147
|
`Shell` uses one of the error classes provided by IF
|
|
@@ -15,6 +15,21 @@ Two parameters are required in global config: `input-parameters` and `output-par
|
|
|
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.
|
|
17
17
|
|
|
18
|
+
### Plugin parameter metadata
|
|
19
|
+
|
|
20
|
+
The `parameter-metadata` section contains information about `description`, `unit` and `aggregation-method` of the parameters of the inputs and outputs
|
|
21
|
+
|
|
22
|
+
- `inputs`: describe parameters of the `input-parameters` of the global config. Each parameter has the following attributes:
|
|
23
|
+
|
|
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`)
|
|
27
|
+
|
|
28
|
+
- `outputs`: describe the parameter of the `output-parameter` of the global config. The parameter has the following attributes:
|
|
29
|
+
- `description`: description of the parameter
|
|
30
|
+
- `unit`: unit of the parameter
|
|
31
|
+
- `aggregation-method`: aggregation method of the parameter (it can be `sum`, `avg` or `none`)
|
|
32
|
+
|
|
18
33
|
### Inputs
|
|
19
34
|
|
|
20
35
|
All of `input-parameters` must be available in the input array.
|
|
@@ -61,8 +76,6 @@ name: subtract demo
|
|
|
61
76
|
description:
|
|
62
77
|
tags:
|
|
63
78
|
initialize:
|
|
64
|
-
outputs:
|
|
65
|
-
- yaml
|
|
66
79
|
plugins:
|
|
67
80
|
subtract:
|
|
68
81
|
method: Subtract
|
|
@@ -74,9 +87,8 @@ tree:
|
|
|
74
87
|
children:
|
|
75
88
|
child:
|
|
76
89
|
pipeline:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
subtract:
|
|
90
|
+
compute:
|
|
91
|
+
- subtract
|
|
80
92
|
inputs:
|
|
81
93
|
- timestamp: 2023-08-06T00:00
|
|
82
94
|
duration: 3600
|
|
@@ -93,7 +105,6 @@ if-run --manifest /manifests/plugins/subtract.yml --output manifests/outputs/sub
|
|
|
93
105
|
|
|
94
106
|
The results will be saved to a new `yaml` file in `manifests/outputs`.
|
|
95
107
|
|
|
96
|
-
|
|
97
108
|
## Errors
|
|
98
109
|
|
|
99
110
|
`Subtract` uses one of IF's error classes:
|
|
@@ -15,6 +15,21 @@ Two parameters are required in global config: `input-parameters` and `output-par
|
|
|
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.
|
|
17
17
|
|
|
18
|
+
### Plugin parameter metadata
|
|
19
|
+
|
|
20
|
+
The `parameter-metadata` section contains information about `description`, `unit` and `aggregation-method` of the parameters of the inputs and outputs
|
|
21
|
+
|
|
22
|
+
- `inputs`: describe parameters of the `input-parameters` of the global config. Each parameter has:
|
|
23
|
+
|
|
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`)
|
|
27
|
+
|
|
28
|
+
- `outputs`: describe the parameter of the `output-parameter` of the global config. The parameter has the following attributes:
|
|
29
|
+
- `description`: description of the parameter
|
|
30
|
+
- `unit`: unit of the parameter
|
|
31
|
+
- `aggregation-method`: aggregation method of the parameter (it can be `sum`, `avg` or `none`)
|
|
32
|
+
|
|
18
33
|
### Inputs
|
|
19
34
|
|
|
20
35
|
All of `input-parameters` must be available in the input array.
|
|
@@ -39,7 +54,7 @@ const config = {
|
|
|
39
54
|
outputParameter: 'energy',
|
|
40
55
|
};
|
|
41
56
|
|
|
42
|
-
const sum = Sum(config);
|
|
57
|
+
const sum = Sum(config, parametersMetadata);
|
|
43
58
|
const result = sum.execute([
|
|
44
59
|
{
|
|
45
60
|
timestamp: '2021-01-01T00:00:00Z',
|
|
@@ -59,8 +74,6 @@ name: sum demo
|
|
|
59
74
|
description:
|
|
60
75
|
tags:
|
|
61
76
|
initialize:
|
|
62
|
-
outputs:
|
|
63
|
-
- yaml
|
|
64
77
|
plugins:
|
|
65
78
|
sum:
|
|
66
79
|
method: Sum
|
|
@@ -68,13 +81,27 @@ initialize:
|
|
|
68
81
|
global-config:
|
|
69
82
|
input-parameters: ['cpu/energy', 'network/energy']
|
|
70
83
|
output-parameter: 'energy'
|
|
84
|
+
parameter-metadata:
|
|
85
|
+
inputs:
|
|
86
|
+
cpu/energy:
|
|
87
|
+
description: energy consumed by the cpu
|
|
88
|
+
unit: kWh
|
|
89
|
+
aggregation-method: sum
|
|
90
|
+
network/energy:
|
|
91
|
+
description: energy consumed by data ingress and egress
|
|
92
|
+
unit: kWh
|
|
93
|
+
aggregation-method: sum
|
|
94
|
+
outputs:
|
|
95
|
+
energy:
|
|
96
|
+
description: sum of energy components
|
|
97
|
+
unit: kWh
|
|
98
|
+
aggregation-method: sum
|
|
71
99
|
tree:
|
|
72
100
|
children:
|
|
73
101
|
child:
|
|
74
102
|
pipeline:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
sum:
|
|
103
|
+
compute:
|
|
104
|
+
- sum
|
|
78
105
|
inputs:
|
|
79
106
|
- timestamp: 2023-08-06T00:00
|
|
80
107
|
duration: 3600
|
|
@@ -90,7 +117,6 @@ if-run --manifest ./examples/manifests/sum.yml --output ./examples/outputs/sum.y
|
|
|
90
117
|
|
|
91
118
|
The results will be saved to a new `yaml` file in `./examples/outputs`.
|
|
92
119
|
|
|
93
|
-
|
|
94
120
|
## Errors
|
|
95
121
|
|
|
96
122
|
`Sum` exposes two of the IF error classes.
|
|
@@ -100,6 +126,7 @@ The results will be saved to a new `yaml` file in `./examples/outputs`.
|
|
|
100
126
|
You will receive an error starting `GlobalConfigError: ` if you have not provided the expected configuration data in the plugin's `initialize` block.
|
|
101
127
|
|
|
102
128
|
The required parameters are:
|
|
129
|
+
|
|
103
130
|
- `input-parameters`: this must be an array of strings, each being the name of a value in the `inputs` array
|
|
104
131
|
- `output-parameter`: this must be a string
|
|
105
132
|
|
|
@@ -114,5 +141,4 @@ Every element in the ``inputs` array must contain:
|
|
|
114
141
|
- `duration`
|
|
115
142
|
- whatever values you passed to `input-parameters`
|
|
116
143
|
|
|
117
|
-
|
|
118
144
|
For more information on our error classes, please visit [our docs](https://if.greensoftware.foundation/reference/errors).
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
## Time-sync
|
|
2
|
+
|
|
3
|
+
Time sync standardizes the start time, end time and temporal resolution of all output data across an entire tree.
|
|
4
|
+
|
|
5
|
+
### Parameters
|
|
6
|
+
|
|
7
|
+
### Plugin config
|
|
8
|
+
|
|
9
|
+
The following should be defined in the plugin initialization:
|
|
10
|
+
|
|
11
|
+
- `start-time`: global start time as ISO 8061 string
|
|
12
|
+
- `stop`: global end time as ISO 8061 string
|
|
13
|
+
- `interval`: temporal resolution in seconds
|
|
14
|
+
- `error-on-padding`: avoid zero/'zeroish' padding (if needed) and error out instead. `False` by defult.
|
|
15
|
+
|
|
16
|
+
#### Inputs:
|
|
17
|
+
|
|
18
|
+
- `inputs`: an array of observations
|
|
19
|
+
|
|
20
|
+
#### Returns
|
|
21
|
+
|
|
22
|
+
- `inputs`: time-synchronized version of the tree
|
|
23
|
+
|
|
24
|
+
#### Overview
|
|
25
|
+
|
|
26
|
+
A manifest file for a tree might contain many nodes each representing some different part of an application's stack or even different applications running on different machines. It is therefore common to have time series data in each component that is not directly comparable to other components either because the temporal resolution of the data is different, they cover different periods, or there are gaps in some records (e.g. some apps might burst but then go dormant, while others run continuously). This makes post-hoc visualization, analysis and aggregation of data from groups of nodes difficult to achieve. To address this, we created a time synchronization plugin that takes in non-uniform times series and snaps them all to a regular timeline with uniform start time, end time and temporal resolution.
|
|
27
|
+
|
|
28
|
+
We do this by implementing the following logic:
|
|
29
|
+
|
|
30
|
+
- Shift readings to nearest whole seconds
|
|
31
|
+
- Upsample the time series to a base resolution (1s)
|
|
32
|
+
- Resample to desired resolution by batching 1s entries
|
|
33
|
+
- Extrapolate or trim to ensure all time series share global start and end dates
|
|
34
|
+
|
|
35
|
+
The next section explains each stage in more detail.
|
|
36
|
+
|
|
37
|
+
#### Details
|
|
38
|
+
|
|
39
|
+
##### Upsampling rules
|
|
40
|
+
|
|
41
|
+
A set of `inputs` is naturally a time series because all `observations` include a `timestamp` and a `duration`, measured in seconds.
|
|
42
|
+
For each `observation` in `inputs` we check whether the duration is greater than 1 second. If `duration` is greater than 1 second, we create N new `observation` objects, where N is equal to `duration`. This means we have an `observation` for every second between the initial timestamp and the end of the observation period. Each new object receives a timestamp incremented by one second.
|
|
43
|
+
|
|
44
|
+
This looks as follows:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
[{timestamp: '2023-12-12T00:00:00.000Z', duration: 5}]
|
|
48
|
+
|
|
49
|
+
# becomes
|
|
50
|
+
[
|
|
51
|
+
{timestamp: '2023-12-12T00:00:01.000Z', duration: 1}
|
|
52
|
+
{timestamp: '2023-12-12T00:00:02.000Z', duration: 1}
|
|
53
|
+
{timestamp: '2023-12-12T00:00:03.000Z', duration: 1}
|
|
54
|
+
{timestamp: '2023-12-12T00:00:04.000Z', duration: 1}
|
|
55
|
+
{timestamp: '2023-12-12T00:00:05.000Z', duration: 1}
|
|
56
|
+
]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Each `observation` actually includes many key-value pairs. The precise content of the `observation` is not known until runtime because it depends on which plugins have been included in the pipeline. Different values have to be treated differently when we upsample in time. The method we use to upsample depends on the `aggregation-method` defined for each key in `units.yml`.
|
|
60
|
+
|
|
61
|
+
If the right way to aggregate a value is to sum it, then the right way to upsample it is to divide by `duration`, effectively spreading the total out evenly across the new, higher resolution, `observations` so that the total across the same bucket of time is unchanged (i.e. if the total for some value is 10 when there is one entry with `duration = 10s`, then the total should still be 10 when there are 10 entries each witch `duration = 1s`).
|
|
62
|
+
|
|
63
|
+
On the other hand, if the right way to aggregate a value is to take its average over some time period, the value should be copied unchanged into the newly upsampled `observations`. This is appropriate for values that are proportional or percentages, such as `cpu/utilization`. Treating these values as constants means the average over the `duration` for an observation is identical whether you consider the initial `observation` or the upsampled set of N `observation`s.
|
|
64
|
+
|
|
65
|
+
Constants can simply be copied as-is, because they are constants. Examples might be the `grid/carbon-intensity` - this value does not change depending on how frequently you observe it.
|
|
66
|
+
|
|
67
|
+
Therefore, we apply this logic and the resulting flow looks as follows (the `aggregation-method` for `carbon` and `energy` is `sum`, `grid/carbon-intensity` is a constant and `cpu/utilization` is expressed as a percentage):
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
[{timestamp: '2023-12-12T00:00:00.000Z', duration: 5, 'cpu/utilization': 12, carbon: 5, energy: 10, 'grid/carbon-intensity': 471}]
|
|
71
|
+
|
|
72
|
+
# becomes
|
|
73
|
+
|
|
74
|
+
[
|
|
75
|
+
{timestamp: '2023-12-12T00:00:00.000Z', duration: 1, 'cpu/utilization': 12, carbon: 1, energy: 2, 'grid/carbon-intensity': 471},
|
|
76
|
+
{timestamp: '2023-12-12T00:00:01.000Z', duration: 1, 'cpu/utilization': 12, carbon: 1, energy: 2, 'grid/carbon-intensity': 471},
|
|
77
|
+
{timestamp: '2023-12-12T00:00:02.000Z', duration: 1, 'cpu/utilization': 12, carbon: 1, energy: 2, 'grid/carbon-intensity': 471},
|
|
78
|
+
{timestamp: '2023-12-12T00:00:03.000Z', duration: 1, 'cpu/utilization': 12, carbon: 1, energy: 2, 'grid/carbon-intensity': 471},
|
|
79
|
+
{timestamp: '2023-12-12T00:00:04.000Z', duration: 1, 'cpu/utilization': 12, carbon: 1, energy: 2, 'grid/carbon-intensity': 471},
|
|
80
|
+
{timestamp: '2023-12-12T00:00:05.000Z', duration: 1, 'cpu/utilization': 12, carbon: 1, energy: 2, 'grid/carbon-intensity': 471}
|
|
81
|
+
]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The end result is that for each `observation`, we upsample the time series to yield 1 second resolution data between `timestamp` and `timestamp + duration`.
|
|
85
|
+
|
|
86
|
+
##### Gap-filling
|
|
87
|
+
|
|
88
|
+
Sometimes there might be discontinuities in the time series between one `observation` and another. For example we might have two `observations` in a set of `inputs` that have timestamps spaced 10 seconds apart, but the `duration` of the first `observation` is only 5 seconds. in this case, 5 seconds of data are unaccounted for and create a discontinuity in the time series.
|
|
89
|
+
|
|
90
|
+
To solve this problem, for all but the first `observation` in the `inputs` array, we grab the `timestamp` and `duration` from the previous `observation` and check that `timestamp[N] + duration[N] == timestamp[N+1]`. If this condition is not satisfied, we backfill the missing data with a "zero-observation" which is identical to the surrounding observations except any values whose `aggregation-method` is `sum` are set to zero. This is equivalent to assuming that when there is no data available, the app being monitored is switched off.
|
|
91
|
+
|
|
92
|
+
The end result of this gap-filling is that we have continuous 1 second resolution data that can be resampled to a new temporal resolution.
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
[
|
|
96
|
+
{timestamp: '2023-12-12T00:00:00.000Z', duration: 5, 'cpu/utilization': 12, carbon: 5, energy: 10, grid/carbon-intensity: 471},
|
|
97
|
+
{timestamp: '2023-12-12T00:00:08.000Z', duration: 2, 'cpu/utilization': 12, carbon: 5, energy: 10, grid/carbon-intensity: 471}
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
# There are 2 seconds of missing data between the end of timestamp[0] + duration, and timestamp[1]
|
|
101
|
+
# After expansion and infilling, the array becomes:
|
|
102
|
+
|
|
103
|
+
[
|
|
104
|
+
{timestamp: '2023-12-12T00:00:00.000Z', duration: 1, 'cpu/utilization': 12, carbon: 1, energy: 2, grid/carbon-intensity: 471},
|
|
105
|
+
{timestamp: '2023-12-12T00:00:01.000Z', duration: 1, 'cpu/utilization': 12, carbon: 1, energy: 2, grid/carbon-intensity: 471},
|
|
106
|
+
{timestamp: '2023-12-12T00:00:02.000Z', duration: 1, 'cpu/utilization': 12, carbon: 1, energy: 2, grid/carbon-intensity: 471},
|
|
107
|
+
{timestamp: '2023-12-12T00:00:03.000Z', duration: 1, 'cpu/utilization': 12, carbon: 1, energy: 2, grid/carbon-intensity: 471},
|
|
108
|
+
{timestamp: '2023-12-12T00:00:04.000Z', duration: 1, 'cpu/utilization': 12, carbon: 1, energy: 2, grid/carbon-intensity: 471},
|
|
109
|
+
{timestamp: '2023-12-12T00:00:05.000Z', duration: 1, 'cpu/utilization': 12, carbon: 1, energy: 2, grid/carbon-intensity: 471},
|
|
110
|
+
{timestamp: '2023-12-12T00:00:06.000Z', duration: 1, 'cpu/utilization': 0, carbon: 0, energy: 0, grid/carbon-intensity: 471},
|
|
111
|
+
{timestamp: '2023-12-12T00:00:07.000Z', duration: 1, 'cpu/utilization': 0, carbon: 0, energy: 0, grid/carbon-intensity: 471},
|
|
112
|
+
{timestamp: '2023-12-12T00:00:08.000Z', duration: 1, 'cpu/utilization': 12, carbon: 2.5, energy: 5, grid/carbon-intensity: 471},
|
|
113
|
+
{timestamp: '2023-12-12T00:00:09.000Z', duration: 1, 'cpu/utilization': 12, carbon: 2.5, energy: 5, grid/carbon-intensity: 471}
|
|
114
|
+
]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Note that when `error-on-padding` is `true` no gap-filling is performed and the plugin will error out instead.
|
|
118
|
+
|
|
119
|
+
##### Trimming and padding
|
|
120
|
+
|
|
121
|
+
To ensure parity across all the components in a tree, we need to synchronize the start and end times for all time series. To do this, we pass the `time-sync` plugin plugin some global config: `startTime`, `endTime` and `interval`. The `startTime` is the timestamp where _all_ input arrays across the entire tree should begin, and `endTime` is the timestamp where _all_ input arrays across the entire tree should end. `interval` is the time resolution we ultimately want to resample to.
|
|
122
|
+
|
|
123
|
+
To synchronize the time series start and end we check the first element of `inputs` for each node in the tree and determine whether it is earlier, later or equal to the global start time. If it is equal then no action is required. If the `input` start time is earlier than the global start time, we simply discard entries from the front of the array until the start times are aligned. If the `input` start time is after the global start time, then we pad with our "zero-observation" object - one for every second separating the global start time from the `input` start time. The same process is repeated for the end time - we either trim away `input` data or pad it out with "zero-observation" objects.
|
|
124
|
+
|
|
125
|
+
For example, for `startTime = 2023-12-12T00:00:00.000Z` and `endTime = 2023-12-12T00:00:15.000Z`:
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
[
|
|
129
|
+
{timestamp: '2023-12-12T00:00:05.000Z', duration: 5, 'cpu/utilization': 12, carbon: 5, energy: 10, 'grid/carbon-intensity': 471},
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
# There are 5 seconds missing from the start and end. After padding, the array becomes:
|
|
133
|
+
|
|
134
|
+
[
|
|
135
|
+
{timestamp: '2023-12-12T00:00:00.000Z', duration: 1, 'cpu/utilization': 0, carbon: 0, energy: 0, grid/carbon-intensity: 471},
|
|
136
|
+
{timestamp: '2023-12-12T00:00:01.000Z', duration: 1, 'cpu/utilization': 0, carbon: 0, energy: 0, grid/carbon-intensity: 471},
|
|
137
|
+
{timestamp: '2023-12-12T00:00:02.000Z', duration: 1, 'cpu/utilization': 0, carbon: 0, energy: 0, grid/carbon-intensity: 471},
|
|
138
|
+
{timestamp: '2023-12-12T00:00:03.000Z', duration: 1, 'cpu/utilization': 0, carbon: 0, energy: 0, grid/carbon-intensity: 471},
|
|
139
|
+
{timestamp: '2023-12-12T00:00:04.000Z', duration: 1, 'cpu/utilization': 0, carbon: 0, energy: 0, grid/carbon-intensity: 471},
|
|
140
|
+
{timestamp: '2023-12-12T00:00:05.000Z', duration: 1, 'cpu/utilization': 12, carbon: 1, energy: 2, grid/carbon-intensity: 471},
|
|
141
|
+
{timestamp: '2023-12-12T00:00:06.000Z', duration: 1, 'cpu/utilization': 12, carbon: 1, energy: 2, grid/carbon-intensity: 471},
|
|
142
|
+
{timestamp: '2023-12-12T00:00:07.000Z', duration: 1, 'cpu/utilization': 12, carbon: 1, energy: 2, grid/carbon-intensity: 471},
|
|
143
|
+
{timestamp: '2023-12-12T00:00:08.000Z', duration: 1, 'cpu/utilization': 12, carbon: 1, energy: 2, grid/carbon-intensity: 471},
|
|
144
|
+
{timestamp: '2023-12-12T00:00:09.000Z', duration: 1, 'cpu/utilization': 12, carbon: 1, energy: 2, grid/carbon-intensity: 471},
|
|
145
|
+
{timestamp: '2023-12-12T00:00:10.000Z', duration: 1, 'cpu/utilization': 0, carbon: 0, energy: 0, grid/carbon-intensity: 471},
|
|
146
|
+
{timestamp: '2023-12-12T00:00:11.000Z', duration: 1, 'cpu/utilization': 0, carbon: 0, energy: 0, grid/carbon-intensity: 471},
|
|
147
|
+
{timestamp: '2023-12-12T00:00:12.000Z', duration: 1, 'cpu/utilization': 0, carbon: 0, energy: 0, grid/carbon-intensity: 471},
|
|
148
|
+
{timestamp: '2023-12-12T00:00:13.000Z', duration: 1, 'cpu/utilization': 0, carbon: 0, energy: 0, grid/carbon-intensity: 471},
|
|
149
|
+
{timestamp: '2023-12-12T00:00:14.000Z', duration: 1, 'cpu/utilization': 0, carbon: 0, energy: 0, grid/carbon-intensity: 471},
|
|
150
|
+
|
|
151
|
+
]
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Note that when `error-on-padding` is `true` no padding is performed and the plugin will error out instead.
|
|
155
|
+
|
|
156
|
+
##### Resampling rules
|
|
157
|
+
|
|
158
|
+
Now we have synchronized, continuous, high resolution time series data, we can resample. To achieve this, we use `interval`, which sets the global temporal resolution for the final, processed time series. `interval` is expressed in units of seconds, which means we can simply batch `observations` together in groups of size `interval`. For each value in each object we either sum, average or copy the values into one single summary object representing each time bucket of size `interval` depending on their `aggregation-method` defined in `aggregation` section in the manifest file. The returned array is the final, synchronized time series at the desired temporal resolution.
|
|
159
|
+
|
|
160
|
+
#### Assumptions and limitations
|
|
161
|
+
|
|
162
|
+
To do time synchronization, we assume:
|
|
163
|
+
|
|
164
|
+
- There is no environmental impact for an application when there is no data available.
|
|
165
|
+
- Evenly distributing the total for a `duration` across higher resolution `observations` is appropriate, as opposed to having some non-uniform distribution.
|
|
166
|
+
|
|
167
|
+
### Typescript implementation
|
|
168
|
+
|
|
169
|
+
To run the plugin, you must first create an instance of `TimeSync`.
|
|
170
|
+
Then, you can call `execute()`.
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
const globalConfig = {
|
|
174
|
+
'start-time': '2023-12-12T00:00:00.000Z',
|
|
175
|
+
'end-time': '2023-12-12T00:00:30.000Z',
|
|
176
|
+
interval: 10
|
|
177
|
+
}
|
|
178
|
+
const timeSync = TimeSync(globalConfig);
|
|
179
|
+
const results = timeSync.execute([
|
|
180
|
+
{
|
|
181
|
+
timestamp: '2023-12-12T00:00:00.000Z'
|
|
182
|
+
duration: 10
|
|
183
|
+
'cpu/utilization': 10
|
|
184
|
+
carbon: 100
|
|
185
|
+
energy: 100
|
|
186
|
+
requests: 300
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
timestamp: '2023-12-12T00:00:10.000Z'
|
|
190
|
+
duration: 10
|
|
191
|
+
'cpu/utilization': 20
|
|
192
|
+
carbon: 100,
|
|
193
|
+
energy: 100,
|
|
194
|
+
requests: 380
|
|
195
|
+
}
|
|
196
|
+
])
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Example manifest
|
|
200
|
+
|
|
201
|
+
IF users will typically call the plugin as part of a pipeline defined in an `manifest`
|
|
202
|
+
file. In this case, instantiating and configuring the plugin is handled by
|
|
203
|
+
`if-run` and does not have to be done explicitly by the user.
|
|
204
|
+
The following is an example `manifest` that calls `time-sync`:
|
|
205
|
+
|
|
206
|
+
```yaml
|
|
207
|
+
name: time-sync-demo
|
|
208
|
+
description: impl with 2 levels of nesting with non-uniform timing of observations
|
|
209
|
+
tags:
|
|
210
|
+
initialize:
|
|
211
|
+
plugins:
|
|
212
|
+
teads-curve:
|
|
213
|
+
method: TeadsCurve
|
|
214
|
+
path: '@grnsft/if-unofficial-plugins'
|
|
215
|
+
sci-e:
|
|
216
|
+
method: SciE
|
|
217
|
+
path: '@grnsft/if-plugins'
|
|
218
|
+
sci-embodied:
|
|
219
|
+
path: 'builtin'
|
|
220
|
+
method: SciEmbodied
|
|
221
|
+
sci-o:
|
|
222
|
+
method: SciO
|
|
223
|
+
path: '@grnsft/if-plugins'
|
|
224
|
+
time-sync:
|
|
225
|
+
method: TimeSync
|
|
226
|
+
path: builtin
|
|
227
|
+
global-config:
|
|
228
|
+
start-time: '2023-12-12T00:00:00.000Z' # ISO timestamp
|
|
229
|
+
end-time: '2023-12-12T00:01:00.000Z' # ISO timestamp
|
|
230
|
+
interval: 5 # seconds
|
|
231
|
+
tree:
|
|
232
|
+
children:
|
|
233
|
+
child: # an advanced grouping node
|
|
234
|
+
pipeline:
|
|
235
|
+
compute:
|
|
236
|
+
- teads-curve
|
|
237
|
+
- sci-e
|
|
238
|
+
- sci-embodied
|
|
239
|
+
- sci-o
|
|
240
|
+
- time-sync
|
|
241
|
+
config:
|
|
242
|
+
teads-curve:
|
|
243
|
+
cpu/thermal-design-power: 65
|
|
244
|
+
sci-embodied:
|
|
245
|
+
device/emissions-embodied: 251000 # gCO2eq
|
|
246
|
+
time-reserved: 3600 # 1 hour in s
|
|
247
|
+
device/expected-lifespan: 126144000 # 4 years in seconds
|
|
248
|
+
resources-reserved: 1
|
|
249
|
+
resources-total: 1
|
|
250
|
+
sci-o:
|
|
251
|
+
grid/carbon-intensity: 457 # gCO2/kwh
|
|
252
|
+
children:
|
|
253
|
+
child-1:
|
|
254
|
+
inputs:
|
|
255
|
+
- timestamp: '2023-12-12T00:00:00.000Z'
|
|
256
|
+
duration: 10
|
|
257
|
+
cpu/utilization: 10
|
|
258
|
+
carbon: 100
|
|
259
|
+
energy: 100
|
|
260
|
+
requests: 300
|
|
261
|
+
- timestamp: '2023-12-12T00:00:10.000Z'
|
|
262
|
+
duration: 10
|
|
263
|
+
cpu/utilization: 20
|
|
264
|
+
carbon: 200
|
|
265
|
+
energy: 200
|
|
266
|
+
requests: 380
|
|
267
|
+
```
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Coefficient = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const utils_1 = require("@grnsft/if-core/utils");
|
|
6
|
-
const validations_1 = require("../../util/validations");
|
|
7
|
-
const config_1 = require("../../config");
|
|
8
|
-
const { GlobalConfigError } = utils_1.ERRORS;
|
|
9
|
-
const { MISSING_GLOBAL_CONFIG } = config_1.STRINGS;
|
|
10
|
-
const Coefficient = (globalConfig) => {
|
|
11
|
-
const metadata = {
|
|
12
|
-
kind: 'execute',
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Calculate the product of each input parameter.
|
|
16
|
-
*/
|
|
17
|
-
const execute = (inputs) => {
|
|
18
|
-
const safeGlobalConfig = validateGlobalConfig();
|
|
19
|
-
const inputParameter = safeGlobalConfig['input-parameter'];
|
|
20
|
-
const outputParameter = safeGlobalConfig['output-parameter'];
|
|
21
|
-
const coefficient = safeGlobalConfig['coefficient'];
|
|
22
|
-
return inputs.map(input => {
|
|
23
|
-
validateSingleInput(input, inputParameter);
|
|
24
|
-
return {
|
|
25
|
-
...input,
|
|
26
|
-
[outputParameter]: calculateProduct(input, inputParameter, coefficient),
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Checks for required fields in input.
|
|
32
|
-
*/
|
|
33
|
-
const validateSingleInput = (input, inputParameter) => {
|
|
34
|
-
const inputData = {
|
|
35
|
-
'input-parameter': input[inputParameter],
|
|
36
|
-
};
|
|
37
|
-
const validationSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.number());
|
|
38
|
-
(0, validations_1.validate)(validationSchema, inputData);
|
|
39
|
-
return input;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Calculates the product of the energy components.
|
|
43
|
-
*/
|
|
44
|
-
const calculateProduct = (input, inputParameter, coefficient) => input[inputParameter] * coefficient;
|
|
45
|
-
/**
|
|
46
|
-
* Checks global config value are valid.
|
|
47
|
-
*/
|
|
48
|
-
const validateGlobalConfig = () => {
|
|
49
|
-
if (!globalConfig) {
|
|
50
|
-
throw new GlobalConfigError(MISSING_GLOBAL_CONFIG);
|
|
51
|
-
}
|
|
52
|
-
const globalConfigSchema = zod_1.z.object({
|
|
53
|
-
coefficient: zod_1.z.number(),
|
|
54
|
-
'input-parameter': zod_1.z.string().min(1),
|
|
55
|
-
'output-parameter': zod_1.z.string().min(1),
|
|
56
|
-
});
|
|
57
|
-
return (0, validations_1.validate)(globalConfigSchema, globalConfig);
|
|
58
|
-
};
|
|
59
|
-
return {
|
|
60
|
-
metadata,
|
|
61
|
-
execute,
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
exports.Coefficient = Coefficient;
|
|
65
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYnVpbHRpbnMvY29lZmZpY2llbnQvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsNkJBQXNCO0FBQ3RCLGlEQUE2QztBQU83Qyx3REFBZ0Q7QUFFaEQseUNBQXFDO0FBRXJDLE1BQU0sRUFBQyxpQkFBaUIsRUFBQyxHQUFHLGNBQU0sQ0FBQztBQUNuQyxNQUFNLEVBQUMscUJBQXFCLEVBQUMsR0FBRyxnQkFBTyxDQUFDO0FBRWpDLE1BQU0sV0FBVyxHQUFHLENBQUMsWUFBK0IsRUFBaUIsRUFBRTtJQUM1RSxNQUFNLFFBQVEsR0FBRztRQUNmLElBQUksRUFBRSxTQUFTO0tBQ2hCLENBQUM7SUFFRjs7T0FFRztJQUNILE1BQU0sT0FBTyxHQUFHLENBQUMsTUFBc0IsRUFBRSxFQUFFO1FBQ3pDLE1BQU0sZ0JBQWdCLEdBQUcsb0JBQW9C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b25maWdTY2hlbWEgPSB6Lm9iamVjdCh7XG4gICAgICBjb2VmZmljaWVudDogei5udW1iZXIoKSxcbiAgICAgICdpbnB1dC1wYXJhbWV0ZXInOiB6LnN0cmluZygpLm1pbigxKSxcbiAgICAgICdvdXRwdXQtcGFyYW1ldGVyJzogei5zdHJpbmcoKS5taW4oMSksXG4gICAgfSk7XG5cbiAgICByZXR1cm4gdmFsaWRhdGU8ei5pbmZlcjx0eXBlb2YgZ2xvYmFsQ29uZmlnU2NoZW1hPj4oXG4gICAgICBnbG9iYWxDb25maWdTY2hlbWEsXG4gICAgICBnbG9iYWxDb25maWdcbiAgICApO1xuICB9O1xuXG4gIHJldHVybiB7XG4gICAgbWV0YWRhdGEsXG4gICAgZXhlY3V0ZSxcbiAgfTtcbn07XG4iXX0=
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Copy = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const utils_1 = require("@grnsft/if-core/utils");
|
|
6
|
-
const validations_1 = require("../../util/validations");
|
|
7
|
-
const config_1 = require("../../config");
|
|
8
|
-
const { MISSING_GLOBAL_CONFIG } = config_1.STRINGS;
|
|
9
|
-
const { GlobalConfigError } = utils_1.ERRORS;
|
|
10
|
-
// keep-existing: true/false (whether to remove the parameter you are copying from)
|
|
11
|
-
// from-param: the parameter you are copying from (e.g. cpu/name)
|
|
12
|
-
// to-field: the parameter you are copying to (e.g. cpu/processor-name)
|
|
13
|
-
const Copy = (globalConfig) => {
|
|
14
|
-
const metadata = {
|
|
15
|
-
kind: 'execute',
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Checks global config value are valid.
|
|
19
|
-
*/
|
|
20
|
-
const validateGlobalConfig = () => {
|
|
21
|
-
if (!globalConfig) {
|
|
22
|
-
throw new GlobalConfigError(MISSING_GLOBAL_CONFIG);
|
|
23
|
-
}
|
|
24
|
-
const globalConfigSchema = zod_1.z.object({
|
|
25
|
-
'keep-existing': zod_1.z.boolean(),
|
|
26
|
-
from: zod_1.z.string().min(1),
|
|
27
|
-
to: zod_1.z.string().min(1),
|
|
28
|
-
});
|
|
29
|
-
return (0, validations_1.validate)(globalConfigSchema, globalConfig);
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Checks for required fields in input.
|
|
33
|
-
*/
|
|
34
|
-
const validateSingleInput = (input, inputParameters) => {
|
|
35
|
-
const inputData = inputParameters.reduce((acc, param) => {
|
|
36
|
-
acc[param] = input[param];
|
|
37
|
-
return acc;
|
|
38
|
-
}, {});
|
|
39
|
-
const validationSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.string());
|
|
40
|
-
(0, validations_1.validate)(validationSchema, inputData);
|
|
41
|
-
return input;
|
|
42
|
-
};
|
|
43
|
-
const execute = (inputs) => {
|
|
44
|
-
const safeGlobalConfig = validateGlobalConfig();
|
|
45
|
-
const keepExisting = safeGlobalConfig['keep-existing'] === true;
|
|
46
|
-
const from = safeGlobalConfig['from'];
|
|
47
|
-
const to = safeGlobalConfig['to'];
|
|
48
|
-
return inputs.map(input => {
|
|
49
|
-
const safeInput = validateSingleInput(input, [from]);
|
|
50
|
-
const outputValue = safeInput[from];
|
|
51
|
-
if (safeInput[from]) {
|
|
52
|
-
if (!keepExisting) {
|
|
53
|
-
delete safeInput[from];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
...safeInput,
|
|
58
|
-
[to]: outputValue,
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
return {
|
|
63
|
-
metadata,
|
|
64
|
-
execute,
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
exports.Copy = Copy;
|
|
68
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6Wy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