Skip to content

Commit

Permalink
change useExistingModels to work with absolute paths as well
Browse files Browse the repository at this point in the history
  • Loading branch information
ozgurakgun committed Mar 8, 2024
1 parent e404580 commit 0b5eab8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/Conjure/UI/MainHelper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0b5eab8

Please sign in to comment.