lib.dh 8.72 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 = "./"
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 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
in  let basicCommand =
            λ(args : { name : Text, outprefix : Text, outwants : List Text })
          → { name =
                args.name
            , args =
                [] : List Text
            , out =
                { filename =
                    "${args.outprefix}.out"
                , filecheck =
                    values.emptyCheck ⫽ { wants = args.outwants }
                }
            , err =
                { filename =
                    "${args.outprefix}.err"
                , filecheck =
                    values.emptyCheck
                }
            , postchecks =
                [] : List types.FileCheck
            , vars =
                values.emptyVars
            , passvars =
                [ "PATH" ]
43 44
            , timeout =
                [] : Optional Natural
Valentin Reis's avatar
Valentin Reis committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
            }

in  let MakeBaseArgs =
          { manifest :
              Text
          , cmd :
              Text
          , containerName :
              Text
          , args :
              List Text
          , verbose :
              Bool
          , cmdwants :
              List Text
Valentin Reis's avatar
Valentin Reis committed
60 61
          , vars :
              List types.EnvVar
Valentin Reis's avatar
Valentin Reis committed
62 63
          , passvars :
              List Text
64 65
          , timeout :
              Optional Natural
Valentin Reis's avatar
Valentin Reis committed
66 67
          }

Valentin Reis's avatar
Valentin Reis committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
in  let emptyMakeBaseArgs =
            λ(cmd : Text)
          → λ(manifest : Text)
          → λ(containerName : Text)
          → { manifest =
                manifest
            , cmd =
                cmd
            , containerName =
                containerName
            , args =
                [] : List Text
            , verbose =
                False
            , cmdwants =
                [] : List Text
            , vars =
                values.emptyVars
Valentin Reis's avatar
Valentin Reis committed
86 87
            , passvars =
                [] : List Text
Valentin Reis's avatar
Valentin Reis committed
88 89
            }

Valentin Reis's avatar
Valentin Reis committed
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
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
                      }
                    ⫽ { args =
                          addVerbose args.verbose
                      , vars =
                          [ { varname =
                                "ARGO_NODEOS_CONFIG"
                            , value =
                                "/tmp/argo_nodeos_config"
                            }
                          ]
                      }
Valentin Reis's avatar
Valentin Reis committed
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
                  ,     let b =
                              basicCommand
                              { name =
                                  "cmd"
                              , outprefix =
                                  "cmdrun"
                              , outwants =
                                  args.cmdwants
                              }
                    
                    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
137
                  ]
Valentin Reis's avatar
Valentin Reis committed
138 139
              , verbose =
                  True
Valentin Reis's avatar
Valentin Reis committed
140
              , workdir =
Valentin Reis's avatar
lib fix  
Valentin Reis committed
141
                  "./_output"
Valentin Reis's avatar
Valentin Reis committed
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
              , 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
157 158 159
          { filter :
              Text
          , cmd :
Valentin Reis's avatar
Valentin Reis committed
160
              Text
Valentin Reis's avatar
Valentin Reis committed
161 162 163 164
          , args :
              List Text
          , vars :
              List types.EnvVar
Valentin Reis's avatar
Valentin Reis committed
165 166
          , passvars :
              List Text
Valentin Reis's avatar
Valentin Reis committed
167 168
          , isTest :
              Bool
169 170
          , timeout :
              Optional Natural
Valentin Reis's avatar
Valentin Reis committed
171
          }
Valentin Reis's avatar
Valentin Reis committed
172 173 174

in  let emptyFilterTestArgs =
            λ(filter : Text)
Valentin Reis's avatar
Valentin Reis committed
175 176 177 178
          → λ(cmd : Text)
          → { cmd =
                cmd
            , filter =
Valentin Reis's avatar
Valentin Reis committed
179 180 181
                filter
            , args =
                [] : List Text
Valentin Reis's avatar
Valentin Reis committed
182 183
            , vars =
                values.emptyVars
Valentin Reis's avatar
Valentin Reis committed
184 185
            , passvars =
                [] : List Text
Valentin Reis's avatar
Valentin Reis committed
186 187
            , isTest =
                False
188 189
            , timeout =
                [] : Optional Natural
Valentin Reis's avatar
Valentin Reis committed
190 191 192 193 194 195 196 197
            }

