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
153
Issues
153
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
ce5d8d25
Verified
Commit
ce5d8d25
authored
Mar 31, 2023
by
Przemyslaw Kaminski
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[list] fixes to list CSV upload
Now, error should be reported, provided we fix job logs (?)
parent
33881047
Pipeline
#3829
failed with stage
in 29 minutes and 40 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
29 deletions
+41
-29
gargantext.cabal
gargantext.cabal
+0
-1
List.hs
src/Gargantext/API/Ngrams/List.hs
+41
-28
No files found.
gargantext.cabal
View file @
ce5d8d25
...
...
@@ -45,7 +45,6 @@ library
Gargantext.API.Node.Share
Gargantext.API.Prelude
Gargantext.Core
Gargantext.Core.NLP
Gargantext.Core.Methods.Similarities
Gargantext.Core.NLP
Gargantext.Core.NodeStory
...
...
src/Gargantext/API/Ngrams/List.hs
View file @
ce5d8d25
...
...
@@ -25,6 +25,7 @@ import Data.Text (Text, concat, pack, splitOn)
import
Data.Vector
(
Vector
)
import
Gargantext.API.Admin.EnvTypes
(
Env
,
GargJob
(
..
))
import
Gargantext.API.Admin.Orchestrator.Types
import
Gargantext.API.Job
(
jobLogFailTotalWithMessage
,
jobLogSuccess
)
import
Gargantext.API.Ngrams
(
setListNgrams
)
import
Gargantext.API.Ngrams.List.Types
import
Gargantext.API.Ngrams.Prelude
(
getNgramsList
)
...
...
@@ -235,10 +236,10 @@ postAsync' l (WithJsonFile m _) logStatus = do
------------------------------------------------------------------------
readCsvText
::
Text
->
[(
Text
,
Text
,
Text
)]
readCsvText
::
Text
->
Either
Text
[(
Text
,
Text
,
Text
)]
readCsvText
t
=
case
eDec
of
Left
_
->
[]
Right
dec
->
Vec
.
toList
dec
Left
err
->
Left
$
pack
err
Right
dec
->
Right
$
Vec
.
toList
dec
where
lt
=
BSL
.
fromStrict
$
P
.
encodeUtf8
t
eDec
=
Csv
.
decodeWith
...
...
@@ -268,22 +269,25 @@ parseCsvData lst = Map.fromList $ conv <$> lst
csvPost
::
FlowCmdM
env
err
m
=>
ListId
->
Text
->
m
Bool
->
m
(
Either
Text
()
)
csvPost
l
m
=
do
-- printDebug "[csvPost] l" l
-- printDebug "[csvPost] m" m
-- status label forms
let
lst
=
readCsvText
m
let
p
=
parseCsvData
lst
--printDebug "[csvPost] lst" lst
-- printDebug "[csvPost] p" p
_
<-
setListNgrams
l
NgramsTerms
p
-- printDebug "ReIndexing List" l
corpus_node
<-
getNode
l
-- (Proxy :: Proxy HyperdataList)
let
corpus_id
=
fromMaybe
(
panic
""
)
(
_node_parent_id
corpus_node
)
_
<-
reIndexWith
corpus_id
l
NgramsTerms
(
Set
.
fromList
[
MapTerm
,
CandidateTerm
])
pure
True
let
eLst
=
readCsvText
m
case
eLst
of
Left
err
->
pure
$
Left
err
Right
lst
->
do
let
p
=
parseCsvData
lst
--printDebug "[csvPost] lst" lst
-- printDebug "[csvPost] p" p
_
<-
setListNgrams
l
NgramsTerms
p
-- printDebug "ReIndexing List" l
corpus_node
<-
getNode
l
-- (Proxy :: Proxy HyperdataList)
let
corpus_id
=
fromMaybe
(
panic
""
)
(
_node_parent_id
corpus_node
)
_
<-
reIndexWith
corpus_id
l
NgramsTerms
(
Set
.
fromList
[
MapTerm
,
CandidateTerm
])
pure
$
Right
()
------------------------------------------------------------------------
csvPostAsync
::
ServerT
CSVAPI
(
GargM
Env
GargError
)
...
...
@@ -293,7 +297,10 @@ csvPostAsync lId =
-- printDebug "[csvPostAsync] filetype" ft
-- printDebug "[csvPostAsync] name" n
jobHandleLogger
jHandle
x
csvPostAsync'
lId
f
log''
jl
<-
csvPostAsync'
lId
f
log''
printDebug
"[csvPostAsync] job ended with joblog: "
jl
log''
jl
pure
jl
csvPostAsync'
::
FlowCmdM
env
err
m
...
...
@@ -302,16 +309,22 @@ csvPostAsync' :: FlowCmdM env err m
->
(
JobLog
->
m
()
)
->
m
JobLog
csvPostAsync'
l
(
WithTextFile
_
m
_
)
logStatus
=
do
logStatus
JobLog
{
_scst_succeeded
=
Just
0
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
1
,
_scst_events
=
Just
[]
}
_r
<-
csvPost
l
m
pure
JobLog
{
_scst_succeeded
=
Just
1
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
0
,
_scst_events
=
Just
[]
}
let
jl
=
JobLog
{
_scst_succeeded
=
Just
0
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
1
,
_scst_events
=
Just
[]
}
logStatus
jl
ePost
<-
csvPost
l
m
case
ePost
of
Left
err
->
pure
$
jobLogFailTotalWithMessage
err
jl
Right
()
->
pure
$
jobLogSuccess
jl
------------------------------------------------------------------------
-- | This is for debugging the CSV parser in the REPL
importCsvFile
::
FlowCmdM
env
err
m
=>
ListId
->
P
.
FilePath
->
m
(
Either
Text
()
)
importCsvFile
lId
fp
=
do
contents
<-
liftBase
$
P
.
readFile
fp
csvPost
lId
contents
Przemyslaw Kaminski
@cgenie
mentioned in issue
#191 (closed)
·
Mar 31, 2023
mentioned in issue
#191 (closed)
mentioned in issue #191
Toggle commit list
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