lib.dh 7.82 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
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" ]
            }

in  let MakeBaseArgs =
          { manifest :
              Text
          , cmd :
              Text
          , containerName :
              Text
          , args :
              List Text
          , verbose :
              Bool
          , cmdwants :
              List Text
Valentin Reis's avatar
Valentin Reis committed
51 52
          , vars :
              List types.EnvVar
Valentin Reis's avatar
Valentin Reis committed
53 54
          }

Valentin Reis's avatar
Valentin Reis committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
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
75 76 77 78 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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
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" ]
                      }
                  ]
              , 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
137 138 139 140 141 142 143 144 145 146 147
          { filter :
              Text
          , cmd :
              OptionalSleep
          , args :
              List Text
          , vars :
              List types.EnvVar
          , isTest :
              Bool
          }
Valentin Reis's avatar
Valentin Reis committed
148 149 150 151 152 153 154 155 156

in  let emptyFilterTestArgs =
            λ(filter : Text)
          → { filter =
                filter
            , cmd =
                < Sleep = {=} | Cmd : Text >
            , args =
                [] : List Text
Valentin Reis's avatar
Valentin Reis committed
157 158 159 160
            , vars =
                values.emptyVars
            , isTest =
                False
Valentin Reis's avatar
Valentin Reis committed
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
            }

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
191 192
                , vars =
                    args.vars
Valentin Reis's avatar
Valentin Reis committed
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
                }
                [     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
211 212 213 214 215 216 217
                                  ⫽ { wants =
                                              if args.isTest
                                        
                                        then  [ args.filter ]
                                        
                                        else  [] : List Text
                                    }
Valentin Reis's avatar
Valentin Reis committed
218 219 220 221
                              }
                        }
                ]

Valentin Reis's avatar
Valentin Reis committed
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
in  let ProgressAppTestArg =
          { cmd :
              Text
          , args :
              List Text
          , vars :
              List types.EnvVar
          , isTest :
              Bool
          }

in  let emptyProgressAppTestArg =
            λ(cmd : Text)
          → λ(args : List Text)
          →   { cmd =
                  cmd
              , args =
                  args
              , vars =
                  [] : List types.EnvVar
              , isTest =
                  False
              }
            : ProgressAppTestArg

in  let progressAppTest =
            λ(args : ProgressAppTestArg)
          → appTest
            (   emptyFilterTestArgs "progress"
              ⫽ { cmd =
                    < Cmd = args.cmd | Sleep : {} >
                , args =
                    args.args
                , vars =
                    args.vars
                , isTest =
                    False
                }
            )

Valentin Reis's avatar
Valentin Reis committed
262 263
in  { values =
        values
Valentin Reis's avatar
Valentin Reis committed
264 265
    , emptyMakeBaseArgs =
        emptyMakeBaseArgs
Valentin Reis's avatar
Valentin Reis committed
266 267 268 269 270 271
    , makeBase =
        makeBase
    , makeExtended =
        makeExtended
    , appTest =
        appTest
Valentin Reis's avatar
Valentin Reis committed
272 273
    , progressAppTest =
        progressAppTest
Valentin Reis's avatar
Valentin Reis committed
274 275 276 277
    , emptyFilterTestArgs =
        emptyFilterTestArgs
    , qmcPackDir =
        qmcPackDir
Valentin Reis's avatar
Valentin Reis committed
278 279
    , lammpsDir =
        lammpsDir
Valentin Reis's avatar
Valentin Reis committed
280 281
    , argopkgsManifestDirPath =
        argopkgsManifestDirPath
Valentin Reis's avatar
Valentin Reis committed
282 283
    , emptyProgressAppTestArg =
        emptyProgressAppTestArg
Valentin Reis's avatar
Valentin Reis committed
284
    }