Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
163
Issues
163
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
dcf385f6
Commit
dcf385f6
authored
Aug 21, 2024
by
Loïc Chapron
Committed by
Grégoire Locqueville
Oct 14, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update from WIP
parent
ec084771
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
16 deletions
+21
-16
EnvTypes.hs
src/Gargantext/API/Admin/EnvTypes.hs
+13
-8
Job.hs
src/Gargantext/API/Job.hs
+1
-1
New.hs
src/Gargantext/API/Node/Corpus/New.hs
+1
-1
Jobs.hs
src/Gargantext/Utils/Jobs.hs
+0
-1
Internal.hs
src/Gargantext/Utils/Jobs/Internal.hs
+3
-4
Monad.hs
src/Gargantext/Utils/Jobs/Monad.hs
+3
-1
No files found.
src/Gargantext/API/Admin/EnvTypes.hs
View file @
dcf385f6
...
@@ -51,7 +51,6 @@ import Gargantext.Core.NodeStory
...
@@ -51,7 +51,6 @@ import Gargantext.Core.NodeStory
import
Gargantext.Database.Prelude
(
HasConnectionPool
(
..
))
import
Gargantext.Database.Prelude
(
HasConnectionPool
(
..
))
import
Gargantext.Prelude
hiding
(
to
)
import
Gargantext.Prelude
hiding
(
to
)
import
Gargantext.System.Logging
import
Gargantext.System.Logging
import
Gargantext.Utils.Jobs.Error
import
Gargantext.Utils.Jobs.Map
(
LoggerM
,
J
(
..
),
jTask
,
rjGetLog
)
import
Gargantext.Utils.Jobs.Map
(
LoggerM
,
J
(
..
),
jTask
,
rjGetLog
)
import
Gargantext.Utils.Jobs.Monad
qualified
as
Jobs
import
Gargantext.Utils.Jobs.Monad
qualified
as
Jobs
import
Network.HTTP.Client
(
Manager
)
import
Network.HTTP.Client
(
Manager
)
...
@@ -61,6 +60,7 @@ import Servant.Job.Async (HasJobEnv(..), Job)
...
@@ -61,6 +60,7 @@ import Servant.Job.Async (HasJobEnv(..), Job)
import
Servant.Job.Async
qualified
as
SJ
import
Servant.Job.Async
qualified
as
SJ
import
Servant.Job.Core
qualified
import
Servant.Job.Core
qualified
import
System.Log.FastLogger
qualified
as
FL
import
System.Log.FastLogger
qualified
as
FL
import
Debug.Trace
as
DT
data
Mode
=
Dev
|
Mock
|
Prod
data
Mode
=
Dev
|
Mock
|
Prod
deriving
(
Show
,
Read
,
Generic
)
deriving
(
Show
,
Read
,
Generic
)
...
@@ -185,21 +185,19 @@ data ConcreteJobHandle err =
...
@@ -185,21 +185,19 @@ data ConcreteJobHandle err =
|
JobHandle
{
|
JobHandle
{
_jh_id
::
!
(
SJ
.
JobID
'S
J
.
Safe
)
_jh_id
::
!
(
SJ
.
JobID
'S
J
.
Safe
)
,
_jh_logger
::
LoggerM
(
GargM
Env
err
)
JobLog
,
_jh_logger
::
LoggerM
(
GargM
Env
err
)
JobLog
,
_jh_warnings
::
[
WarningDiagnostic
]
}
}
-- | Creates a new /concrete/ 'JobHandle', given its underlying 'JobID' and the logging function to
-- | Creates a new /concrete/ 'JobHandle', given its underlying 'JobID' and the logging function to
-- be used to report the status.
-- be used to report the status.
mkJobHandle
::
SJ
.
JobID
'S
J
.
Safe
mkJobHandle
::
SJ
.
JobID
'S
J
.
Safe
->
LoggerM
(
GargM
Env
err
)
JobLog
->
LoggerM
(
GargM
Env
err
)
JobLog
->
[
WarningDiagnostic
]
->
ConcreteJobHandle
err
->
ConcreteJobHandle
err
mkJobHandle
jId
=
JobHandle
jId
mkJobHandle
jId
=
JobHandle
jId
-- | Updates the status of a 'JobHandle' by using the input 'updateJobStatus' function.
-- | Updates the status of a 'JobHandle' by using the input 'updateJobStatus' function.
updateJobProgress
::
ConcreteJobHandle
err
->
(
JobLog
->
JobLog
)
->
GargM
Env
err
()
updateJobProgress
::
ConcreteJobHandle
err
->
(
JobLog
->
JobLog
)
->
GargM
Env
err
()
updateJobProgress
ConcreteNullHandle
_
=
pure
()
updateJobProgress
ConcreteNullHandle
_
=
pure
()
updateJobProgress
hdl
@
(
JobHandle
_
logStatus
_
)
updateJobStatus
=
updateJobProgress
hdl
@
(
JobHandle
_
logStatus
)
updateJobStatus
=
Jobs
.
getLatestJobStatus
hdl
>>=
logStatus
.
updateJobStatus
Jobs
.
getLatestJobStatus
hdl
>>=
logStatus
.
updateJobStatus
...
@@ -213,7 +211,7 @@ instance Jobs.MonadJobStatus (GargM Env err) where
...
@@ -213,7 +211,7 @@ instance Jobs.MonadJobStatus (GargM Env err) where
noJobHandle
Proxy
=
ConcreteNullHandle
noJobHandle
Proxy
=
ConcreteNullHandle
getLatestJobStatus
ConcreteNullHandle
=
pure
noJobLog
getLatestJobStatus
ConcreteNullHandle
=
pure
noJobLog
getLatestJobStatus
(
JobHandle
jId
_
_
)
=
do
getLatestJobStatus
(
JobHandle
jId
_
)
=
do
mb_jb
<-
Jobs
.
findJob
jId
mb_jb
<-
Jobs
.
findJob
jId
case
mb_jb
of
case
mb_jb
of
Nothing
->
pure
noJobLog
Nothing
->
pure
noJobLog
...
@@ -228,7 +226,7 @@ instance Jobs.MonadJobStatus (GargM Env err) where
...
@@ -228,7 +226,7 @@ instance Jobs.MonadJobStatus (GargM Env err) where
l
:<
_
->
l
l
:<
_
->
l
withTracer
_
ConcreteNullHandle
f
=
f
ConcreteNullHandle
withTracer
_
ConcreteNullHandle
f
=
f
ConcreteNullHandle
withTracer
extraLogger
(
JobHandle
jId
logger
_
)
n
=
n
(
JobHandle
jId
(
\
w
->
logger
w
>>
liftIO
(
extraLogger
w
))
[]
)
withTracer
extraLogger
(
JobHandle
jId
logger
)
n
=
n
(
JobHandle
jId
(
\
w
->
logger
w
>>
liftIO
(
extraLogger
w
))
)
markStarted
n
jh
=
updateJobProgress
jh
(
const
$
jobLogStart
(
RemainingSteps
n
))
markStarted
n
jh
=
updateJobProgress
jh
(
const
$
jobLogStart
(
RemainingSteps
n
))
...
@@ -242,7 +240,12 @@ instance Jobs.MonadJobStatus (GargM Env err) where
...
@@ -242,7 +240,12 @@ instance Jobs.MonadJobStatus (GargM Env err) where
markComplete
jh
=
updateJobProgress
jh
jobLogComplete
markComplete
jh
=
updateJobProgress
jh
jobLogComplete
markWarning
jh
warn
=
updateJobProgress
jh
(
addWarningEvent
warn
)
markCompleteWithWarning
h
diag
=
do
Jobs
.
emitWarning
h
diag
Jobs
.
markComplete
h
emitWarning
jh
warn
=
DT
.
trace
(
"Test"
)
$
updateJobProgress
jh
(
addWarningEvent
warn
)
markFailed
mb_msg
jh
=
markFailed
mb_msg
jh
=
updateJobProgress
jh
(
\
latest
->
case
mb_msg
of
updateJobProgress
jh
(
\
latest
->
case
mb_msg
of
...
@@ -321,7 +324,9 @@ instance Jobs.MonadJobStatus (GargM DevEnv err) where
...
@@ -321,7 +324,9 @@ instance Jobs.MonadJobStatus (GargM DevEnv err) where
markComplete
_
=
pure
()
markComplete
_
=
pure
()
markWarning
_
_
=
pure
()
markCompleteWithWarning
_
_
=
pure
()
emitWarning
_
_
=
pure
()
markFailed
_
_
=
pure
()
markFailed
_
_
=
pure
()
...
...
src/Gargantext/API/Job.hs
View file @
dcf385f6
...
@@ -51,7 +51,7 @@ addErrorEvent :: ToHumanFriendlyError e => e -> JobLog -> JobLog
...
@@ -51,7 +51,7 @@ addErrorEvent :: ToHumanFriendlyError e => e -> JobLog -> JobLog
addErrorEvent
message
=
addEvent
"ERROR"
(
mkHumanFriendly
message
)
addErrorEvent
message
=
addEvent
"ERROR"
(
mkHumanFriendly
message
)
addWarningEvent
::
WarningDiagnostic
->
JobLog
->
JobLog
addWarningEvent
::
WarningDiagnostic
->
JobLog
->
JobLog
addWarningEvent
message
=
addEvent
"
WARNING
"
(
renderWarningDiagnostic
message
)
addWarningEvent
message
=
addEvent
"
ERROR
"
(
renderWarningDiagnostic
message
)
jobLogProgress
::
Int
->
JobLog
->
JobLog
jobLogProgress
::
Int
->
JobLog
->
JobLog
jobLogProgress
n
jl
=
over
(
scst_succeeded
.
_Just
)
(
+
n
)
$
jobLogProgress
n
jl
=
over
(
scst_succeeded
.
_Just
)
(
+
n
)
$
...
...
src/Gargantext/API/Node/Corpus/New.hs
View file @
dcf385f6
...
@@ -296,7 +296,7 @@ addToCorpusWithForm user cid nwf jobHandle = do
...
@@ -296,7 +296,7 @@ addToCorpusWithForm user cid nwf jobHandle = do
-- TODO uncomment this
-- TODO uncomment this
--sendMail user
--sendMail user
mark
Warning
jobHandle
(
Warn
.
MissingAbstractFromCorpus
"Test"
)
emit
Warning
jobHandle
(
Warn
.
MissingAbstractFromCorpus
"Test"
)
$
(
logLocM
)
WARNING
$
T
.
pack
$
"Warning in parsing"
$
(
logLocM
)
WARNING
$
T
.
pack
$
"Warning in parsing"
--markFailed (Just $ Parser.ParseFormatError "Test") jobHandle
--markFailed (Just $ Parser.ParseFormatError "Test") jobHandle
...
...
src/Gargantext/Utils/Jobs.hs
View file @
dcf385f6
...
@@ -29,7 +29,6 @@ import Prelude
...
@@ -29,7 +29,6 @@ import Prelude
import
System.Directory
(
doesFileExist
)
import
System.Directory
(
doesFileExist
)
import
Text.Read
(
readMaybe
)
import
Text.Read
(
readMaybe
)
import
qualified
Data.Text
as
T
import
qualified
Data.Text
as
T
import
Gargantext.API.Admin.EnvTypes
(
mkJobHandle
,
Env
,
GargJob
(
..
)
)
import
Gargantext.API.Admin.EnvTypes
(
mkJobHandle
,
Env
,
GargJob
(
..
)
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
(
InternalJobError
)
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
(
InternalJobError
)
)
import
Gargantext.API.Prelude
(
GargM
)
import
Gargantext.API.Prelude
(
GargM
)
...
...
src/Gargantext/Utils/Jobs/Internal.hs
View file @
dcf385f6
...
@@ -27,7 +27,6 @@ import Servant.API.Alternative
...
@@ -27,7 +27,6 @@ import Servant.API.Alternative
import
Servant.API.ContentTypes
import
Servant.API.ContentTypes
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.Utils.Jobs.Error
import
Gargantext.Utils.Jobs.Map
import
Gargantext.Utils.Jobs.Map
import
Gargantext.Utils.Jobs.Monad
import
Gargantext.Utils.Jobs.Monad
...
@@ -44,7 +43,7 @@ serveJobsAPI
...
@@ -44,7 +43,7 @@ serveJobsAPI
,
ToJSON
event
,
ToJSON
output
,
MimeRender
JSON
output
,
ToJSON
event
,
ToJSON
output
,
MimeRender
JSON
output
,
Foldable
callback
,
Foldable
callback
)
)
=>
(
SJ
.
JobID
'S
J
.
Safe
->
LoggerM
m
event
->
[
WarningDiagnostic
]
->
JobHandle
m
)
=>
(
SJ
.
JobID
'S
J
.
Safe
->
LoggerM
m
event
->
JobHandle
m
)
->
m
env
->
m
env
->
t
->
t
->
(
JobError
->
BackendInternalError
)
->
(
JobError
->
BackendInternalError
)
...
@@ -83,7 +82,7 @@ newJob
...
@@ -83,7 +82,7 @@ newJob
,
MimeRender
JSON
output
,
MimeRender
JSON
output
,
Foldable
callbacks
,
Foldable
callbacks
)
)
=>
(
SJ
.
JobID
'S
J
.
Safe
->
LoggerM
m
event
->
[
WarningDiagnostic
]
->
JobHandle
m
)
=>
(
SJ
.
JobID
'S
J
.
Safe
->
LoggerM
m
event
->
JobHandle
m
)
->
m
env
->
m
env
->
t
->
t
->
(
env
->
JobHandle
m
->
input
->
IO
(
Either
BackendInternalError
output
))
->
(
env
->
JobHandle
m
->
input
->
IO
(
Either
BackendInternalError
output
))
...
@@ -102,7 +101,7 @@ newJob newJobHandle getenv jobkind f input = do
...
@@ -102,7 +101,7 @@ newJob newJobHandle getenv jobkind f input = do
f'
jId
inp
logF
=
do
f'
jId
inp
logF
=
do
catch
(
do
catch
(
do
r
<-
f
env
(
newJobHandle
jId
(
liftIO
.
pushLog
logF
.
Seq
.
singleton
)
[]
)
inp
r
<-
f
env
(
newJobHandle
jId
(
liftIO
.
pushLog
logF
.
Seq
.
singleton
))
inp
case
r
of
case
r
of
Left
e
->
postCallback
(
SJ
.
mkChanError
e
)
>>
throwIO
e
Left
e
->
postCallback
(
SJ
.
mkChanError
e
)
>>
throwIO
e
Right
a
->
postCallback
(
SJ
.
mkChanResult
a
)
>>
pure
a
)
Right
a
->
postCallback
(
SJ
.
mkChanResult
a
)
>>
pure
a
)
...
...
src/Gargantext/Utils/Jobs/Monad.hs
View file @
dcf385f6
...
@@ -224,8 +224,10 @@ class MonadJobStatus m where
...
@@ -224,8 +224,10 @@ class MonadJobStatus m where
-- | Finish tracking a job by marking all the remaining steps as succeeded.
-- | Finish tracking a job by marking all the remaining steps as succeeded.
markComplete
::
JobHandle
m
->
m
()
markComplete
::
JobHandle
m
->
m
()
markCompleteWithWarning
::
MonadJobStatus
m
=>
JobHandle
m
->
WarningDiagnostic
->
m
()
-- |
-- |
mark
Warning
::
JobHandle
m
->
WarningDiagnostic
->
m
()
emit
Warning
::
JobHandle
m
->
WarningDiagnostic
->
m
()
-- | Finish tracking a job by marking all the remaining steps as failed. Attach an optional
-- | Finish tracking a job by marking all the remaining steps as failed. Attach an optional
-- message to the failure.
-- message to the failure.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment