lib.dh 8.35 KB
Newer Older
Valentin Reis's avatar
Valentin Reis committed
1 2 3 4 5 6 7 8 9
    let values = ./../../dhrun/resources/package.dh

in  let types = ./../../dhrun/resources/types.dh

in  let argopkgsManifestDirPath =
          "/home/fre/workspace/argopkgs/dhrun/manifests/"

in  let qmcPackDir = "toto"

Valentin Reis's avatar
Valentin Reis committed
10 11
in  let lammpsDir = "toto"

Valentin Reis's avatar
Valentin Reis committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
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" ]
36 37
            , timeout =
                [] : Optional Natural
Valentin Reis's avatar
Valentin Reis committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
            }

in  let MakeBaseArgs =
          { manifest :
              Text
          , cmd :
              Text
          , containerName :
              Text
          , args :
              List Text
          , verbose :
              Bool
          , cmdwants :
              List Text
Valentin Reis's avatar
Valentin Reis committed
53 54
          , vars :
              List types.EnvVar
55 56
          , timeout :
              Optional Natural
Valentin Reis's avatar
Valentin Reis committed
57 58
          }

Valentin Reis's avatar
Valentin Reis committed
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
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
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
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"
                            }
                          ]
                      }
                  ,   basicCommand
                      { name =
                          "cmd"
                      , outprefix =
                          "cmdrun"
                      , outwants =
                          args.cmdwants
                      }
                    ⫽ { args =
                            [ "run"
                            , "-u"
                            , args.containerName
                            , args.manifest
                            , args.cmd
                            ]
                          # args.args
                      , passvars =
                          [ "PATH" ]
120 121
                      , timeout =
                          args.timeout
Valentin Reis's avatar
Valentin Reis committed
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
                      }
                  ]
              , verbosity =
                  values.Normal
              , workdir =
                  "./_dhrun_out"
              , 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
143 144 145 146 147 148 149 150 151 152
          { filter :
              Text
          , cmd :
              OptionalSleep
          , args :
              List Text
          , vars :
              List types.EnvVar
          , isTest :
              Bool
153 154
          , timeout :
              Optional Natural
Valentin Reis's avatar
Valentin Reis committed
155
          }
Valentin Reis's avatar
Valentin Reis committed
156 157 158 159 160 161 162 163 164

in  let emptyFilterTestArgs =
            λ(filter : Text)
          → { filter =
                filter
            , cmd =
                < Sleep = {=} | Cmd : Text >
            , args =
                [] : List Text
Valentin Reis's avatar
Valentin Reis committed
165 166 167 168
            , vars =
                values.emptyVars
            , isTest =
                False
169 170
            , timeout =
                [] : Optional Natural
Valentin Reis's avatar
Valentin Reis committed
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
            }

in  let sleepArgs =
            λ(l : List Text)
          → if Natural/isZero (List/length Text l) then [ "15" ] else l

in  let sleep =
            λ(x : OptionalSleep)
          →     let handlers =
                      { Sleep = λ(_ : {}) → "cmd", Cmd = λ(b : Text) → b }
            
            in  merge handlers x

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

Valentin Reis's avatar
Valentin Reis committed
234 235 236 237 238 239 240 241 242
in  let ProgressAppTestArg =
          { cmd :
              Text
          , args :
              List Text
          , vars :
              List types.EnvVar
          , isTest :
              Bool
243 244
          , timeout :
              Optional Natural
Valentin Reis's avatar
Valentin Reis committed
245 246 247 248 249 250 251 252 253 254 255 256 257
          }

in  let emptyProgressAppTestArg =
            λ(cmd : Text)
          → λ(args : List Text)
          →   { cmd =
                  cmd
              , args =
                  args
              , vars =
                  [] : List types.EnvVar
              , isTest =
                  False
258 259
              , timeout =
                  [] : Optional Natural
Valentin Reis's avatar
Valentin Reis committed
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
              }
            : ProgressAppTestArg

in  let progressAppTest =
            λ(args : ProgressAppTestArg)
          → appTest
            (   emptyFilterTestArgs "progress"
              ⫽ { cmd =
                    < Cmd = args.cmd | Sleep : {} >
                , args =
                    args.args
                , vars =
                    args.vars
                , isTest =
                    False
275 276
                , timeout =
                    args.timeout
Valentin Reis's avatar
Valentin Reis committed
277 278 279
                }
            )

Valentin Reis's avatar
Valentin Reis committed
280 281
in  { values =
        values
Valentin Reis's avatar
Valentin Reis committed
282 283
    , emptyMakeBaseArgs =
        emptyMakeBaseArgs
Valentin Reis's avatar
Valentin Reis committed
284 285 286 287 288 289
    , makeBase =
        makeBase
    , makeExtended =
        makeExtended
    , appTest =
        appTest
Valentin Reis's avatar
Valentin Reis committed
290 291
    , progressAppTest =
        progressAppTest
Valentin Reis's avatar
Valentin Reis committed
292 293 294 295
    , emptyFilterTestArgs =
        emptyFilterTestArgs
    , qmcPackDir =
        qmcPackDir
Valentin Reis's avatar
Valentin Reis committed
296 297
    , lammpsDir =
        lammpsDir
Valentin Reis's avatar
Valentin Reis committed
298 299
    , argopkgsManifestDirPath =
        argopkgsManifestDirPath
Valentin Reis's avatar
Valentin Reis committed
300 301
    , emptyProgressAppTestArg =
        emptyProgressAppTestArg
Valentin Reis's avatar
Valentin Reis committed
302
    }