, simRebalance :: Bool
, simHistory :: [SimCommand]
, simVectorClock :: VectorClock
- , simFile :: Maybe FilePath
+ , simLogFile :: Maybe FilePath
, simRootDirectory :: FilePath
}
deriving (Show, Read)
, simRebalance = False
, simHistory = []
, simVectorClock = VectorClock 0
- , simFile = Nothing
+ , simLogFile = Nothing
, simRootDirectory = rootdir
}
simdir <- fromRawFilePath <$> fromRepo gitAnnexSimDir
whenM (liftIO $ doesDirectoryExist simdir) $ do
liftIO $ removeDirectoryRecursive simdir
+ showLongNote $ UnquotedString "Sim ended."
seek ("visit":reponame:[]) = do
simdir <- fromRepo gitAnnexSimDir
liftIO (restoreSim simdir) >>= \case
, "Choose from:"
, unwords $ map fromRepoName $ M.keys (simRepos st)
]
+seek ("show":[]) = do
+ simdir <- fromRepo gitAnnexSimDir
+ liftIO (restoreSim simdir) >>= \case
+ Left err -> giveup err
+ Right st -> case simLogFile st of
+ Just f -> liftIO $ putStr =<< readFile f
+ Nothing -> return ()
seek ps = case parseSimCommand ps of
Left err -> giveup err
Right simcmd -> do
rng <- fst . random <$> initStdGen
let st = (emptySimState rng simdir)
- { simFile = Just simlogfile }
+ { simLogFile = Just simlogfile }
case simfile of
Nothing -> startup simdir st []
Just f -> liftIO (readFile f) >>= \c ->
case parseSimFile c of
Left err -> giveup err
Right cs -> startup simdir st cs
- showLongNote $ UnquotedString "Sim started, logging to sim file "
- <> QuotedPath (toRawFilePath simlogfile)
+ showLongNote $ UnquotedString "Sim started."
where
startup simdir st cs = do
repobyname <- mkGetExistingRepoByName
saveState :: SimState SimRepo -> IO ()
saveState st = do
suspendSim st
- case simFile st of
+ case simLogFile st of
Just f -> writeFile f $ generateSimFile $ reverse $ simHistory st
Nothing -> noop
git annex sim visit repo
+git annex sim show
+
git annex sim end
# DESCRIPTION
with the command in the same format used in the sim file (see sim commands
list below). For example, "git annex sim step 1" runs the simulation one step.
-The simulation writes to an output sim file as it runs, which contains the
+The simulation keeps a log as it runs, which contains the
entire simulation input, as well as the actions performed in the
-simulation, and the results of the simulation.
-This allows re-running the same simulation later, as well as analyzing
-the results of the simulation.
+simulation, and the results of the simulation. Use "git-annex sim show"
+to display the log. This allows re-running the same simulation later,
+as well as analyzing the results of the simulation.
-While a simulation is running, the command "git annex visit repo", where
+While a simulation is running, the command "git annex sim visit repo", where
"repo" is the name of one of the repositories in the simulation, will spawn
a subshell in a git repository whose git-annex branch contains the state of
that simulated repository. This allows running any git-annex command, such
as `git-annex whereis` to examine the state of the simulation.
+You should avoid making any changes to git-annex state.
Exit the subshell to end the visit.
Use "git annex sim end" to finish the simulation, and clean up.