in  let appTest =
            λ(args : FilterTestArgs)
          →     let cn = "testContainer"
            
            in  makeExtended
                { manifest =
Valentin Reis's avatar
Valentin Reis committed
198
                    manifestDir ++ "perfwrap.json"
Valentin Reis's avatar
Valentin Reis committed
199 200 201
                , containerName =
                    cn
                , cmd =
Valentin Reis's avatar
Valentin Reis committed
202
                    args.cmd
Valentin Reis's avatar
Valentin Reis committed
203
                , args =
Valentin Reis's avatar
Valentin Reis committed
204
                    args.args
Valentin Reis's avatar
Valentin Reis committed
205 206 207 208
                , verbose =
                    True
                , cmdwants =
                    [] : List Text
Valentin Reis's avatar
Valentin Reis committed
209 210
                , vars =
                    args.vars
Valentin Reis's avatar
Valentin Reis committed
211 212
                , passvars =
                    args.passvars
213 214
                , timeout =
                    args.timeout
Valentin Reis's avatar
Valentin Reis committed
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
                }
                [     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
233 234 235 236 237 238 239
                                  ⫽ { wants =
                                              if args.isTest
                                        
                                        then  [ args.filter ]
                                        
                                        else  [] : List Text
                                    }
Valentin Reis's avatar
Valentin Reis committed
240 241 242 243
                              }
                        }
                ]

Valentin Reis's avatar
Valentin Reis committed
244 245 246 247 248 249 250
in  let ProgressAppTestArg =
          { cmd :
              Text
          , args :
              List Text
          , vars :
              List types.EnvVar
Valentin Reis's avatar
Valentin Reis committed
251 252
          , passvars :
              List Text
Valentin Reis's avatar
Valentin Reis committed
253 254
          , isTest :
              Bool
255 256
          , timeout :
              Optional Natural
Valentin Reis's avatar
Valentin Reis committed
257 258 259 260 261 262 263 264 265 266 267
          }

in  let emptyProgressAppTestArg =
            λ(cmd : Text)
          → λ(args : List Text)
          →   { cmd =
                  cmd
              , args =
                  args
              , vars =
                  [] : List types.EnvVar
Valentin Reis's avatar
Valentin Reis committed
268 269
              , passvars =
                  [] : List Text
Valentin Reis's avatar
Valentin Reis committed
270 271
              , isTest =
                  False
272 273
              , timeout =
                  [] : Optional Natural
Valentin Reis's avatar
Valentin Reis committed
274 275 276 277 278 279
              }
            : ProgressAppTestArg

in  let progressAppTest =
            λ(args : ProgressAppTestArg)
          → appTest
Valentin Reis's avatar
Valentin Reis committed
280 281
            (   emptyFilterTestArgs "progress" args.cmd
              ⫽ { args =
Valentin Reis's avatar
Valentin Reis committed
282 283 284
                    args.args
                , vars =
                    args.vars
Valentin Reis's avatar
Valentin Reis committed
285 286
                , passvars =
                    args.passvars
Valentin Reis's avatar
Valentin Reis committed
287
                , isTest =
Valentin Reis's avatar
Valentin Reis committed
288
                    True
289 290
                , timeout =
                    args.timeout
Valentin Reis's avatar
Valentin Reis committed
291 292 293
                }
            )

Valentin Reis's avatar
Valentin Reis committed
294 295
in  { values =
        values
Valentin Reis's avatar
Valentin Reis committed
296 297
    , emptyMakeBaseArgs =
        emptyMakeBaseArgs
Valentin Reis's avatar
Valentin Reis committed
298 299 300 301 302 303
    , makeBase =
        makeBase
    , makeExtended =
        makeExtended
    , appTest =
        appTest
Valentin Reis's avatar
Valentin Reis committed
304 305
    , progressAppTest =
        progressAppTest
Valentin Reis's avatar
Valentin Reis committed
306 307 308 309
    , emptyFilterTestArgs =
        emptyFilterTestArgs
    , qmcPackDir =
        qmcPackDir
Valentin Reis's avatar
Valentin Reis committed
310 311
    , openmcDir =
        openmcDir
Valentin Reis's avatar
Valentin Reis committed
312 313
    , lammpsDir =
        lammpsDir
Valentin Reis's avatar
Valentin Reis committed
314 315
    , manifestDir =
        manifestDir
Valentin Reis's avatar
Valentin Reis committed
316 317
    , emptyProgressAppTestArg =
        emptyProgressAppTestArg
Valentin Reis's avatar
Valentin Reis committed
318
    }