improve error message when unable to get an input file
In this case, the compute program is run the same as if addcomputed --fast were used, so it should succeed, without outputting a computed file. computeInputsUnavailable is in ComputeState for simplicity, but it is not serialized with the rest of the ComputeState.
This commit is contained in:
parent
f4e0d6a043
commit
51538fa0a8
2 changed files with 24 additions and 14 deletions
|
@ -95,6 +95,7 @@ perform o r = do
|
||||||
, Remote.Compute.computeOutputs = mempty
|
, Remote.Compute.computeOutputs = mempty
|
||||||
, Remote.Compute.computeSubdir = subdir
|
, Remote.Compute.computeSubdir = subdir
|
||||||
, Remote.Compute.computeReproducible = False
|
, Remote.Compute.computeReproducible = False
|
||||||
|
, Remote.Compute.computeInputsUnavailable = False
|
||||||
}
|
}
|
||||||
fast <- Annex.getRead Annex.fast
|
fast <- Annex.getRead Annex.fast
|
||||||
Remote.Compute.runComputeProgram program state
|
Remote.Compute.runComputeProgram program state
|
||||||
|
|
|
@ -218,6 +218,7 @@ data ComputeState = ComputeState
|
||||||
, computeOutputs :: M.Map OsPath (Maybe Key)
|
, computeOutputs :: M.Map OsPath (Maybe Key)
|
||||||
, computeSubdir :: OsPath
|
, computeSubdir :: OsPath
|
||||||
, computeReproducible :: Bool
|
, computeReproducible :: Bool
|
||||||
|
, computeInputsUnavailable :: Bool
|
||||||
}
|
}
|
||||||
deriving (Show, Eq)
|
deriving (Show, Eq)
|
||||||
|
|
||||||
|
@ -261,7 +262,7 @@ parseComputeState k b =
|
||||||
let st = go emptycomputestate (parseQuery b)
|
let st = go emptycomputestate (parseQuery b)
|
||||||
in if st == emptycomputestate then Nothing else Just st
|
in if st == emptycomputestate then Nothing else Just st
|
||||||
where
|
where
|
||||||
emptycomputestate = ComputeState mempty mempty mempty "." False
|
emptycomputestate = ComputeState mempty mempty mempty "." False False
|
||||||
go :: ComputeState -> [QueryItem] -> ComputeState
|
go :: ComputeState -> [QueryItem] -> ComputeState
|
||||||
go c [] = c { computeParams = reverse (computeParams c) }
|
go c [] = c { computeParams = reverse (computeParams c) }
|
||||||
go c ((f, v):rest) =
|
go c ((f, v):rest) =
|
||||||
|
@ -363,8 +364,8 @@ runComputeProgram
|
||||||
-> ComputeState
|
-> ComputeState
|
||||||
-> ImmutableState
|
-> ImmutableState
|
||||||
-> (OsPath -> Annex (Key, Maybe (Either Git.Sha OsPath)))
|
-> (OsPath -> Annex (Key, Maybe (Either Git.Sha OsPath)))
|
||||||
-- ^ get input file's content, or Nothing when adding a computation
|
-- ^ get input file's content, or Nothing the input file's
|
||||||
-- without actually performing it
|
-- content is not available
|
||||||
-> (ComputeState -> OsPath -> NominalDiffTime -> Annex v)
|
-> (ComputeState -> OsPath -> NominalDiffTime -> Annex v)
|
||||||
-> Annex v
|
-> Annex v
|
||||||
runComputeProgram (ComputeProgram program) state (ImmutableState immutablestate) getinputcontent cont =
|
runComputeProgram (ComputeProgram program) state (ImmutableState immutablestate) getinputcontent cont =
|
||||||
|
@ -431,9 +432,13 @@ runComputeProgram (ComputeProgram program) state (ImmutableState immutablestate)
|
||||||
liftIO $ hPutStrLn (stdinHandle p) $
|
liftIO $ hPutStrLn (stdinHandle p) $
|
||||||
maybe "" fromOsPath mp
|
maybe "" fromOsPath mp
|
||||||
liftIO $ hFlush (stdinHandle p)
|
liftIO $ hFlush (stdinHandle p)
|
||||||
|
let state'' = state'
|
||||||
|
{ computeInputsUnavailable =
|
||||||
|
isNothing mp || computeInputsUnavailable state'
|
||||||
|
}
|
||||||
return $ if immutablestate
|
return $ if immutablestate
|
||||||
then state
|
then state''
|
||||||
else state'
|
else state''
|
||||||
{ computeInputs =
|
{ computeInputs =
|
||||||
M.insert f' k
|
M.insert f' k
|
||||||
(computeInputs state')
|
(computeInputs state')
|
||||||
|
@ -444,7 +449,7 @@ runComputeProgram (ComputeProgram program) state (ImmutableState immutablestate)
|
||||||
let knownoutput = M.member f' (computeOutputs state')
|
let knownoutput = M.member f' (computeOutputs state')
|
||||||
checkimmutable knownoutput "outputting" f' $
|
checkimmutable knownoutput "outputting" f' $
|
||||||
return $ if immutablestate
|
return $ if immutablestate
|
||||||
then state
|
then state'
|
||||||
else state'
|
else state'
|
||||||
{ computeOutputs =
|
{ computeOutputs =
|
||||||
M.insert f' Nothing
|
M.insert f' Nothing
|
||||||
|
@ -488,7 +493,7 @@ computeKey rs (ComputeProgram program) k _af dest p vc =
|
||||||
state
|
state
|
||||||
(ImmutableState True)
|
(ImmutableState True)
|
||||||
(getinputcontent state)
|
(getinputcontent state)
|
||||||
(go keyfile)
|
(postcompute keyfile)
|
||||||
Nothing -> missingstate
|
Nothing -> missingstate
|
||||||
Nothing -> missingstate
|
Nothing -> missingstate
|
||||||
where
|
where
|
||||||
|
@ -503,9 +508,10 @@ computeKey rs (ComputeProgram program) k _af dest p vc =
|
||||||
return (inputkey, Just (Right obj))
|
return (inputkey, Just (Right obj))
|
||||||
in ifM (inAnnex inputkey)
|
in ifM (inAnnex inputkey)
|
||||||
( retkey
|
( retkey
|
||||||
, do
|
, ifM (getinputcontent' f inputkey)
|
||||||
getinputcontent' f inputkey
|
( retkey
|
||||||
retkey
|
, return (inputkey, Nothing)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
Just gitsha ->
|
Just gitsha ->
|
||||||
return (inputkey, Just (Left gitsha))
|
return (inputkey, Just (Left gitsha))
|
||||||
|
@ -515,9 +521,7 @@ computeKey rs (ComputeProgram program) k _af dest p vc =
|
||||||
remotelist <- Annex.getState Annex.remotes
|
remotelist <- Annex.getState Annex.remotes
|
||||||
locs <- loggedLocations inputkey
|
locs <- loggedLocations inputkey
|
||||||
remotes <- keyPossibilities' (IncludeIgnored False) inputkey locs remotelist
|
remotes <- keyPossibilities' (IncludeIgnored False) inputkey locs remotelist
|
||||||
if null remotes
|
anyM (getinputcontentfrom f inputkey) remotes
|
||||||
then return ()
|
|
||||||
else void $ firstM (getinputcontentfrom f inputkey) remotes
|
|
||||||
|
|
||||||
-- TODO cycle prevention
|
-- TODO cycle prevention
|
||||||
getinputcontentfrom f inputkey r = do
|
getinputcontentfrom f inputkey r = do
|
||||||
|
@ -533,7 +537,12 @@ computeKey rs (ComputeProgram program) k _af dest p vc =
|
||||||
(keyfile : _) -> Just keyfile
|
(keyfile : _) -> Just keyfile
|
||||||
[] -> Nothing
|
[] -> Nothing
|
||||||
|
|
||||||
go keyfile state tmpdir _ts = do
|
postcompute keyfile state tmpdir _ts
|
||||||
|
| computeInputsUnavailable state =
|
||||||
|
giveup "Input file(s) unavailable."
|
||||||
|
| otherwise = postcompute' keyfile state tmpdir
|
||||||
|
|
||||||
|
postcompute' keyfile state tmpdir = do
|
||||||
hb <- hashBackend
|
hb <- hashBackend
|
||||||
let updatevurl key getobj =
|
let updatevurl key getobj =
|
||||||
if (fromKey keyVariety key == VURLKey)
|
if (fromKey keyVariety key == VURLKey)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue