[flow] allow for API errors during flow

Continue with the flow and import terms.

This way, a failed API call doesn't prevent from the job to finish
gracefully.

TODO: Print a nice, formatted error
parent fe9e25bf
Pipeline #7862 passed with stages
in 50 minutes and 9 seconds
......@@ -23,7 +23,7 @@ import Gargantext.API.Admin.EnvTypes (Env)
import Gargantext.API.Errors.Types ( BackendInternalError )
import Gargantext.API.Node.Corpus.New (addToCorpusWithTempFile)
import Gargantext.API.Node.Corpus.New.Types (FileFormat(..), FileType(..))
import Gargantext.API.Node.FrameCalcUpload.Types
import Gargantext.API.Node.FrameCalcUpload.Types ( FrameCalcUpload(FrameCalcUpload) )
import Gargantext.API.Node.Types (NewWithTempFile(..))
import Gargantext.API.Prelude ( GargM )
import Gargantext.API.Routes.Named.FrameCalc qualified as Named
......
......@@ -112,7 +112,7 @@ import Gargantext.Database.Schema.Node
import Gargantext.Database.Types
import Gargantext.Prelude hiding (catch, onException, to)
import Gargantext.System.Logging ( logLocM, LogLevel(DEBUG, ERROR), MonadLogger )
import Gargantext.Utils.Jobs.Monad ( JobHandle, MonadJobStatus(..) )
import Gargantext.Utils.Jobs.Monad ( JobHandle, MonadJobStatus(..), markFailureNoErr )
------------------------------------------------------------------------
-- Imports for upgrade function
......@@ -298,10 +298,14 @@ flow c mkCorpusUser la mfslw (count, docsC) jobHandle = do
(_userId, userCorpusId, listId, msgs) <- runDBTx $ createNodes cfg mkCorpusUser c
forM_ msgs ce_notify
-- TODO if public insertMasterDocs else insertUserDocs
runConduit $ zipSources (yieldMany ([1..] :: [Int])) docsC
(runConduit $ zipSources (yieldMany ([1..] :: [Int])) docsC
.| CList.chunksOf 5
.| mapM_C (addDocumentsWithProgress userCorpusId)
.| sinkNull
.| sinkNull) `CES.catch` (\(e :: SomeException) -> do
$(logLocM) ERROR $ "Exception during API call: " <> show e
markFailureNoErr 1 jobHandle
-- ignore this and proceed with list generation
pure ())
let u = userFromMkCorpusUser mkCorpusUser
......@@ -427,7 +431,7 @@ buildSocialList l user userCorpusId listId ctype = \case
(master_user_id, _masterRootId, master_corpus_id)
<- getOrMkRootWithCorpus cfg MkCorpusUserMaster ctype
let gp = GroupWithPosTag l nlpServer HashMap.empty
let gp = GroupWithPosTag { _gwl_lang = l, _gwl_nlp_config = nlpServer, _gwl_map = mempty }
(master_user_id, master_corpus_id,) <$> buildNgramsLists user userCorpusId master_corpus_id mfslw gp
-- printDebug "flowCorpusUser:ngs" ngs
......
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