lib.dh 9.62 KB
Newer Older
Valentin Reis's avatar
Valentin Reis committed
1 2
    let values =
          https://xgitlab.cels.anl.gov/argo/dhrun/raw/master/resources/package.dh
Valentin Reis's avatar
Valentin Reis committed
3

Valentin Reis's avatar
Valentin Reis committed
4 5
in  let types =
          https://xgitlab.cels.anl.gov/argo/dhrun/raw/master/resources/types.dh
Valentin Reis's avatar
Valentin Reis committed
6

Valentin Reis's avatar
Valentin Reis committed
7
in  let dataDir = env:DHRUNSPECS as Text ++ "/"
Valentin Reis's avatar
Valentin Reis committed
8

Valentin Reis's avatar
Valentin Reis committed
9
in  let manifestDir = dataDir ++ "manifests/"
Valentin Reis's avatar
Valentin Reis committed
10

Valentin Reis's avatar
Valentin Reis committed
11 12 13 14 15 16 17
in  let assetDir = dataDir ++ "assets/"

in  let openmcDir = assetDir ++ "openmc/"

in  let lammpsDir = assetDir

in  let qmcPackDir = assetDir
Valentin Reis's avatar
Valentin Reis committed
18

Valentin Reis's avatar
Valentin Reis committed
19
in  let basicCommand =
Valentin Reis's avatar
Valentin Reis committed
20 21 22 23 24 25 26 27 28 29 30
            λ ( args
              : { name :
                    Text
                , outprefix :
                    Text
                , outwants :
                    List Text
                , outavoids :
                    List Text
                }
              )
Valentin Reis's avatar
Valentin Reis committed
31 32 33 34 35 36 37 38
          → { name =
                args.name
            , args =
                [] : List Text
            , out =
                { filename =
                    "${args.outprefix}.out"
                , filecheck =
Valentin Reis's avatar
Valentin Reis committed
39
                    { wants = args.outwants, avoids = args.outavoids }
Valentin Reis's avatar
Valentin Reis committed
40 41 42 43 44
                }
            , err =
                { filename =
                    "${args.outprefix}.err"
                , filecheck =
Valentin Reis's avatar
Valentin Reis committed
45
                    values.emptyCheck ⫽ { avoids = args.outavoids }
Valentin Reis's avatar
Valentin Reis committed
46 47 48 49 50 51 52
                }
            , postchecks =
                [] : List types.FileCheck
            , vars =
                values.emptyVars
            , passvars =
                [ "PATH" ]
53 54
            , timeout =
                [] : Optional Natural
Valentin Reis's avatar
Valentin Reis committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
            }

in  let MakeBaseArgs =
          { manifest :
              Text
          , cmd :
              Text
          , containerName :
              Text
          , args :
              List Text
          , verbose :
              Bool
          , cmdwants :
              List Text
Valentin Reis's avatar
Valentin Reis committed
70 71
          , cmdavoids :
              List Text
Valentin Reis's avatar
Valentin Reis committed
72 73
          , vars :
              List types.EnvVar
Valentin Reis's avatar
Valentin Reis committed
74 75
          , passvars :
              List Text
76 77
          , timeout :
              Optional Natural
Valentin Reis's avatar
Valentin Reis committed
78 79
          }

Valentin Reis's avatar
Valentin Reis committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
in  let emptyMakeBaseArgs =
            λ(cmd : Text)
          → λ(manifest : Text)
          → λ(containerName : Text)
          → { manifest =
                manifest
            , cmd =
                cmd
            , containerName =
                containerName
            , args =
                [] : List Text
            , verbose =
                False
            , cmdwants =
                [] : List Text
Valentin Reis's avatar
Valentin Reis committed
96 97
            , cmdavoids =
                [] : List Text
Valentin Reis's avatar
Valentin Reis committed
98 99
            , vars =
                values.emptyVars
Valentin Reis's avatar
Valentin Reis committed
100 101
            , passvars =
                [] : List Text
Valentin Reis's avatar
Valentin Reis committed
102 103
            }

Valentin Reis's avatar
Valentin Reis committed
104 105 106 107 108 109 110 111 112 113 114 115
in  let addVerbose = λ(v : Bool) → if v then [ "--verbose" ] else [] : List Text

