Commit 1fd5b1a9 authored by Valentin Reis's avatar Valentin Reis

mapM -> for

parent 288bbb1c
Pipeline #5933 passed with stages
in 2 minutes and 37 seconds
.PHONY: ghcid-tests ghcid-lib
ghcid-lib:
sh -c "while true; do \
nix-shell \
--run 'ghcid \
--command \"cabal new-repl argotk\" \
--restart=argotk.cabal \
--restart=default.nix\
--restart=shell.nix'\
; done"
......@@ -2,7 +2,7 @@
<settings>
<run_mode>eigenvalue</run_mode>
<particles>100</particles>
<batches>800</batches>
<batches>60</batches>
<inactive>1</inactive>
<source strength="1.0">
<space type="fission">
......
......@@ -34,23 +34,29 @@ import Data.Text as T
import Argo.Utils
import System.Process as P
hiding ( shell )
import Control.Monad as CM
import Control.Monad ( mapM_
, filterM
)
import Data.Foldable ( for_ )
import Data.Traversable ( for )
import Data.Maybe
import Control.Foldl as Fold
( length )
import Text.Show.Pretty
cleanLeftovers :: WorkingDirectory -> Shell () --TODO
cleanLeftovers (WorkingDirectory wd) = do
printInfo "Cleaning sockets."
CM.mapM_
cleanSocket
for_ socklist cleanSocket
printInfo "Cleaning output directory."
void $ shell (format ("rm -rf " % fp) wd) Turtle.empty
where
socklist =
[ "/tmp/nrm-downstream-in"
, "/tmp/nrm-downstream-event"
, "/tmp/nrm-upstream-in"
, "/tmp/nrm-upstream-event"
]
printInfo "Cleaning output directory."
void $ shell (format ("rm -rf " % fp) wd) Turtle.empty
prepareDaemon
:: StdOutLog
......@@ -167,11 +173,13 @@ runStack sa@StackArgs {..} = do
when (powercap /= None) $ do
user <- lineToText <$> single (inproc "whoami" [] empty)
chownPowercapFiles user "/sys/devices/virtual/powercap/intel-rapl/intel-rapl:0"
chownPowercapFiles user "/sys/devices/virtual/powercap/intel-rapl/intel-rapl:1"
chownPowercapFiles user
"/sys/devices/virtual/powercap/intel-rapl/intel-rapl:0"
chownPowercapFiles user
"/sys/devices/virtual/powercap/intel-rapl/intel-rapl:1"
cleanLeftovers workingDirectory
CM.mapM_ ($ coerce workingDirectory) [mktree, cd]
mapM_ ($ coerce workingDirectory) [mktree, cd]
iDaemon <- case daemon of
DontRun -> return Nothing
......@@ -202,8 +210,8 @@ runStack sa@StackArgs {..} = do
printInfo "Starting the following processes:"
liftIO $ pPrint ilist
asyncs <- liftIO $ mapM tupleToAsync ilist
_ <- liftIO $ kbInstallHandler $ CM.mapM_ cancel asyncs
asyncs <- liftIO $ for ilist tupleToAsync
_ <- liftIO $ kbInstallHandler $ for_ asyncs cancel
when verbose $ printInfo "Processes started."
......@@ -235,10 +243,8 @@ runStack sa@StackArgs {..} = do
chownPowercap user fn =
shell (format ("sudo chown " % s % ":" % s % " " % s) user user fn) empty
>>= \case
ExitSuccess ->
printWarning $ "changed ownership on " <> fn
ExitFailure _ ->
die $ "Couldn't change ownership on " <> fn
ExitSuccess -> printWarning $ "changed ownership on " <> fn
ExitFailure _ -> die $ "Couldn't change ownership on " <> fn
chownPowercapFiles user p =
chownPowercap user (p <> "/constraint_1_power_limit_uw")
......
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Main
( main
)
where
{-|
Module : argotk.hs
Description : argo provisioner/executor
......@@ -10,6 +14,7 @@ Maintainer : fre@freux.fr
-}
import Data.Coerce ( coerce )
import Data.Foldable ( for_ )
import Argo.Stack
import Argo.Utils
import Argo.Types
......@@ -320,7 +325,7 @@ opts sa = hsubparser
commandTest ttype = command (show ttype)
$ info (action ttype) (progDesc $ T.unpack $ descTest ttype)
commandTests ttypes cmdStr descStr = command cmdStr
$ info (pure $ mapM_ (doTest sa) ttypes) (progDesc $ T.unpack descStr)
$ info (pure $ for_ ttypes (doTest sa)) (progDesc $ T.unpack descStr)
doTest :: StackArgs -> TestName -> Shell ()
doTest stackArgs ttype = doSpec spec
......@@ -345,17 +350,14 @@ fullStack isTest a@StackArgs {..} = do
case stackOutput of
FoundMessage msg -> printSuccess $ "Found string in message:" <> repr msg
FoundTracebacks tsl -> do
mapM_
(\(stacki, fout, ferr) ->
printError
$ "Found Python Traceback when executing "
<> repr stacki
<> ". Files for this command: "
<> repr fout
<> " "
<> repr ferr
)
tsl
for_ tsl $ \(stacki, fout, ferr) ->
printError
$ "Found Python Traceback when executing "
<> repr stacki
<> ". Files for this command: "
<> repr fout
<> " "
<> repr ferr
exit (ExitFailure 1)
Died stacki errorcode _ _ tsl -> case isTest of
IsTest -> do
......@@ -364,7 +366,8 @@ fullStack isTest a@StackArgs {..} = do
<> " died before a message could be found with error code "
<> repr errorcode
)
mapM_
for_
tsl
(\(stacki', fout, ferr) ->
printError
$ "Found Python Traceback when executing "
......@@ -374,7 +377,6 @@ fullStack isTest a@StackArgs {..} = do
<> " "
<> repr ferr
)
tsl
exit (ExitFailure 1)
NotTest -> exit ExitSuccess
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment