From b69080e50d7582446e735392159f15b7433707af Mon Sep 17 00:00:00 2001 From: Valentin Reis Date: Wed, 28 Oct 2020 10:31:17 -0500 Subject: [PATCH] [refactor] config file format simplifications, adding example fixes/tests. This is a minor refactor of the config file formats. It comes with additional CI tests on the "examples" root directory. --- .gitlab-ci.dhall | 1 + .gitlab-ci.yml | 6 + Makefile | 5 + README.md | 7 +- examples/nrmd/control.dhall | 3 +- examples/nrmd/control.json | 3 + examples/nrmd/control.yaml | 2 + examples/nrmd/extra-static-actuator.dhall | 4 +- examples/nrmd/extra-static-actuator.json | 4 +- examples/nrmd/extra-static-actuator.yaml | 4 +- examples/nrmd/extra-static-sensor.dhall | 4 +- examples/nrmd/extra-static-sensor.json | 4 +- examples/nrmd/extra-static-sensor.yaml | 4 +- ...iorum-two-package-power-limit-sensor.dhall | 8 +- ...riorum-two-package-power-limit-sensor.json | 8 +- ...riorum-two-package-power-limit-sensor.yaml | 8 +- ...um-two-package-power-limits-actuator.dhall | 4 +- ...rum-two-package-power-limits-actuator.json | 4 +- ...rum-two-package-power-limits-actuator.yaml | 4 +- ...iorum-two-package-power-value-sensor.dhall | 8 +- ...riorum-two-package-power-value-sensor.json | 8 +- ...riorum-two-package-power-value-sensor.yaml | 8 +- hsnrm/.hlint.yaml | 1 + hsnrm/hsnrm/dhall/defaults/nrmd.dhall | 4 +- hsnrm/hsnrm/dhall/types/nrmd.dhall | 36 +- hsnrm/hsnrm/hsnrm.cabal | 2 +- hsnrm/hsnrm/src/NRM/CPD.hs | 2 +- hsnrm/hsnrm/src/NRM/Codegen.hs | 34 +- hsnrm/hsnrm/src/NRM/State.hs | 4 +- hsnrm/hsnrm/src/NRM/Types/Configuration.hs | 58 +- hsnrm/hsnrm/src/NRM/Types/DownstreamCmd.hs | 2 +- hsnrm/hsnrm/src/NRM/Types/DownstreamThread.hs | 2 +- hsnrm/hsnrm/src/NRM/Types/Manifest.hs | 4 - hsnrm/hsnrm/src/NRM/Types/Topology/Package.hs | 2 +- hsnrm/hsnrm/src/NRM/Types/Units.hs | 16 +- resources/defaults/manifest.json | 9 +- resources/defaults/nrmd.json | 7 +- resources/schemas/manifest.json | 183 ------ resources/schemas/nrmd.json | 540 ------------------ resources/schemas/upstream-rep.json | 40 +- tests/example-test.sh | 26 + 41 files changed, 201 insertions(+), 882 deletions(-) delete mode 100644 resources/schemas/manifest.json delete mode 100644 resources/schemas/nrmd.json create mode 100755 tests/example-test.sh diff --git a/.gitlab-ci.dhall b/.gitlab-ci.dhall index 218d9da..f3cdd68 100644 --- a/.gitlab-ci.dhall +++ b/.gitlab-ci.dhall @@ -34,6 +34,7 @@ in { stages = [ "source", "build", "test", "deploy" ] , tests/apps = mkT "app-tests" , tests/rapl = mkT "tests-rapl" ⫽ { tags = [ "chimera" ] } , tests/perf = mkT "tests-perf" ⫽ { tags = [ "chimera" ] } + , examples = mkT "examples" , libnrm/autotools = mkB "libnrm/autotools" , hsnrm/all = mkB "hsnrm/all" , resources = mkS "resources" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7ee661f..4173e2f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,6 +5,12 @@ dhall-format: tags: - nix - kvm +examples: + script: "nix-shell -p gnumake --run 'make examples'" + stage: test + tags: + - nix + - kvm hsnrm-/dhall-format: script: "nix-shell -p gnumake --run 'make hsnrm/dhall-format'" stage: source diff --git a/Makefile b/Makefile index ef20116..dc9d592 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,7 @@ pre-commit: hsnrm/pre-commit\ pynrm/pre-commit\ libnrm/pre-commit\ dhall-format\ + examples\ shellcheck\ nixfmt\ resource-propagation\ @@ -124,6 +125,10 @@ resources: cd hsnrm; cabal v2-run hsnrm-extra/Codegen.hs ../resources ' +.PHONY: examples +examples: + @nix-shell --pure -p yq -p dhall -p haskellPackages.dhall-json --run ./tests/example-test.sh + ############################# SECTION: libnrm pseudo-recursive targets (directory uses autotools) libnrm/all: libnrm/autotools diff --git a/README.md b/README.md index 4ac109e..0d11b7d 100644 --- a/README.md +++ b/README.md @@ -30,14 +30,13 @@ nrm --help JSON schemas (raw) and Dhall types (documented with comments, for now) are available. -when using JSON/YAML, -- JSON schemas: `resources/schemas/{nrmd,manifest}.json` -- default values: `resources/defauts/{nrmd,manifest}.json` - when using Dhall, - types: `hsnrm/hsnrm/dhall/types/{nrmd,manifest}.dhall` - default values: `hsnrm/hsnrm/dhall/defaults/{nrmd,manifest}.dhall` +when using JSON/YAML, +- default values: `resources/defauts/{nrmd,manifest}.json` + Example `nrmd` configurations and `nrm` manifests are available in the `examples` folder in JSON,YAML and Dhall format. diff --git a/examples/nrmd/control.dhall b/examples/nrmd/control.dhall index f540125..6f19f56 100644 --- a/examples/nrmd/control.dhall +++ b/examples/nrmd/control.dhall @@ -15,12 +15,13 @@ in default , controlCfg = types.ControlCfg.ControlCfg { minimumControlInterval.microseconds = 100000.0 + , minimumWaitInterval.microseconds = 100000.0 , staticPower.microwatts = 2.0e8 , learnCfg = types.LearnCfg.Contextual { horizon = +4000 } , speedThreshold = 1.1 , referenceMeasurementRoundInterval = +6 , hint = types.Hint.Full } - , activeSensorFrequency.hertz = 1.0 + , passiveSensorFrequency.hertz = 1.0 } : types.Cfg diff --git a/examples/nrmd/control.json b/examples/nrmd/control.json index 613f43a..4985b1e 100644 --- a/examples/nrmd/control.json +++ b/examples/nrmd/control.json @@ -7,6 +7,9 @@ "learnCfg": { "horizon": 4000 }, + "minimumWaitInterval": { + "microseconds": 100000 + }, "minimumControlInterval": { "microseconds": 100000 }, diff --git a/examples/nrmd/control.yaml b/examples/nrmd/control.yaml index 4770cf2..e8ba691 100644 --- a/examples/nrmd/control.yaml +++ b/examples/nrmd/control.yaml @@ -4,6 +4,8 @@ controlCfg: hint: Full learnCfg: horizon: 4000 + minimumWaitInterval: + microseconds: 100000 minimumControlInterval: microseconds: 100000 referenceMeasurementRoundInterval: 6 diff --git a/examples/nrmd/extra-static-actuator.dhall b/examples/nrmd/extra-static-actuator.dhall index 5e49d37..ea3f2e4 100644 --- a/examples/nrmd/extra-static-actuator.dhall +++ b/examples/nrmd/extra-static-actuator.dhall @@ -4,8 +4,8 @@ let default = ../../hsnrm/hsnrm/dhall/defaults/nrmd.dhall in default ⫽ { extraStaticActuators = - [ { staticActuatorKey = "example extra actuator ID" - , staticActuatorValue = + [ { actuatorID = "example extra actuator ID" + , actuator = { actuatorBinary = "bash" , actuatorArguments = [ "-c" diff --git a/examples/nrmd/extra-static-actuator.json b/examples/nrmd/extra-static-actuator.json index 9ebb410..923b86a 100644 --- a/examples/nrmd/extra-static-actuator.json +++ b/examples/nrmd/extra-static-actuator.json @@ -1,8 +1,8 @@ { "extraStaticActuators": [ { - "staticActuatorKey": "example extra actuator ID", - "staticActuatorValue": { + "actuatorID": "example extra actuator ID", + "actuator": { "actions": [ 1, 2 diff --git a/examples/nrmd/extra-static-actuator.yaml b/examples/nrmd/extra-static-actuator.yaml index 7fa100a..c2ae00a 100644 --- a/examples/nrmd/extra-static-actuator.yaml +++ b/examples/nrmd/extra-static-actuator.yaml @@ -1,6 +1,6 @@ extraStaticActuators: - - staticActuatorKey: "example extra actuator ID" - staticActuatorValue: + - actuatorID: "example extra actuator ID" + actuator: actions: - 1 - 2 diff --git a/examples/nrmd/extra-static-sensor.dhall b/examples/nrmd/extra-static-sensor.dhall index 2a19675..5b80605 100644 --- a/examples/nrmd/extra-static-sensor.dhall +++ b/examples/nrmd/extra-static-sensor.dhall @@ -4,8 +4,8 @@ let default = ../../hsnrm/hsnrm/dhall/defaults/nrmd.dhall in default ⫽ { extraStaticPassiveSensors = - [ { passiveSensorKey = "example extra static passive power sensor" - , passiveSensorValue = + [ { sensorID = "example extra static passive power sensor" + , sensor = { sensorBinary = "echo" , sensorArguments = [ "30" ] , range = { lower = 1.0, upper = 40.0 } diff --git a/examples/nrmd/extra-static-sensor.json b/examples/nrmd/extra-static-sensor.json index 4b7ea9c..c98f05c 100644 --- a/examples/nrmd/extra-static-sensor.json +++ b/examples/nrmd/extra-static-sensor.json @@ -1,8 +1,8 @@ { "extraStaticPassiveSensors": [ { - "passiveSensorKey": "example extra static passive power sensor", - "passiveSensorValue": { + "sensorID": "example extra static passive power sensor", + "sensor": { "range": { "lower": 1, "upper": 40 diff --git a/examples/nrmd/extra-static-sensor.yaml b/examples/nrmd/extra-static-sensor.yaml index 56dfdb4..3f9584e 100644 --- a/examples/nrmd/extra-static-sensor.yaml +++ b/examples/nrmd/extra-static-sensor.yaml @@ -1,6 +1,6 @@ extraStaticPassiveSensors: - - passiveSensorKey: "example extra static passive power sensor" - passiveSensorValue: + - sensorID: "example extra static passive power sensor" + sensor: range: lower: 1 upper: 40 diff --git a/examples/nrmd/variorum-two-package-power-limit-sensor.dhall b/examples/nrmd/variorum-two-package-power-limit-sensor.dhall index 4de114a..76d3ba4 100644 --- a/examples/nrmd/variorum-two-package-power-limit-sensor.dhall +++ b/examples/nrmd/variorum-two-package-power-limit-sensor.dhall @@ -4,9 +4,9 @@ let default = ../../hsnrm/hsnrm/dhall/defaults/nrmd.dhall in default ⫽ { extraStaticPassiveSensors = - [ { passiveSensorKey = + [ { sensorID = "Sensor that gets package power limits for package 0 through variorum" - , passiveSensorValue = + , sensor = { sensorBinary = "bash" , sensorArguments = [ "-c" @@ -17,9 +17,9 @@ in default , sensorBehavior = types.SensorBehavior.IntervalBased } } - , { passiveSensorKey = + , { sensorID = "Sensor that gets package power limits for package 1 through variorum" - , passiveSensorValue = + , sensor = { sensorBinary = "bash" , sensorArguments = [ "-c" diff --git a/examples/nrmd/variorum-two-package-power-limit-sensor.json b/examples/nrmd/variorum-two-package-power-limit-sensor.json index 728aab9..6437eb9 100644 --- a/examples/nrmd/variorum-two-package-power-limit-sensor.json +++ b/examples/nrmd/variorum-two-package-power-limit-sensor.json @@ -1,8 +1,8 @@ { "extraStaticPassiveSensors": [ { - "passiveSensorKey": "Sensor that gets package power limits for package 0 through variorum", - "passiveSensorValue": { + "sensorID": "Sensor that gets package power limits for package 0 through variorum", + "sensor": { "range": { "lower": 1, "upper": 40 @@ -17,8 +17,8 @@ } }, { - "passiveSensorKey": "Sensor that gets package power limits for package 1 through variorum", - "passiveSensorValue": { + "sensorID": "Sensor that gets package power limits for package 1 through variorum", + "sensor": { "range": { "lower": 1, "upper": 40 diff --git a/examples/nrmd/variorum-two-package-power-limit-sensor.yaml b/examples/nrmd/variorum-two-package-power-limit-sensor.yaml index 4bcb1df..ee47628 100644 --- a/examples/nrmd/variorum-two-package-power-limit-sensor.yaml +++ b/examples/nrmd/variorum-two-package-power-limit-sensor.yaml @@ -1,6 +1,6 @@ extraStaticPassiveSensors: - - passiveSensorKey: "Sensor that gets package power limits for package 0 through variorum" - passiveSensorValue: + - sensorID: "Sensor that gets package power limits for package 0 through variorum" + sensor: range: lower: 1 upper: 40 @@ -10,8 +10,8 @@ extraStaticPassiveSensors: sensorBehavior: IntervalBased sensorBinary: bash tags: [] - - passiveSensorKey: "Sensor that gets package power limits for package 1 through variorum" - passiveSensorValue: + - sensorID: "Sensor that gets package power limits for package 1 through variorum" + sensor: range: lower: 1 upper: 40 diff --git a/examples/nrmd/variorum-two-package-power-limits-actuator.dhall b/examples/nrmd/variorum-two-package-power-limits-actuator.dhall index 170d034..c7474a7 100644 --- a/examples/nrmd/variorum-two-package-power-limits-actuator.dhall +++ b/examples/nrmd/variorum-two-package-power-limits-actuator.dhall @@ -4,8 +4,8 @@ let default = ../../hsnrm/hsnrm/dhall/defaults/nrmd.dhall in default ⫽ { extraStaticActuators = - [ { staticActuatorKey = "example extra actuator" - , staticActuatorValue = + [ { actuatorID = "example extra actuator" + , actuator = { actuatorBinary = "variorum-set-socket-power-limits-example" , actuatorArguments = [] : List Text , actions = [ 100.0, 150.0 ] diff --git a/examples/nrmd/variorum-two-package-power-limits-actuator.json b/examples/nrmd/variorum-two-package-power-limits-actuator.json index aa55f91..9bdde1c 100644 --- a/examples/nrmd/variorum-two-package-power-limits-actuator.json +++ b/examples/nrmd/variorum-two-package-power-limits-actuator.json @@ -1,8 +1,8 @@ { "extraStaticActuators": [ { - "staticActuatorKey": "example extra actuator", - "staticActuatorValue": { + "actuatorID": "example extra actuator", + "actuator": { "actions": [ 100, 150 diff --git a/examples/nrmd/variorum-two-package-power-limits-actuator.yaml b/examples/nrmd/variorum-two-package-power-limits-actuator.yaml index 8718b1c..ccf5d98 100644 --- a/examples/nrmd/variorum-two-package-power-limits-actuator.yaml +++ b/examples/nrmd/variorum-two-package-power-limits-actuator.yaml @@ -1,6 +1,6 @@ extraStaticActuators: - - staticActuatorKey: "example extra actuator" - staticActuatorValue: + - actuatorID: "example extra actuator" + actuator: actions: - 100 - 150 diff --git a/examples/nrmd/variorum-two-package-power-value-sensor.dhall b/examples/nrmd/variorum-two-package-power-value-sensor.dhall index f6d5aa5..ad614c6 100644 --- a/examples/nrmd/variorum-two-package-power-value-sensor.dhall +++ b/examples/nrmd/variorum-two-package-power-value-sensor.dhall @@ -4,9 +4,9 @@ let default = ../../hsnrm/hsnrm/dhall/defaults/nrmd.dhall in default ⫽ { extraStaticPassiveSensors = - [ { passiveSensorKey = + [ { sensorID = "Sensor that gets package power limits for package 0 through variorum" - , passiveSensorValue = + , sensor = { sensorBinary = "bash" , sensorArguments = [ "-c" @@ -17,9 +17,9 @@ in default , sensorBehavior = types.SensorBehavior.Cumulative } } - , { passiveSensorKey = + , { sensorID = "Sensor that gets package power limits for package 1 through variorum" - , passiveSensorValue = + , sensor = { sensorBinary = "bash" , sensorArguments = [ "-c" diff --git a/examples/nrmd/variorum-two-package-power-value-sensor.json b/examples/nrmd/variorum-two-package-power-value-sensor.json index 82f452c..ac39894 100644 --- a/examples/nrmd/variorum-two-package-power-value-sensor.json +++ b/examples/nrmd/variorum-two-package-power-value-sensor.json @@ -1,8 +1,8 @@ { "extraStaticPassiveSensors": [ { - "passiveSensorKey": "Sensor that gets package power limits for package 0 through variorum", - "passiveSensorValue": { + "sensorID": "Sensor that gets package power limits for package 0 through variorum", + "sensor": { "range": { "lower": 1, "upper": 40 @@ -19,8 +19,8 @@ } }, { - "passiveSensorKey": "Sensor that gets package power limits for package 1 through variorum", - "passiveSensorValue": { + "sensorID": "Sensor that gets package power limits for package 1 through variorum", + "sensor": { "range": { "lower": 1, "upper": 40 diff --git a/examples/nrmd/variorum-two-package-power-value-sensor.yaml b/examples/nrmd/variorum-two-package-power-value-sensor.yaml index 098972f..ee9ac6e 100644 --- a/examples/nrmd/variorum-two-package-power-value-sensor.yaml +++ b/examples/nrmd/variorum-two-package-power-value-sensor.yaml @@ -1,6 +1,6 @@ extraStaticPassiveSensors: - - passiveSensorKey: "Sensor that gets package power limits for package 0 through variorum" - passiveSensorValue: + - sensorID: "Sensor that gets package power limits for package 0 through variorum" + sensor: range: lower: 1 upper: 40 @@ -11,8 +11,8 @@ extraStaticPassiveSensors: sensorBinary: bash tags: - TagPower - - passiveSensorKey: "Sensor that gets package power limits for package 1 through variorum" - passiveSensorValue: + - sensorID: "Sensor that gets package power limits for package 1 through variorum" + sensor: range: lower: 1 upper: 40 diff --git a/hsnrm/.hlint.yaml b/hsnrm/.hlint.yaml index 9309133..fe1a886 100644 --- a/hsnrm/.hlint.yaml +++ b/hsnrm/.hlint.yaml @@ -6,6 +6,7 @@ - extensions: - default: false - name: [DerivingVia] + - name: [NumericUnderscores] - name: [NoOverloadedLists] - name: [QuasiQuotes] - name: [ScopedTypeVariables] diff --git a/hsnrm/hsnrm/dhall/defaults/nrmd.dhall b/hsnrm/hsnrm/dhall/defaults/nrmd.dhall index 349c75f..0c5df8a 100644 --- a/hsnrm/hsnrm/dhall/defaults/nrmd.dhall +++ b/hsnrm/hsnrm/dhall/defaults/nrmd.dhall @@ -22,7 +22,7 @@ in { verbose = t.Verbosity.Error , hwmonCfg = { hwmonEnabled = True, hwmonPath = "/sys/class/hwmon" } , controlCfg = t.ControlCfg.ControlOff , passiveSensorFrequency.hertz = 1.0 - , extraStaticPassiveSensors = [] : List t.PassiveSensorKV - , extraStaticActuators = [] : List t.StaticActuatorKV + , extraStaticPassiveSensors = [] : List t.SensorKV + , extraStaticActuators = [] : List t.ActuatorKV } : t.Cfg diff --git a/hsnrm/hsnrm/dhall/types/nrmd.dhall b/hsnrm/hsnrm/dhall/types/nrmd.dhall index 35a7b78..f90104a 100644 --- a/hsnrm/hsnrm/dhall/types/nrmd.dhall +++ b/hsnrm/hsnrm/dhall/types/nrmd.dhall @@ -37,11 +37,11 @@ let Tag = -- Available tags for describing sensors. Tags are used for setting -- objective functions up. < TagPower - | Rapl - | DownstreamThreadSignal - | DownstreamCmdSignal - | Minimize - | Maximize + | TagRapl + | TagDownstreamThreadSignal + | TagDownstreamCmdSignal + | TagMinimize + | TagMaximize > let Sensor = @@ -61,15 +61,17 @@ let Actuator = , referenceAction : Double } -let StaticActuatorKV = +let ActuatorKV = -- Key-value representation for an actuator. - { staticActuatorKey : Text, staticActuatorValue : Actuator } + { actuatorID : Text, actuator : Actuator } -let PassiveSensorKV = - -- Key-value representation for a passive sensor. - { passiveSensorKey : Text, passiveSensorValue : Sensor } +let SensorKV = + -- Key-value representation for a sensor. + { sensorID : Text, sensor : Sensor } -let Hwmon = { hwmonEnabled : Bool, hwmonPath : Text } +let Hwmon = + --- Temperature sensor config (imported from NRM1, placeholder) + { hwmonEnabled : Bool, hwmonPath : Text } let RaplCfg = -- Configuration for auto-discovered RAPL power sensors/actuators @@ -80,7 +82,7 @@ let RaplCfg = let ActuatorValue = -- Actuator value configuration for the internal control loop configuration. - { actuatorID : Text, actuatorValue : Double } + { actuatorValueID : Text, actuatorValue : Double } let Hint = -- Action space configuration for internal control loop. @@ -131,8 +133,8 @@ let Cfg = , hwmonCfg : Hwmon , controlCfg : ControlCfg , passiveSensorFrequency : types.Frequency - , extraStaticPassiveSensors : List PassiveSensorKV - , extraStaticActuators : List StaticActuatorKV + , extraStaticPassiveSensors : List SensorKV + , extraStaticActuators : List ActuatorKV } let output = @@ -142,9 +144,9 @@ let output = , Tag = Tag , SensorBehavior = SensorBehavior , Actuator = Actuator - , PassiveSensorKV = PassiveSensorKV - , PassiveSensor = Sensor - , StaticActuatorKV = StaticActuatorKV + , SensorKV = SensorKV + , Sensor = Sensor + , ActuatorKV = ActuatorKV , Range = Range , PassiveSensorCfg = Sensor , ActuatorValue = ActuatorValue diff --git a/hsnrm/hsnrm/hsnrm.cabal b/hsnrm/hsnrm/hsnrm.cabal index c65af01..d9ce88d 100644 --- a/hsnrm/hsnrm/hsnrm.cabal +++ b/hsnrm/hsnrm/hsnrm.cabal @@ -110,7 +110,7 @@ library OverloadedLabels DeriveFoldable DerivingStrategies TypeApplications MultiWayIf NoTemplateHaskell BlockArguments GADTs FlexibleContexts TypeOperators DataKinds PolyKinds AllowAmbiguousTypes - FunctionalDependencies UndecidableInstances CPP + FunctionalDependencies UndecidableInstances NumericUnderscores ghc-options: -Wall -O0 -Wcompat -Wincomplete-uni-patterns -Wmissing-home-modules -Widentities -Wredundant-constraints -Wcpp-undef -fwarn-tabs -fwarn-unused-imports diff --git a/hsnrm/hsnrm/src/NRM/CPD.hs b/hsnrm/hsnrm/src/NRM/CPD.hs index 8311ec9..3585900 100644 --- a/hsnrm/hsnrm/src/NRM/CPD.hs +++ b/hsnrm/hsnrm/src/NRM/CPD.hs @@ -79,7 +79,7 @@ throughputConstrained cfg st = constrained :: Map SensorID SensorMeta constrained = M.filterWithKey - (\_ m -> DownstreamCmdSignal `elem` S.tags m) + (\_ m -> TagDownstreamCmdSignal `elem` S.tags m) allSensorMeta allSensorMeta :: Map SensorID S.SensorMeta allSensorMeta = diff --git a/hsnrm/hsnrm/src/NRM/Codegen.hs b/hsnrm/hsnrm/src/NRM/Codegen.hs index db2e70c..c4c5eaf 100644 --- a/hsnrm/hsnrm/src/NRM/Codegen.hs +++ b/hsnrm/hsnrm/src/NRM/Codegen.hs @@ -11,8 +11,6 @@ module NRM.Codegen upstreamReqSchema, upstreamRepSchema, downstreamEventSchema, - manifestSchema, - configurationSchema, libnrmHeader, licenseC, ) @@ -20,11 +18,11 @@ where import Codegen.CHeader import Codegen.Schema (generatePretty) -import Codegen.Schema as CS import Data.Aeson.Encode.Pretty as AP (encodePretty) import Data.Default import Data.JSON.Schema as S import Dhall +import Dhall.JSON as DJ import NRM.Messaging import qualified NRM.Types.Configuration as C import qualified NRM.Types.Manifest as MI @@ -47,10 +45,24 @@ main = do verboseWrite (prefix <> "/schemas") "upstream-rep" upstreamRepSchema verboseWrite (prefix <> "/schemas") "upstream-req" upstreamReqSchema verboseWrite (prefix <> "/schemas") "downstream" downstreamEventSchema - verboseWrite (prefix <> "/schemas") "manifest" manifestSchema - verboseWrite (prefix <> "/schemas") "nrmd" configurationSchema - verboseWrite (prefix <> "/defaults") "nrmd" (toS $ AP.encodePretty (def :: C.Cfg)) - verboseWrite (prefix <> "/defaults") "manifest" (toS $ AP.encodePretty (def :: MI.Manifest)) + verboseWrite + (prefix <> "/defaults") + "nrmd" + ( toS + . AP.encodePretty + . fromRight (panic "generatio error") + . dhallToJSON + $ Dhall.embed Dhall.inject (def :: C.Cfg) + ) + verboseWrite + (prefix <> "/defaults") + "manifest" + ( toS + . AP.encodePretty + . fromRight (panic "generatio error") + . dhallToJSON + $ Dhall.embed Dhall.inject (def :: MI.Manifest) + ) where verboseWrite :: Text -> Text -> Text -> IO () verboseWrite prefix desc sch = do @@ -75,14 +87,6 @@ upstreamPubSchema = generatePretty (Proxy :: Proxy Pub) downstreamEventSchema :: Text downstreamEventSchema = generatePretty (Proxy :: Proxy Event) --- | The manifest schema. -manifestSchema :: Text -manifestSchema = toS . AP.encodePretty . CS.toAeson $ S.schema (Proxy :: Proxy MI.Manifest) - --- | The configuration schema. -configurationSchema :: Text -configurationSchema = toS . AP.encodePretty . CS.toAeson $ S.schema (Proxy :: Proxy C.Cfg) - -- | The libnrm C header. libnrmHeader :: Text libnrmHeader = toS $ toCHeader (Proxy :: Proxy Down.Event) diff --git a/hsnrm/hsnrm/src/NRM/State.hs b/hsnrm/hsnrm/src/NRM/State.hs index c9aef0c..ce9917f 100644 --- a/hsnrm/hsnrm/src/NRM/State.hs +++ b/hsnrm/hsnrm/src/NRM/State.hs @@ -117,11 +117,11 @@ initialState c time = do else Nothing, extraStaticActuators = Cfg.extraStaticActuators c - & fmap (\(Cfg.StaticActuatorKV k v) -> (k, v)) + & fmap (\Cfg.ActuatorKV {actuatorID, actuator} -> (actuatorID, actuator)) & M.fromList, extraStaticPassiveSensors = ( Cfg.extraStaticPassiveSensors c - & fmap (\(Cfg.PassiveSensorKV k v) -> (k, v)) + & fmap (\Cfg.SensorKV {sensorID, sensor} -> (sensorID, sensor)) & M.fromList ) <&> concretizeExtraPassiveSensor diff --git a/hsnrm/hsnrm/src/NRM/Types/Configuration.hs b/hsnrm/hsnrm/src/NRM/Types/Configuration.hs index c300295..cb16be8 100644 --- a/hsnrm/hsnrm/src/NRM/Types/Configuration.hs +++ b/hsnrm/hsnrm/src/NRM/Types/Configuration.hs @@ -17,8 +17,8 @@ module NRM.Types.Configuration RaplCfg (..), HwmonCfg (..), ExtraPassiveSensor (..), - StaticActuatorKV (..), - PassiveSensorKV (..), + ActuatorKV (..), + SensorKV (..), Power (..), Tag (..), Hint (..), @@ -35,10 +35,8 @@ module NRM.Types.Configuration ) where --- examples, - import CPD.Core -import CPD.Values +import CPD.Values hiding (actuatorValue) import Data.Aeson import Data.Default import Data.Either.Validation as V @@ -80,9 +78,9 @@ makeHaskellTypes $ dRec "Cfg" "Cfg", dSum "ControlCfg" "ControlCfg", dSum "LearnCfg" "LearnCfg", - dRec "StaticActuatorKV" "StaticActuatorKV", - dRec "PassiveSensorKV" "PassiveSensorKV", - dRec "ExtraPassiveSensor" "PassiveSensor", + dRec "ActuatorKV" "ActuatorKV", + dRec "SensorKV" "SensorKV", + dRec "ExtraPassiveSensor" "Sensor", dRec "DownstreamCfg" "DownstreamCfg", dSum "SensorBehavior" "SensorBehavior", dRec "UpstreamCfg" "UpstreamCfg", @@ -109,7 +107,7 @@ toRange :: Interval Double -> Range toRange i = Range (inf i) (sup i) toAction :: ActuatorValue -> Action -toAction (ActuatorValue i v) = Action (ActuatorID i) (DiscreteDouble v) +toAction a = Action (ActuatorID $ actuatorValueID a) (DiscreteDouble $ actuatorValue a) toTime :: Time -> U.Time toTime t@Time {} = U.uS $ microseconds t @@ -260,25 +258,25 @@ deriving via (GenericJSON ExtraPassiveSensor) instance ToJSON ExtraPassiveSensor deriving via (GenericJSON ExtraPassiveSensor) instance JSONSchema ExtraPassiveSensor -deriving instance Generic PassiveSensorKV +deriving instance Generic SensorKV -deriving instance Eq PassiveSensorKV +deriving instance Eq SensorKV -deriving instance Ord PassiveSensorKV +deriving instance Ord SensorKV -deriving instance Show PassiveSensorKV +deriving instance Show SensorKV -deriving instance MessagePack PassiveSensorKV +deriving instance MessagePack SensorKV -deriving instance FromDhall PassiveSensorKV +deriving instance FromDhall SensorKV -deriving instance ToDhall PassiveSensorKV +deriving instance ToDhall SensorKV -deriving via (GenericJSON PassiveSensorKV) instance FromJSON PassiveSensorKV +deriving via (GenericJSON SensorKV) instance FromJSON SensorKV -deriving via (GenericJSON PassiveSensorKV) instance ToJSON PassiveSensorKV +deriving via (GenericJSON SensorKV) instance ToJSON SensorKV -deriving via (GenericJSON PassiveSensorKV) instance JSONSchema PassiveSensorKV +deriving via (GenericJSON SensorKV) instance JSONSchema SensorKV deriving instance Generic ExtraActuator @@ -320,25 +318,25 @@ deriving via (GenericJSON DownstreamCfg) instance ToJSON DownstreamCfg deriving via (GenericJSON DownstreamCfg) instance JSONSchema DownstreamCfg -deriving instance Generic StaticActuatorKV +deriving instance Generic ActuatorKV -deriving instance Eq StaticActuatorKV +deriving instance Eq ActuatorKV -deriving instance Ord StaticActuatorKV +deriving instance Ord ActuatorKV -deriving instance Show StaticActuatorKV +deriving instance Show ActuatorKV -deriving instance MessagePack StaticActuatorKV +deriving instance MessagePack ActuatorKV -deriving instance FromDhall StaticActuatorKV +deriving instance FromDhall ActuatorKV -deriving instance ToDhall StaticActuatorKV +deriving instance ToDhall ActuatorKV -deriving via (GenericJSON StaticActuatorKV) instance FromJSON StaticActuatorKV +deriving via (GenericJSON ActuatorKV) instance FromJSON ActuatorKV -deriving via (GenericJSON StaticActuatorKV) instance ToJSON StaticActuatorKV +deriving via (GenericJSON ActuatorKV) instance ToJSON ActuatorKV -deriving via (GenericJSON StaticActuatorKV) instance JSONSchema StaticActuatorKV +deriving via (GenericJSON ActuatorKV) instance JSONSchema ActuatorKV deriving instance Generic Power @@ -521,4 +519,4 @@ deriving via (GenericJSON Cfg) instance ToJSON Cfg deriving via (GenericJSON Cfg) instance JSONSchema Cfg jsonOptions :: Options -jsonOptions = defaultOptions {omitNothingFields = False} +jsonOptions = defaultOptions diff --git a/hsnrm/hsnrm/src/NRM/Types/DownstreamCmd.hs b/hsnrm/hsnrm/src/NRM/Types/DownstreamCmd.hs index fe93b82..2060fdd 100644 --- a/hsnrm/hsnrm/src/NRM/Types/DownstreamCmd.hs +++ b/hsnrm/hsnrm/src/NRM/Types/DownstreamCmd.hs @@ -51,7 +51,7 @@ instance getter (DownstreamCmd _maxValue ratelimit dtLastRef lastRead) = ActiveSensor { activeMeta = SensorMeta - { tags = [Maximize, DownstreamCmdSignal], + { tags = [TagMaximize, TagDownstreamCmdSignal], range = 0 ... (maxValue downstreamCmd & fromOps & fromIntegral), lastReferenceMeasurements = dtLastRef, last = lastRead <&> fmap (fromIntegral . fromProgress), diff --git a/hsnrm/hsnrm/src/NRM/Types/DownstreamThread.hs b/hsnrm/hsnrm/src/NRM/Types/DownstreamThread.hs index d6b7602..da86c0a 100644 --- a/hsnrm/hsnrm/src/NRM/Types/DownstreamThread.hs +++ b/hsnrm/hsnrm/src/NRM/Types/DownstreamThread.hs @@ -49,7 +49,7 @@ instance getter (DownstreamThread _maxValue ratelimit dtLastRef lastRead) = ActiveSensor { activeMeta = SensorMeta - { tags = [Maximize, DownstreamThreadSignal], + { tags = [TagMaximize, TagDownstreamThreadSignal], range = 0 ... (maxValue downstreamThread & fromProgress & fromIntegral), lastReferenceMeasurements = dtLastRef, last = lastRead <&> fmap (fromIntegral . fromProgress), diff --git a/hsnrm/hsnrm/src/NRM/Types/Manifest.hs b/hsnrm/hsnrm/src/NRM/Types/Manifest.hs index 9bf4326..e66cb1c 100644 --- a/hsnrm/hsnrm/src/NRM/Types/Manifest.hs +++ b/hsnrm/hsnrm/src/NRM/Types/Manifest.hs @@ -20,7 +20,6 @@ module NRM.Types.Manifest Perfwrapper (..), Image (..), toFrequency, - jsonOptions, ) where @@ -74,9 +73,6 @@ instance Default Manifest where V.Failure _ -> panic "Error in default cfg" V.Success a -> a -jsonOptions :: Options -jsonOptions = defaultOptions {omitNothingFields = False} - instance MessagePack Integer where toObject = toObject . (fromInteger :: Integer -> Int) diff --git a/hsnrm/hsnrm/src/NRM/Types/Topology/Package.hs b/hsnrm/hsnrm/src/NRM/Types/Topology/Package.hs index 72001a5..0c606b8 100644 --- a/hsnrm/hsnrm/src/NRM/Types/Topology/Package.hs +++ b/hsnrm/hsnrm/src/NRM/Types/Topology/Package.hs @@ -92,7 +92,7 @@ instance HasLensMap (PackageID, Package) S.PassiveSensorKey S.PassiveSensor wher getter (NRM.Types.Topology.Package.Rapl cfg maxPower maxCounter freq _discreteChoices _defaultPower lastRead history) = S.PassiveSensor { passiveMeta = S.SensorMeta - { tags = [Cfg.Minimize, Cfg.TagPower, Cfg.Rapl], + { tags = [Cfg.TagMinimize, Cfg.TagPower, Cfg.TagRapl], range = 0 ... fromWatts maxPower, S.lastReferenceMeasurements = history, last = lastRead <&> fmap fromJoules, diff --git a/hsnrm/hsnrm/src/NRM/Types/Units.hs b/hsnrm/hsnrm/src/NRM/Types/Units.hs index 720e89f..48fcc2d 100644 --- a/hsnrm/hsnrm/src/NRM/Types/Units.hs +++ b/hsnrm/hsnrm/src/NRM/Types/Units.hs @@ -1,4 +1,5 @@ {-# LANGUAGE DerivingVia #-} +{-# LANGUAGE NumericUnderscores #-} -- | -- Module : NRM.Types.Units @@ -74,9 +75,6 @@ newtype Energy = Energy {fromuJ :: Double} deriving (Eq, Ord, Generic, Data, Inject, Interpret, MessagePack) deriving (Show, Num, JSONSchema, ToJSON, FromJSON) via Double -mil :: Double -mil = 1000000 - -- | Microjoule value constructor. progress :: Int -> Progress progress = Progress @@ -87,11 +85,11 @@ uJ = Energy -- | Joule value accessor. fromJoules :: Energy -> Double -fromJoules = (/ mil) . fromuJ +fromJoules = (/ 1_000_000) . fromuJ -- | Watt value constructor. joules :: Double -> Energy -joules = Energy . (* mil) +joules = Energy . (* 1_000_000) -- | Microwatt value constructor. uW :: Double -> Power @@ -99,11 +97,11 @@ uW = Power -- | Watt value accessor. fromWatts :: Power -> Double -fromWatts = (/ mil) . fromuW +fromWatts = (/ 1_000_000) . fromuW -- | Watt value constructor. watts :: Double -> Power -watts = Power . (* mil) +watts = Power . (* 1_000_000) -- | Microsecond value constructor. uS :: Double -> Time @@ -111,10 +109,10 @@ uS = Time -- | Second value constructor. seconds :: Double -> Time -seconds = Time . (* mil) +seconds = Time . (* 1_000_000) fromSeconds :: Time -> Double -fromSeconds (Time t) = t / mil +fromSeconds (Time t) = t / 1_000_000 -- | Hertz value constructor. hz :: Double -> Frequency diff --git a/resources/defaults/manifest.json b/resources/defaults/manifest.json index 04590ad..e336a49 100644 --- a/resources/defaults/manifest.json +++ b/resources/defaults/manifest.json @@ -1,13 +1,14 @@ { + "image": null, "hwbind": false, "app": { - "scheduler": { - "fIFO": {} - }, + "scheduler": "FIFO", + "instrumentation": null, + "perfwrapper": null, "powerCfg": { "slowdown": 1, "profile": false, - "policy": "noPowerPolicy" + "policy": "NoPowerPolicy" }, "slice": { "cpus": 1, diff --git a/resources/defaults/nrmd.json b/resources/defaults/nrmd.json index 0a7b145..c8500cc 100644 --- a/resources/defaults/nrmd.json +++ b/resources/defaults/nrmd.json @@ -1,18 +1,17 @@ { "extraStaticPassiveSensors": [], "pmpi_lib": "pmpi_lib", - "verbose": "error", + "verbose": "Error", "logfile": "/tmp/nrm.log", "singularity": false, "argo_nodeos_config": "argo_nodeos_config", - "controlCfg": { - "controlOff": {} - }, + "controlCfg": "ControlOff", "upstreamCfg": { "upstreamBindAddress": "*", "rpcPort": 3456, "pubPort": 2345 }, + "libnrmPath": null, "perf": "perf", "argo_perf_wrapper": "nrm-perfwrapper", "downstreamCfg": { diff --git a/resources/schemas/manifest.json b/resources/schemas/manifest.json deleted file mode 100644 index 4f701a9..0000000 --- a/resources/schemas/manifest.json +++ /dev/null @@ -1,183 +0,0 @@ -{ - "required": [ - "app", - "hwbind", - "name" - ], - "type": "object", - "properties": { - "image": { - "required": [ - "imagetype", - "path" - ], - "type": "object", - "properties": { - "binds": { - "uniqueItems": false, - "items": { - "type": "string" - }, - "type": "array" - }, - "path": { - "type": "string" - }, - "imagetype": { - "oneOf": [ - { - "const": "\"docker\"" - }, - { - "const": "\"sif\"" - } - ] - } - } - }, - "hwbind": { - "type": "boolean" - }, - "app": { - "required": [ - "powerCfg", - "scheduler", - "slice" - ], - "type": "object", - "properties": { - "scheduler": { - "oneOf": [ - { - "required": [ - "fIFO" - ], - "type": "object", - "properties": { - "fIFO": { - "type": "object", - "properties": {} - } - } - }, - { - "required": [ - "hPC" - ], - "type": "object", - "properties": { - "hPC": { - "type": "object", - "properties": {} - } - } - }, - { - "required": [ - "other" - ], - "type": "object", - "properties": { - "other": { - "type": "number" - } - } - } - ] - }, - "instrumentation": { - "required": [ - "ratelimit" - ], - "type": "object", - "properties": { - "ratelimit": { - "required": [ - "hertz" - ], - "type": "object", - "properties": { - "hertz": { - "type": "number" - } - } - } - } - }, - "perfwrapper": { - "required": [ - "perfFreq", - "perfLimit" - ], - "type": "object", - "properties": { - "perfLimit": { - "type": "number" - }, - "perfFreq": { - "required": [ - "hertz" - ], - "type": "object", - "properties": { - "hertz": { - "type": "number" - } - } - } - } - }, - "powerCfg": { - "required": [ - "policy", - "profile", - "slowdown" - ], - "type": "object", - "properties": { - "slowdown": { - "type": "number" - }, - "profile": { - "type": "boolean" - }, - "policy": { - "oneOf": [ - { - "const": "\"combined\"" - }, - { - "const": "\"dDCM\"" - }, - { - "const": "\"dVFS\"" - }, - { - "const": "\"noPowerPolicy\"" - } - ] - } - } - }, - "slice": { - "required": [ - "cpus", - "mems" - ], - "type": "object", - "properties": { - "cpus": { - "type": "number" - }, - "mems": { - "type": "number" - } - } - } - } - }, - "name": { - "type": "string" - } - } -} \ No newline at end of file diff --git a/resources/schemas/nrmd.json b/resources/schemas/nrmd.json deleted file mode 100644 index 0752761..0000000 --- a/resources/schemas/nrmd.json +++ /dev/null @@ -1,540 +0,0 @@ -{ - "required": [ - "argo_nodeos_config", - "argo_perf_wrapper", - "controlCfg", - "downstreamCfg", - "dummy", - "extraStaticActuators", - "extraStaticPassiveSensors", - "hwloc", - "hwmonCfg", - "logfile", - "nodeos", - "passiveSensorFrequency", - "perf", - "pmpi_lib", - "singularity", - "upstreamCfg", - "verbose" - ], - "type": "object", - "properties": { - "extraStaticPassiveSensors": { - "uniqueItems": false, - "items": { - "required": [ - "passiveSensorKey", - "passiveSensorValue" - ], - "type": "object", - "properties": { - "passiveSensorKey": { - "type": "string" - }, - "passiveSensorValue": { - "required": [ - "range", - "sensorArguments", - "sensorBehavior", - "sensorBinary", - "tags" - ], - "type": "object", - "properties": { - "range": { - "required": [ - "lower", - "upper" - ], - "type": "object", - "properties": { - "upper": { - "type": "number" - }, - "lower": { - "type": "number" - } - } - }, - "sensorBehavior": { - "oneOf": [ - { - "required": [ - "cumulative" - ], - "type": "object", - "properties": { - "cumulative": { - "type": "object", - "properties": {} - } - } - }, - { - "required": [ - "cumulativeWithCapacity" - ], - "type": "object", - "properties": { - "cumulativeWithCapacity": { - "type": "number" - } - } - }, - { - "required": [ - "intervalBased" - ], - "type": "object", - "properties": { - "intervalBased": { - "type": "object", - "properties": {} - } - } - } - ] - }, - "sensorArguments": { - "uniqueItems": false, - "items": { - "type": "string" - }, - "type": "array" - }, - "tags": { - "uniqueItems": false, - "items": { - "oneOf": [ - { - "const": "\"downstreamCmdSignal\"" - }, - { - "const": "\"downstreamThreadSignal\"" - }, - { - "const": "\"maximize\"" - }, - { - "const": "\"minimize\"" - }, - { - "const": "\"rapl\"" - }, - { - "const": "\"tagPower\"" - } - ] - }, - "type": "array" - }, - "sensorBinary": { - "type": "string" - } - } - } - } - }, - "type": "array" - }, - "pmpi_lib": { - "type": "string" - }, - "verbose": { - "oneOf": [ - { - "const": "\"debug\"" - }, - { - "const": "\"error\"" - }, - { - "const": "\"info\"" - } - ] - }, - "logfile": { - "type": "string" - }, - "singularity": { - "type": "boolean" - }, - "argo_nodeos_config": { - "type": "string" - }, - "controlCfg": { - "oneOf": [ - { - "required": [ - "controlCfg" - ], - "type": "object", - "properties": { - "controlCfg": { - "required": [ - "hint", - "learnCfg", - "minimumControlInterval", - "minimumWaitInterval", - "referenceMeasurementRoundInterval", - "speedThreshold", - "staticPower" - ], - "type": "object", - "properties": { - "referenceMeasurementRoundInterval": { - "type": "number" - }, - "minimumWaitInterval": { - "required": [ - "microseconds" - ], - "type": "object", - "properties": { - "microseconds": { - "type": "number" - } - } - }, - "hint": { - "oneOf": [ - { - "required": [ - "full" - ], - "type": "object", - "properties": { - "full": { - "type": "object", - "properties": {} - } - } - }, - { - "required": [ - "only" - ], - "type": "object", - "properties": { - "only": { - "required": [ - "neHead", - "neTail" - ], - "type": "object", - "properties": { - "neHead": { - "uniqueItems": false, - "items": { - "required": [ - "actuatorID", - "actuatorValue" - ], - "type": "object", - "properties": { - "actuatorValue": { - "type": "number" - }, - "actuatorID": { - "type": "string" - } - } - }, - "type": "array" - }, - "neTail": { - "uniqueItems": false, - "items": { - "uniqueItems": false, - "items": { - "required": [ - "actuatorID", - "actuatorValue" - ], - "type": "object", - "properties": { - "actuatorValue": { - "type": "number" - }, - "actuatorID": { - "type": "string" - } - } - }, - "type": "array" - }, - "type": "array" - } - } - } - } - } - ] - }, - "learnCfg": { - "oneOf": [ - { - "required": [ - "contextual" - ], - "type": "object", - "properties": { - "contextual": { - "required": [ - "horizon" - ], - "type": "object", - "properties": { - "horizon": { - "type": "number" - } - } - } - } - }, - { - "required": [ - "lagrange" - ], - "type": "object", - "properties": { - "lagrange": { - "required": [ - "lagrange" - ], - "type": "object", - "properties": { - "lagrange": { - "type": "number" - } - } - } - } - }, - { - "required": [ - "random" - ], - "type": "object", - "properties": { - "random": { - "required": [ - "seed" - ], - "type": "object", - "properties": { - "seed": { - "type": "number" - } - } - } - } - } - ] - }, - "staticPower": { - "required": [ - "microwatts" - ], - "type": "object", - "properties": { - "microwatts": { - "type": "number" - } - } - }, - "speedThreshold": { - "type": "number" - }, - "minimumControlInterval": { - "required": [ - "microseconds" - ], - "type": "object", - "properties": { - "microseconds": { - "type": "number" - } - } - } - } - } - } - }, - { - "required": [ - "controlOff" - ], - "type": "object", - "properties": { - "controlOff": { - "type": "object", - "properties": {} - } - } - } - ] - }, - "upstreamCfg": { - "required": [ - "pubPort", - "rpcPort", - "upstreamBindAddress" - ], - "type": "object", - "properties": { - "upstreamBindAddress": { - "type": "string" - }, - "rpcPort": { - "type": "number" - }, - "pubPort": { - "type": "number" - } - } - }, - "libnrmPath": { - "type": "string" - }, - "perf": { - "type": "string" - }, - "argo_perf_wrapper": { - "type": "string" - }, - "downstreamCfg": { - "required": [ - "downstreamBindAddress" - ], - "type": "object", - "properties": { - "downstreamBindAddress": { - "type": "string" - } - } - }, - "nodeos": { - "type": "boolean" - }, - "hwloc": { - "type": "string" - }, - "extraStaticActuators": { - "uniqueItems": false, - "items": { - "required": [ - "staticActuatorKey", - "staticActuatorValue" - ], - "type": "object", - "properties": { - "staticActuatorValue": { - "required": [ - "actions", - "actuatorArguments", - "actuatorBinary", - "referenceAction" - ], - "type": "object", - "properties": { - "actuatorBinary": { - "type": "string" - }, - "actions": { - "uniqueItems": false, - "items": { - "type": "number" - }, - "type": "array" - }, - "actuatorArguments": { - "uniqueItems": false, - "items": { - "type": "string" - }, - "type": "array" - }, - "referenceAction": { - "type": "number" - } - } - }, - "staticActuatorKey": { - "type": "string" - } - } - }, - "type": "array" - }, - "raplCfg": { - "required": [ - "raplActions", - "raplPath", - "referencePower" - ], - "type": "object", - "properties": { - "referencePower": { - "required": [ - "microwatts" - ], - "type": "object", - "properties": { - "microwatts": { - "type": "number" - } - } - }, - "raplActions": { - "uniqueItems": false, - "items": { - "required": [ - "microwatts" - ], - "type": "object", - "properties": { - "microwatts": { - "type": "number" - } - } - }, - "type": "array" - }, - "raplPath": { - "type": "string" - } - } - }, - "dummy": { - "type": "boolean" - }, - "hwmonCfg": { - "required": [ - "hwmonEnabled", - "hwmonPath" - ], - "type": "object", - "properties": { - "hwmonPath": { - "type": "string" - }, - "hwmonEnabled": { - "type": "boolean" - } - } - }, - "passiveSensorFrequency": { - "required": [ - "hertz" - ], - "type": "object", - "properties": { - "hertz": { - "type": "number" - } - } - } - } -} \ No newline at end of file diff --git a/resources/schemas/upstream-rep.json b/resources/schemas/upstream-rep.json index 9b59005..52a54d1 100644 --- a/resources/schemas/upstream-rep.json +++ b/resources/schemas/upstream-rep.json @@ -1071,15 +1071,15 @@ "uniqueItems": false, "items": { "required": [ - "passiveSensorKey", - "passiveSensorValue" + "sensor", + "sensorID" ], "type": "object", "properties": { - "passiveSensorKey": { + "sensorID": { "type": "string" }, - "passiveSensorValue": { + "sensor": { "required": [ "range", "sensorArguments", @@ -1155,22 +1155,22 @@ "items": { "oneOf": [ { - "const": "\"downstreamCmdSignal\"" + "const": "\"tagDownstreamCmdSignal\"" }, { - "const": "\"downstreamThreadSignal\"" + "const": "\"tagDownstreamThreadSignal\"" }, { - "const": "\"maximize\"" + "const": "\"tagMaximize\"" }, { - "const": "\"minimize\"" + "const": "\"tagMinimize\"" }, { - "const": "\"rapl\"" + "const": "\"tagPower\"" }, { - "const": "\"tagPower\"" + "const": "\"tagRapl\"" } ] }, @@ -1275,15 +1275,15 @@ "uniqueItems": false, "items": { "required": [ - "actuatorID", - "actuatorValue" + "actuatorValue", + "actuatorValueID" ], "type": "object", "properties": { "actuatorValue": { "type": "number" }, - "actuatorID": { + "actuatorValueID": { "type": "string" } } @@ -1296,15 +1296,15 @@ "uniqueItems": false, "items": { "required": [ - "actuatorID", - "actuatorValue" + "actuatorValue", + "actuatorValueID" ], "type": "object", "properties": { "actuatorValue": { "type": "number" }, - "actuatorID": { + "actuatorValueID": { "type": "string" } } @@ -1472,12 +1472,12 @@ "uniqueItems": false, "items": { "required": [ - "staticActuatorKey", - "staticActuatorValue" + "actuator", + "actuatorID" ], "type": "object", "properties": { - "staticActuatorValue": { + "actuator": { "required": [ "actions", "actuatorArguments", @@ -1508,7 +1508,7 @@ } } }, - "staticActuatorKey": { + "actuatorID": { "type": "string" } } diff --git a/tests/example-test.sh b/tests/example-test.sh new file mode 100755 index 0000000..c953d23 --- /dev/null +++ b/tests/example-test.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +set -e + +for file in ./examples/nrmd/*.dhall ; do + filename=$(basename -- "$file"); + extension="${filename##*.}"; + rootname="${filename%.*}" + echo "merged file $rootname.yaml with defaults:" + echo "$(yq -s '.[0] * .[1]' ./resources/defaults/nrmd.json ./examples/nrmd/${rootname}.yaml)" + echo "diffing with file: $file" + dhall diff " $file " " $(yq -s '.[0] * .[1]' ./resources/defaults/nrmd.json ./examples/nrmd/${rootname}.yaml | json-to-dhall ' (./hsnrm/hsnrm/dhall/types/nrmd.dhall).Cfg ' --records-loose) " + cat ./examples/nrmd/${rootname}.yaml | yq '' > ./examples/nrmd/${rootname}.json +done + +for file in ./examples/manifests/*.dhall ; do + filename=$(basename -- "$file"); + extension="${filename##*.}"; + rootname="${filename%.*}" + echo "merged file $rootname.yaml with defaults:" + echo "$(yq -s '.[0] * .[1]' ./resources/defaults/manifest.json ./examples/manifests/${rootname}.yaml)" + echo "diffing with file: $file" + dhall diff " $file " " $(yq -s '.[0] * .[1]' ./resources/defaults/manifest.json ./examples/manifests/${rootname}.yaml | json-to-dhall ' (./hsnrm/hsnrm/dhall/types/manifest.dhall).Manifest ' --records-loose) " + cat ./examples/manifests/${rootname}.yaml | yq '' > ./examples/manifests/${rootname}.json +done + -- GitLab