in  let makeBase =
            λ(args : MakeBaseArgs)
          →   { cmds =
                  [   basicCommand
                      { name =
                          "daemon"
                      , outprefix =
                          "daemon"
                      , outwants =
                          [] : List Text
Valentin Reis's avatar
Valentin Reis committed
116 117
                      , outavoids =
                          [ "Traceback" ] : List Text
Valentin Reis's avatar
Valentin Reis committed
118 119
                      }
                    ⫽ { args =
Valentin Reis's avatar
Valentin Reis committed
120
                          [ "--nrm_log", "./nrm_log" ] # addVerbose args.verbose
Valentin Reis's avatar
Valentin Reis committed
121 122 123 124 125 126 127 128
                      , vars =
                          [ { varname =
                                "ARGO_NODEOS_CONFIG"
                            , value =
                                "/tmp/argo_nodeos_config"
                            }
                          ]
                      }
Valentin Reis's avatar
Valentin Reis committed
129 130 131 132 133 134 135 136
                  ,     let b =
                              basicCommand
                              { name =
                                  "cmd"
                              , outprefix =
                                  "cmdrun"
                              , outwants =
                                  args.cmdwants
Valentin Reis's avatar
Valentin Reis committed
137 138
                              , outavoids =
                                  args.cmdavoids
Valentin Reis's avatar
Valentin Reis committed
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
                              }
                    
                    in    b
                        ⫽ { args =
                                [ "run"
                                , "-u"
                                , args.containerName
                                , args.manifest
                                , args.cmd
                                ]
                              # args.args
                          , passvars =
                              b.passvars # args.passvars
                          , timeout =
                              args.timeout
                          }
Valentin Reis's avatar
Valentin Reis committed
155
                  ]
Valentin Reis's avatar
Valentin Reis committed
156 157
              , verbose =
                  True
Valentin Reis's avatar
Valentin Reis committed
158
              , workdir =
Valentin Reis's avatar
lib fix  
Valentin Reis committed
159
                  "./_output"
Valentin Reis's avatar
Valentin Reis committed
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
              , pre =
                  [] : List Text
              , post =
                  [] : List Text
              }
            : types.Config

in  let makeExtended =
            λ(args : MakeBaseArgs)
          → λ(cmds : List types.Cmd)
          → let b = makeBase args in b ⫽ { cmds = b.cmds # cmds }

in  let OptionalSleep = < Cmd : Text | Sleep : {} >

in  let FilterTestArgs =
Valentin Reis's avatar
Valentin Reis committed
175 176 177
          { filter :
              Text
          , cmd :
Valentin Reis's avatar
Valentin Reis committed
178
              Text
Valentin Reis's avatar
Valentin Reis committed
179 180 181 182
          , args :
              List Text
          , vars :
              List types.EnvVar
Valentin Reis's avatar
Valentin Reis committed
183 184
          , passvars :
              List Text
Valentin Reis's avatar
Valentin Reis committed
185 186
          , cmdavoids :
              List Text
Valentin Reis's avatar
Valentin Reis committed
187 188
          , isTest :
              Bool
189 190
          , timeout :
              Optional Natural
Valentin Reis's avatar
Valentin Reis committed
191
          }
Valentin Reis's avatar
Valentin Reis committed
192 193 194

in  let emptyFilterTestArgs =
            λ(filter : Text)
Valentin Reis's avatar
Valentin Reis committed
195 196 197 198
          → λ(cmd : Text)
          → { cmd =
                cmd
            , filter =
Valentin Reis's avatar
Valentin Reis committed
199 200 201
                filter
            , args =
                [] : List Text
Valentin Reis's avatar
Valentin Reis committed
202 203
            , vars =
                values.emptyVars
Valentin Reis's avatar
Valentin Reis committed
204 205
            , passvars =
                [] : List Text
Valentin Reis's avatar
Valentin Reis committed
206 207
            , cmdavoids =
                [] : List Text
Valentin Reis's avatar
Valentin Reis committed
208 209
            , isTest =
                False
210 211
            , timeout =
                [] : Optional Natural
Valentin Reis's avatar
Valentin Reis committed
212 213 214 215 216 217 218 219
            }

in  let appTest =
            λ(args : FilterTestArgs)
          →     let cn = "testContainer"
            
            in  makeExtended
                { manifest =
Valentin Reis's avatar
Valentin Reis committed
220
                    manifestDir ++ "perfwrap.json"
Valentin Reis's avatar
Valentin Reis committed
221 222 223
                , containerName =
                    cn
                , cmd =
Valentin Reis's avatar
Valentin Reis committed
224
                    args.cmd
Valentin Reis's avatar
Valentin Reis committed
225
                , args =
Valentin Reis's avatar
Valentin Reis committed
226
                    args.args
Valentin Reis's avatar
Valentin Reis committed
227 228 229 230
                , verbose =
                    True
                , cmdwants =
                    [] : List Text
Valentin Reis's avatar
Valentin Reis committed
231 232
                , cmdavoids =
                    args.cmdavoids
Valentin Reis's avatar
Valentin Reis committed
233 234
                , vars =
                    args.vars
Valentin Reis's avatar
Valentin Reis committed
235 236
                , passvars =
                    args.passvars
237 238
                , timeout =
                    args.timeout
Valentin Reis's avatar
Valentin Reis committed
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
                }
                [     let b =
                            values.emptyCmd
                            { name =
                                "cmd"
                            , outfile =
                                "cmdlisten.out"
                            , errfile =
                                "cmdlisten.err"
                            }
                  
                  in    b
                      ⫽ { args =
                            [ "listen", "-u", cn, "--filter", args.filter ]
                        , out =
                              b.out
                            ⫽ { filecheck =
                                    values.emptyCheck
Valentin Reis's avatar
Valentin Reis committed
257 258 259 260 261 262 263
                                  ⫽ { wants =
                                              if args.isTest
                                        
                                        then  [ args.filter ]
                                        
                                        else  [] : List Text
                                    }
Valentin Reis's avatar
Valentin Reis committed
264 265 266 267
                              }
                        }
                ]

Valentin Reis's avatar
Valentin Reis committed
268 269 270 271 272 273 274
in  let ProgressAppTestArg =
          { cmd :
              Text
          , args :
              List Text
          , vars :
              List types.EnvVar
Valentin Reis's avatar
Valentin Reis committed
275 276
          , passvars :
              List Text
Valentin Reis's avatar
Valentin Reis committed
277 278
          , cmdavoids :
              List Text
Valentin Reis's avatar
Valentin Reis committed
279 280
          , isTest :
              Bool
281 282
          , timeout :
              Optional Natural
Valentin Reis's avatar
Valentin Reis committed
283 284 285 286 287 288 289 290 291 292 293
          }

in  let emptyProgressAppTestArg =
            λ(cmd : Text)
          → λ(args : List Text)
          →   { cmd =
                  cmd
              , args =
                  args
              , vars =
                  [] : List types.EnvVar
Valentin Reis's avatar
Valentin Reis committed
294 295
              , passvars =
                  [] : List Text
Valentin Reis's avatar
Valentin Reis committed
296 297
              , cmdavoids =
                  [] : List Text
Valentin Reis's avatar
Valentin Reis committed
298 299
              , isTest =
                  False
300 301
              , timeout =
                  [] : Optional Natural
Valentin Reis's avatar
Valentin Reis committed
302 303 304 305 306 307
              }
            : ProgressAppTestArg

in  let progressAppTest =
            λ(args : ProgressAppTestArg)
          → appTest
Valentin Reis's avatar
Valentin Reis committed
308 309
            (   emptyFilterTestArgs "progress" args.cmd
              ⫽ { args =
Valentin Reis's avatar
Valentin Reis committed
310 311 312
                    args.args
                , vars =
                    args.vars
Valentin Reis's avatar
Valentin Reis committed
313 314
                , passvars =
                    args.passvars
Valentin Reis's avatar
Valentin Reis committed
315 316
                , cmdavoids =
                    args.cmdavoids
Valentin Reis's avatar
Valentin Reis committed
317
                , isTest =
Valentin Reis's avatar
Valentin Reis committed
318
                    True
319 320
                , timeout =
                    args.timeout
Valentin Reis's avatar
Valentin Reis committed
321 322 323
                }
            )

Valentin Reis's avatar
Valentin Reis committed
324 325
in  { values =
        values
Valentin Reis's avatar
Valentin Reis committed
326 327
    , emptyMakeBaseArgs =
        emptyMakeBaseArgs
Valentin Reis's avatar
Valentin Reis committed
328 329 330 331 332 333
    , makeBase =
        makeBase
    , makeExtended =
        makeExtended
    , appTest =
        appTest
Valentin Reis's avatar
Valentin Reis committed
334 335
    , progressAppTest =
        progressAppTest
Valentin Reis's avatar
Valentin Reis committed
336 337 338 339
    , emptyFilterTestArgs =
        emptyFilterTestArgs
    , qmcPackDir =
        qmcPackDir
Valentin Reis's avatar
Valentin Reis committed
340 341
    , openmcDir =
        openmcDir
Valentin Reis's avatar
Valentin Reis committed
342 343
    , lammpsDir =
        lammpsDir
Valentin Reis's avatar
Valentin Reis committed
344 345
    , manifestDir =
        manifestDir
Valentin Reis's avatar
Valentin Reis committed
346 347
    , emptyProgressAppTestArg =
        emptyProgressAppTestArg
Valentin Reis's avatar
Valentin Reis committed
348
    }