From 0b5eab8c2840b073a2cd7602606f880e535e100c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Akg=C3=BCn?= Date: Fri, 8 Mar 2024 21:37:29 +0000 Subject: [PATCH] change useExistingModels to work with absolute paths as well --- src/Conjure/UI/MainHelper.hs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Conjure/UI/MainHelper.hs b/src/Conjure/UI/MainHelper.hs index 3d99c78b9..521d90210 100644 --- a/src/Conjure/UI/MainHelper.hs +++ b/src/Conjure/UI/MainHelper.hs @@ -39,6 +39,7 @@ import Conjure.Language.AdHoc ( toSimpleJSON ) -- base +import Control.Exception ( IOException, handle ) import System.IO ( Handle, hSetBuffering, stdout, BufferMode(..), hPutStrLn, stderr ) import System.Environment ( getEnvironment ) import System.Info ( os ) @@ -298,11 +299,7 @@ mainWithArgs config@Solve{..} = do if not (null useExistingModels) then do pp logLevel "Using existing models." - allEprimes <- getEprimes - let missingModels = useExistingModels \\ allEprimes - if null missingModels - then return useExistingModels - else userErr1 $ "Models not found:" <+> vcat (map pretty missingModels) + return useExistingModels else doIfNotCached -- start the show! ( sort (mStatements essenceM_beforeNR) , portfolio @@ -335,8 +332,12 @@ mainWithArgs config@Solve{..} = do conjuring eprimesParsed <- forM eprimes $ \ f -> do - p <- readModelInfoFromFile (outputDirectory f) - return (f, p) + p1 <- liftIO $ handle (\(_ :: IOException) -> return Nothing) (Just <$> readModelInfoFromFile f) + p2 <- liftIO $ handle (\(_ :: IOException) -> return Nothing) (Just <$> readModelInfoFromFile (outputDirectory f)) + case (p1, p2) of + (Just p, _) -> return (f, p) + (_, Just p) -> return (f, p) + _ -> userErr1 $ "Model not found:" <+> pretty f msolutions <- liftIO $ savileRows eprimesParsed essenceParamsParsed case msolutions of