Commit 1dd5a40d authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] merge

parents 189c9ee7 a0ec337b
......@@ -33,7 +33,6 @@ deps
_darcs
*.pdf
*.png
*.sql
*.ini
*.toml
!test-data/test_config.ini
......
# Optimising CI speed by using tips from https://blog.nimbleways.com/let-s-make-faster-gitlab-ci-cd-pipelines/
image: adinapoli/gargantext:v3.4
#image: adinapoli/gargantext:v3.4
image: cgenie/gargantext:9.4.8
variables:
STACK_ROOT: "${CI_PROJECT_DIR}/.stack-root"
......
## Version 0.0.7.3.1
* [FRONT][FIX][Cannot build the project on latest `dev` (#701)](https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/701)
* [FRONT][FIX][Phylomemy panel reload after first query (#674)](https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/674)
* [BACK][FIX][Various test failures (#408)](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/408)
* [BACK][FIX][Swagger documentation is down (#407)](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/407)
* [BACK][ADMIN][Improve startup error from
`runDbCheck`](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/merge_requests/347)
* [BACK][CLEAN] removing unused SQL function in schema.sql
* [BACK][TESTS][Terms are calculated over all documents, even those in trash (#385)](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/385)
## Version 0.0.7.3 [/!\ Maintenance command inside]
* [BACK][FIX][Upgrade to GHC 9.4.8][Switch from .ini to TOML? (#304)](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/304)
* [BACK][CLEAN][Unused trigger](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/merge_requests/345)
* ``` $ ./bin/psql gargantext.ini < devops/postgres/upgrade/0.0.7.3.sql```
* [BACK][Update Readme](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/merge_requests/346)
* [FRONT][FIX][[Node document] Display the db source of a document (with authors, etc.) (#695)](https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/695)
* [FRONT][FIX][Add separators between keywords in phylo (#696)](https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/696)
* [FRONT][FIX][[Node Terms] In settings, on the download tab, put JSON as default selectbox choice, instead of the current JSON (zipped) (#691)](https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/691)
* [BACK][FIX][Order 2] Back to previous parameter WIP
## Version 0.0.7.2.8
* [BACK][FEAT][Switch from .ini to TOML? (#304)](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/304)
* [BACK][SCRIPTS][Improve conversion script
](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/merge_requests/341)
* [BACK][FIX][Remove obsolete GHC option (#388)](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/388)
* [DOC][README][Little update to README, docs and .gitignore
interface](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/merge_requests/343)
## Version 0.0.7.2.7
* [BACK][FEAT][Switch from .ini to TOML? (#304)](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/304)
......
......@@ -190,9 +190,11 @@ The initialization schema should be loaded automatically from `devops/postgres/s
$ cp gargantext-settings.toml_toModify gargantext-settings.toml
```
**NOTE** If you had the `gargantext.ini` file before, you can automatically generate toml with:
**NOTE** If you had the `gargantext.ini` file before, you can automatically
convert it into a file `gargantext-settings.toml` by running the following
from a Nix shell:
```shell
n$ cabal run gargantext-cli -- ini --ini-path gargantext.ini --toml-path gargantext-settings.toml
n$ cabal v2-run gargantext-cli -- ini
```
> `.gitignore` excludes this file, so you don't need to worry about
......@@ -236,6 +238,27 @@ If you want to run particular tests, use:
cabal v2-test garg-test-tasty --test-show-details=streaming --test-option=--pattern='/job status update and tracking/
```
### CI
The CI is on gitlab and is controlled by the `.gitlab-ci.yml` file.
The Docker image that is used can be built with:
```shell
podman build -t cgenie/gargantext:9.4.8 -f ./devops/docker/Dockerfile --format=docker .
```
or
```shell
docker build -t cgenie/gargantext:9.4.8 -f ./devops/docker/Dockerfile .
```
NOTE: if podman/docker complains about not enough space, it's probably
about tmpfs. In that case you can set
```shell
mkdir _build
export TMPDIR=$(pwd)/_build
```
(https://stackoverflow.com/questions/75845647/changing-podman-build-to-path-with-more-space).
### Working on libraries
When a devlopment is needed on libraries (for instance, the HAL crawler in https://gitlab.iscpif.fr/gargantext/crawlers):
......
......@@ -18,13 +18,12 @@ fi
# with the `sha256sum` result calculated on the `cabal.project` and
# `cabal.project.freeze`. This ensures the files stay deterministic so that CI
# cache can kick in.
expected_cabal_project_hash="3943da8b9f3ae918afadf2b302875b3b395b31b2f69c3d42135af2ac800b7a0c"
expected_cabal_project_freeze_hash="af825192f1ec47b07e6001dd2556b59991c9e6c50094dc732ee933a41f0dc9bd"
expected_cabal_project_hash="3afb11e01938b74ae8419caa160180d8f8628a67315a2d689c3a42a76463071e"
expected_cabal_project_freeze_hash="de1726d350936da5f5e15140e3be29bb4f44757c5702defe995c2386f1b4a741"
cabal --store-dir=$STORE_DIR v2-build --dry-run
cabal2stack --system-ghc --allow-newer --resolver lts-21.17 --resolver-file devops/stack/lts-21.17.yaml -o stack.yaml
cabal --store-dir=$STORE_DIR v2-freeze
cabal2stack --system-ghc --allow-newer --resolver lts-21.25 --resolver-file devops/stack/lts-21.25.yaml -o stack.yaml
# Run 'sed' to remove the constraint for 'gargantext', as it doesn't make sense and
# for the test we need to run this with a different flag.
......
......@@ -3,7 +3,7 @@
-- index-state: 2023-12-10T10:34:46Z
index-state: 2024-09-12T03:02:26Z
with-compiler: ghc-9.4.7
with-compiler: ghc-9.4.8
optimization: 2
packages:
......
......@@ -8,7 +8,7 @@ constraints: any.Cabal ==3.8.1.0,
any.JuicyPixels ==3.3.9,
JuicyPixels -mmap,
any.KMP ==0.2.0.0,
any.MissingH ==1.4.3.1,
any.MissingH ==1.6.0.1,
MissingH +network--ge-3_0_0,
any.MonadRandom ==0.6,
any.OneTuple ==0.4.2,
......@@ -57,7 +57,7 @@ constraints: any.Cabal ==3.8.1.0,
any.authenticate-oauth ==1.7,
any.auto-update ==0.1.6,
any.barbies ==2.1.1.0,
any.base ==4.17.2.0,
any.base ==4.17.2.1,
any.base-compat ==0.13.1,
any.base-compat-batteries ==0.13.1,
any.base-orphans ==0.9.2,
......@@ -84,7 +84,7 @@ constraints: any.Cabal ==3.8.1.0,
any.bsb-http-chunked ==0.0.0.4,
any.byteable ==0.1.1,
any.byteorder ==1.0.4,
any.bytestring ==0.11.5.2,
any.bytestring ==0.11.5.3,
any.bytestring-builder ==0.10.8.2.0,
bytestring-builder +bytestring_has_builder,
any.bzlib-conduit ==0.3.0.3,
......@@ -203,13 +203,13 @@ constraints: any.Cabal ==3.8.1.0,
any.generic-monoid ==0.1.0.1,
any.generically ==0.1.1,
any.generics-sop ==0.5.1.3,
any.ghc ==9.4.7,
any.ghc ==9.4.8,
any.ghc-bignum ==1.3,
any.ghc-boot ==9.4.7,
any.ghc-boot-th ==9.4.7,
any.ghc-heap ==9.4.7,
any.ghc-boot ==9.4.8,
any.ghc-boot-th ==9.4.8,
any.ghc-heap ==9.4.8,
any.ghc-prim ==0.9.1,
any.ghci ==9.4.7,
any.ghci ==9.4.8,
any.githash ==0.1.7.0,
any.graphviz ==2999.20.2.0,
graphviz -test-parsing,
......@@ -395,7 +395,7 @@ constraints: any.Cabal ==3.8.1.0,
any.primitive ==0.7.4.0,
any.primitive-extras ==0.10.2,
any.primitive-unlifted ==2.1.0.0,
any.process ==1.6.17.0,
any.process ==1.6.18.0,
any.product-profunctors ==0.11.1.1,
any.profunctors ==5.6.2,
any.promises ==0.3,
......
......@@ -3,7 +3,7 @@ FROM ubuntu:noble
## NOTA BENE: In order for this to be built successfully, you have to run ./devops/coreNLP/build.sh first.
ARG DEBIAN_FRONTEND=noninteractive
ARG GHC=9.4.7
ARG GHC=9.4.8
ARG CORENLP=4.5.4
ARG CORE
COPY ./shell.nix /builds/gargantext/shell.nix
......
......@@ -404,35 +404,3 @@ FOR EACH ROW
EXECUTE PROCEDURE check_node_stories_json();
CREATE OR REPLACE FUNCTION check_ngrams_json()
RETURNS TRIGGER AS $$
DECLARE
missing_ngrams_exist boolean;
BEGIN
WITH child_ngrams as
(SELECT jsonb_array_elements_text(ngrams_repo_element->'children') AS term
FROM node_stories
WHERE term = OLD.terms),
parent_ngrams AS
(SELECT ngrams_repo_element->>'root' AS term
FROM node_stories
WHERE term = OLD.terms),
child_parent_ngrams AS
(SELECT * FROM child_ngrams
UNION SELECT * FROM parent_ngrams)
SELECT EXISTS(SELECT * FROM child_parent_ngrams) INTO missing_ngrams_exist;
IF missing_ngrams_exist THEN
RAISE EXCEPTION 'ngrams are missing: %', row_to_json(OLD);
END IF;
RETURN OLD;
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE TRIGGER check_ngrams_json_trg
AFTER DELETE
ON ngrams
FOR EACH ROW
EXECUTE PROCEDURE check_ngrams_json();
-- This removes the trigger prevening ngrams deletion
-- because the function was not working.
DROP TRIGGER check_ngrams_json_trg ON ngrams;
DROP FUNCTION check_ngrams_json;
# https://github.com/commercialhaskell/stackage-snapshots/blob/master/lts/21/17.yaml
flags:
HsOpenSSL:
fast-bignum: false
......
This diff is collapsed.
......@@ -5,7 +5,7 @@ cabal-version: 3.4
-- see: https://github.com/sol/hpack
name: gargantext
version: 0.0.7.2.7
version: 0.0.7.3.1
synopsis: Search, map, share
description: Please see README.md
category: Data
......@@ -34,6 +34,7 @@ data-files:
ekg-assets/cross.png
test-data/ngrams/GarganText_NgramsTerms-QuantumComputing.json
test-data/ngrams/GarganText_DocsList-nodeId-177.json
test-data/ngrams/GarganText_NgramsTerms-nodeId-177.json
test-data/ngrams/simple.json
test-data/ngrams/simple.tsv
test-data/phylo/bpa_phylo_test.json
......@@ -249,6 +250,7 @@ library
Gargantext.Database.Admin.Types.Hyperdata
Gargantext.Database.Admin.Types.Hyperdata.Corpus
Gargantext.Database.Admin.Types.Hyperdata.Document
Gargantext.Database.Admin.Types.Hyperdata.Folder
Gargantext.Database.Admin.Types.Node
Gargantext.Database.Prelude
Gargantext.Database.Query.Facet
......@@ -419,7 +421,6 @@ library
Gargantext.Database.Admin.Types.Hyperdata.Dashboard
Gargantext.Database.Admin.Types.Hyperdata.Default
Gargantext.Database.Admin.Types.Hyperdata.File
Gargantext.Database.Admin.Types.Hyperdata.Folder
Gargantext.Database.Admin.Types.Hyperdata.Frame
Gargantext.Database.Admin.Types.Hyperdata.List
Gargantext.Database.Admin.Types.Hyperdata.Model
......@@ -472,7 +473,7 @@ library
cpp-options: -DNO_PHYLO_DEBUG_LOGS
build-depends:
KMP ^>= 0.2.0.0
, MissingH ^>= 1.4.3.0
, MissingH ^>= 1.6.0.1
, MonadRandom ^>= 0.6
, QuickCheck ^>= 2.14.2
, accelerate ^>= 1.3.0.0
......@@ -485,14 +486,14 @@ library
, base64-bytestring ^>= 1.2.1.0
, bimap >= 0.5.0
, boolexpr ^>= 0.3
, bytestring ^>= 0.11.5.2
, bytestring ^>= 0.11.5.3
, cache >= 0.1.3.0
, case-insensitive ^>= 1.2.1.0
, cassava ^>= 0.5.2.0
, cereal ^>= 0.5.8.2
, clock >= 0.8
, conduit ^>= 1.3.4.2
, containers ^>= 0.6.5.1
, containers ^>= 0.6.7
, crawlerArxiv
, crawlerHAL
, crawlerISTEX
......@@ -501,16 +502,16 @@ library
, cron ^>= 0.7.0
, data-time-segment ^>= 0.1.0.0
, deferred-folds >= 0.9.18 && < 0.10
, directory ^>= 1.3.6.0
, directory ^>= 1.3.7.1
, discrimination >= 0.5
, ekg-core ^>= 0.1.1.7
, ekg-json ^>= 0.1.0.7
, epo-api-client
, exceptions ^>= 0.10.4
, exceptions ^>= 0.10.5
, extra ^>= 1.7.9
, fast-logger ^>= 3.2.2
, fgl ^>= 5.8.0.0
, filepath ^>= 1.4.2.1
, filepath ^>= 1.4.2.2
, fmt
, formatting ^>= 7.2.0
, fullstop ^>= 0.1.4
......@@ -552,11 +553,11 @@ library
, opaleye-textsearch >= 0.2.0.0
, openalex
, parallel ^>= 3.2.2.0
, parsec ^>= 3.1.14.0
, parsec ^>= 3.1.16.1
, patches-class ^>= 0.1.0.1
, patches-map ^>= 0.1.0.1
, postgresql-simple ^>= 0.6.4
, process ^>= 1.6.13.2
, process ^>= 1.6.18.0
, product-profunctors ^>= 0.11.0.3
, protolude ^>= 0.3.3
, quickcheck-instances ^>= 0.3.25.2
......@@ -649,11 +650,11 @@ executable gargantext-cli
aeson ^>= 2.1.2.1
, aeson-pretty
, async ^>= 2.2.4
, bytestring ^>= 0.11.5.2
, bytestring ^>= 0.11.5.3
, cassava ^>= 0.5.2.0
, containers ^>= 0.6.5.1
, containers ^>= 0.6.7
, cryptohash ^>= 0.11.9
, directory ^>= 1.3.6.0
, directory ^>= 1.3.7.1
, extra ^>= 1.7.9
, gargantext
, gargantext-prelude
......@@ -691,7 +692,7 @@ executable gargantext-server
bin/gargantext-server
build-depends:
cassava ^>= 0.5.2.0
, containers ^>= 0.6.5.1
, containers ^>= 0.6.7
, extra ^>= 1.7.9
, gargantext
, gargantext-prelude
......@@ -711,14 +712,14 @@ common testDependencies
, aeson-qq
, async ^>= 2.2.4
, boolexpr ^>= 0.3
, bytestring ^>= 0.11.5.2
, bytestring ^>= 0.11.5.3
, cache >= 0.1.3.0
, case-insensitive
, conduit ^>= 1.3.4.2
, containers ^>= 0.6.5.1
, containers ^>= 0.6.7
, crawlerArxiv
, cryptohash
, directory
, directory ^>= 1.3.7.1
, epo-api-client
, extra ^>= 1.7.9
, fast-logger ^>= 3.2.2
......@@ -740,13 +741,13 @@ common testDependencies
, monad-control >= 1.0.3 && < 1.1
, mtl ^>= 2.2.2
, network-uri
, parsec ^>= 3.1.14.0
, parsec ^>= 3.1.16.1
, patches-class ^>= 0.1.0.1
, patches-map ^>= 0.1.0.1
, postgres-options >= 0.2 && < 0.3
, postgresql-simple >= 0.6.4 && < 0.7
, pretty
, process ^>= 1.6.13.2
, pretty ^>= 1.1.3.6
, process ^>= 1.6.18.0
, protolude ^>= 0.3.3
, quickcheck-instances ^>= 0.3.25.2
, raw-strings-qq
......@@ -879,7 +880,7 @@ benchmark garg-bench
other-modules:
Paths_gargantext
build-depends: base
, bytestring ^>= 0.11.5.2
, bytestring ^>= 0.11.5.3
, gargantext
, gargantext-prelude
, tasty-bench
......
cradle:
cabal:
- path: "./src"
component: "lib:gargantext"
- path: "./bin/gargantext-cli/Main.hs"
component: "gargantext:exe:gargantext-cli"
- path: "./bin/gargantext-cli/CLI/Admin.hs"
component: "gargantext:exe:gargantext-cli"
- path: "./bin/gargantext-cli/CLI/FileDiff.hs"
component: "gargantext:exe:gargantext-cli"
- path: "./bin/gargantext-cli/CLI/FilterTermsAndCooc.hs"
component: "gargantext:exe:gargantext-cli"
- path: "./bin/gargantext-cli/CLI/Import.hs"
component: "gargantext:exe:gargantext-cli"
- path: "./bin/gargantext-cli/CLI/Ini.hs"
component: "gargantext:exe:gargantext-cli"
- path: "./bin/gargantext-cli/CLI/Init.hs"
component: "gargantext:exe:gargantext-cli"
- path: "./bin/gargantext-cli/CLI/Invitations.hs"
component: "gargantext:exe:gargantext-cli"
- path: "./bin/gargantext-cli/CLI/ObfuscateDB.hs"
component: "gargantext:exe:gargantext-cli"
- path: "./bin/gargantext-cli/CLI/Parsers.hs"
component: "gargantext:exe:gargantext-cli"
- path: "./bin/gargantext-cli/CLI/Phylo.hs"
component: "gargantext:exe:gargantext-cli"
- path: "./bin/gargantext-cli/CLI/Phylo/Common.hs"
component: "gargantext:exe:gargantext-cli"
- path: "./bin/gargantext-cli/CLI/Phylo/Profile.hs"
component: "gargantext:exe:gargantext-cli"
- path: "./bin/gargantext-cli/CLI/Server/Routes.hs"
component: "gargantext:exe:gargantext-cli"
- path: "./bin/gargantext-cli/CLI/Types.hs"
component: "gargantext:exe:gargantext-cli"
- path: "./bin/gargantext-cli/CLI/Upgrade.hs"
component: "gargantext:exe:gargantext-cli"
- path: "./bin/gargantext-cli/Paths_gargantext.hs"
component: "gargantext:exe:gargantext-cli"
- path: "./bin/gargantext-server/Main.hs"
component: "gargantext:exe:gargantext-server"
- path: "./bin/gargantext-server/Paths_gargantext.hs"
component: "gargantext:exe:gargantext-server"
- path: "./test"
component: "gargantext:test:garg-test-tasty"
- path: "./bin/gargantext-cli"
component: "gargantext:test:garg-test-tasty"
- path: "./test"
component: "gargantext:test:garg-test-hspec"
- path: "./bench/Main.hs"
component: "gargantext:bench:garg-bench"
- path: "./bench/Paths_gargantext.hs"
component: "gargantext:bench:garg-bench"
......@@ -2,8 +2,8 @@
rec {
inherit pkgs;
ghc947 = if pkgs.stdenv.isDarwin
then pkgs.haskell.compiler.ghc947.overrideAttrs (finalAttrs: previousAttrs: {
ghc948 = if pkgs.stdenv.isDarwin
then pkgs.haskell.compiler.ghc948.overrideAttrs (finalAttrs: previousAttrs: {
patches = previousAttrs.patches ++ [
# Reverts the linking behavior of GHC to not resolve `-libc++` to `c++`.
(pkgs.fetchpatch {
......@@ -12,8 +12,8 @@ rec {
})
];
})
else pkgs.haskell.compiler.ghc947;
cabal_install_3_10_1_0 = pkgs.haskell.lib.compose.justStaticExecutables pkgs.haskell.packages.ghc947.cabal-install;
else pkgs.haskell.compiler.ghc948;
cabal_install_3_10_2_1 = pkgs.haskell.lib.compose.justStaticExecutables pkgs.haskell.packages.ghc948.cabal-install;
graphviz_dev = pkgs.graphviz.overrideAttrs (finalAttrs: previousAttrs: {
version = "11.0.0~dev";
src = pkgs.fetchFromGitLab {
......@@ -95,8 +95,8 @@ rec {
});
hsBuildInputs = [
ghc947
cabal_install_3_10_1_0
ghc948
cabal_install_3_10_2_1
pkgs.haskellPackages.alex
pkgs.haskellPackages.happy
pkgs.haskellPackages.pretty-show
......
......@@ -92,12 +92,13 @@ startGargantext mode port sf@(SettingsFile settingsFile) = withLoggerHoisted mod
where runDbCheck env = do
r <- runExceptT (runReaderT DB.dbCheck env) `catch`
(\(_ :: SomeException) -> pure $ Right False)
(\(err :: SomeException) -> pure $ Left err)
case r of
Right True -> pure ()
_ -> panicTrace $
"You must run 'gargantext-init " <> pack settingsFile <>
Right True -> pure ()
Right False -> panicTrace $
"You must run 'gargantext-cli init " <> pack settingsFile <>
"' before running gargantext-server (only the first time)."
Left err -> panicTrace $ "Unexpected exception:" <> show err
oneHour = Clock.fromNanoSecs 3600_000_000_000
portRouteInfo :: NotificationsConfig -> PortNumber -> MicroServicesProxyStatus -> IO ()
......
......@@ -205,8 +205,8 @@ logDistributional' n m' = trace ("logDistributional'") result
-- m_{i,j} = 0 if n_{i,j} = 0 or i = j,
-- m_{i,j} = log(to * n_{i,j} / s_{i,j}) otherwise.
mi = (.*) (matrixEye n)
(map (lift1 (\x -> let x' = x * to in cond (x' < 0.5) 0 (log x'))) ((./) m ss))
-- (map (lift1 (\x -> let x' = x * to in cond (x' < 1) 0 (log x'))) ((./) m ss))
-- (map (lift1 (\x -> let x' = x * to in cond (x' < 0.5) 0 (log x'))) ((./) m ss))
(map (lift1 (\x -> let x' = x * to in cond (x' < 1) 0 (log x'))) ((./) m ss))
-- mi_nnz :: Int
-- mi_nnz = flip indexArray Z . run $
-- foldAll (+) 0 $ map (\a -> ifThenElse (abs a < 10^(-6 :: Exp Int)) 0 1) mi
......
......@@ -14,9 +14,10 @@ Portability : POSIX
module Gargantext.Core.Viz.Graph.Types
where
import Data.Aeson (defaultOptions)
import Data.HashSet (HashSet)
import Data.HashSet qualified as HashSet
import Data.Swagger (ToSchema(..), genericDeclareNamedSchema)
import Data.Swagger (ToSchema(..), genericDeclareNamedSchema, defaultSchemaOptions)
import Data.Text (pack)
import Database.PostgreSQL.Simple.FromField (FromField(..))
import Gargantext.API.Ngrams.Types (NgramsTerm)
......@@ -245,9 +246,9 @@ instance FromField HyperdataGraphAPI
data GraphLegendAPI = GraphLegendAPI [LegendField]
deriving (Show, Generic)
$(deriveJSON (unPrefix "_graphAPI") ''GraphLegendAPI)
$(deriveJSON defaultOptions ''GraphLegendAPI)
instance ToSchema GraphLegendAPI where
declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "_graphAPI")
declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
makeLenses ''GraphLegendAPI
......
......@@ -2,13 +2,11 @@
"extra-deps":
- "JuicyPixels-3.3.9"
- "KMP-0.2.0.0"
- "MissingH-1.4.3.1"
- "OneTuple-0.4.2"
- "aeson-pretty-0.8.10"
- "alex-3.5.1.0"
- "ansi-terminal-1.0.2"
- "assoc-1.1.1"
- "async-2.2.5"
- "atomic-primops-0.8.8"
- "barbies-2.1.1.0"
- "base-compat-0.13.1"
......@@ -23,7 +21,6 @@
- "cabal-doctest-1.0.10"
- "cassava-0.5.3.2"
- "cassava-conduit-0.6.6"
- "cborg-0.2.10.0"
- "concurrent-output-1.10.21"
- "conduit-1.3.6"
- "criterion-measurement-0.2.2.0"
......@@ -32,7 +29,6 @@
- "crypton-x509-1.7.7"
- "data-fix-0.3.4"
- "dec-0.0.6"
- "deferred-folds-0.9.18.6"
- "digest-0.0.2.1"
- "double-conversion-2.0.5.0"
- "extra-1.7.16"
......@@ -43,7 +39,6 @@
- "foldl-1.4.17"
- "free-5.2"
- "fullstop-0.1.4"
- "graphviz-2999.20.2.0"
- "hashable-1.4.4.0"
- "haskell-src-meta-0.8.14"
- "hedgehog-1.5"
......@@ -56,23 +51,20 @@
- "hspec-expectations-0.8.4"
- "http-accept-0.2"
- "http-api-data-0.5.1"
- "http-client-0.7.14"
- "http-conduit-2.3.8.3"
- "http-types-0.12.4"
- "http2-5.0.1"
- "indexed-traversable-0.1.4"
- "invariant-0.6.3"
- "iproute-1.7.14"
- "jose-0.10.0.1"
- "json-stream-0.4.6.0"
- "kan-extensions-5.2.6"
- "language-c-0.9.3"
- "libyaml-0.1.4"
- "libyaml-clib-0.2.5"
- "lifted-async-0.10.2.5"
- "logict-0.8.1.0"
- "lzma-0.0.1.1"
- "math-functions-0.3.4.4"
- "matrix-0.3.6.3"
- "megaparsec-9.6.1"
- "microlens-th-0.4.3.15"
- "mono-traversable-1.0.17.0"
......@@ -87,7 +79,6 @@
- "morpheus-graphql-subscriptions-0.24.3"
- "mwc-random-0.15.1.0"
- "network-control-0.0.2"
- "old-time-1.1.0.4"
- "ordered-containers-0.2.4"
- "os-string-2.0.6"
- "password-3.0.4.0"
......@@ -96,14 +87,12 @@
- "primitive-extras-0.10.2"
- "primitive-unlifted-2.1.0.0"
- "protolude-0.3.4"
- "psqueues-0.2.8.0"
- "rake-0.0.1"
- "random-1.2.1.2"
- "recover-rtti-0.4.3"
- "reflection-2.1.8"
- "resourcet-1.3.0"
- "safe-0.3.21"
- "serialise-0.2.6.1"
- "servant-0.20.2"
- "servant-auth-0.4.2.0"
- "servant-auth-client-0.4.2.0"
......@@ -147,7 +136,6 @@
- "validity-0.12.1.0"
- "vector-0.12.3.1"
- "vector-algorithms-0.9.0.2"
- "wai-3.2.4"
- "wai-app-static-3.1.9"
- "wai-extra-3.1.15"
- "wai-logger-2.4.1"
......@@ -703,5 +691,5 @@ flags:
standalone: true
packages:
- .
resolver: "lts-21.17"
resolver: "lts-21.25"
"system-ghc": true
......@@ -58,5 +58,6 @@
},
"hash": ""
}
]
],
"garg_version": "0.0.7.1.16"
}
{ "NgramsTerms":{ "version":1 ,"data":{ "fortran":{"size":2,"list":"MapTerm","children":[]} } }
}
......@@ -8,24 +8,31 @@ module Test.API.Routes where
import Data.Text.Encoding qualified as TE
import Fmt (Builder, (+|), (|+))
import Gargantext.API.Admin.Auth.Types (AuthRequest, AuthResponse, Token)
import Gargantext.API.Admin.Orchestrator.Types (JobLog, asyncJobsAPI')
import Gargantext.API.Errors
import Gargantext.API.HashedResponse (HashedResponse)
import Gargantext.API.Ngrams.Types ( NgramsTable, NgramsTablePatch, OrderBy, TabType, Versioned, VersionedWithCount )
import Gargantext.API.Routes.Named
import Gargantext.API.Routes.Named.Node
import Gargantext.API.Routes.Named.Private hiding (tableNgramsAPI)
import Gargantext.API.Routes.Named.Table
import Gargantext.API.Types () -- MimeUnrender instances
import Gargantext.Core.Types (ListId, NodeId)
import Gargantext.Core.Text.Corpus.Query (RawQuery)
import Gargantext.Core.Types (ListId, NodeId, NodeType, NodeTableResult)
import Gargantext.Core.Types.Main (ListType)
import Gargantext.Core.Types.Query (Limit, MaxSize, MinSize, Offset)
import Gargantext.Database.Admin.Types.Hyperdata
import Gargantext.Database.Query.Facet qualified as Facet
import Gargantext.Prelude
import Network.HTTP.Types qualified as H
import Network.Wai.Handler.Warp (Port)
import Servant ((:<|>)(..))
import Servant.API.WebSocket qualified as WS
import Servant.Auth.Client qualified as S
import Servant.Client (ClientM)
import Servant.Client.Core (RunClient, HasClient(..), Request)
import Servant.Client.Generic ( genericClient, AsClientT )
import Servant.Job.Async
instance RunClient m => HasClient m WS.WebSocketPending where
......@@ -47,6 +54,9 @@ mkUrl :: Port -> Builder -> ByteString
mkUrl _port urlPiece =
"/api/" +| curApi |+ urlPiece
gqlUrl :: ByteString
gqlUrl = "/gql"
-- | The client for the full API. It also serves as a \"proof\" that our
-- whole API has all the required instances to be used in a client.
......@@ -64,19 +74,44 @@ auth_api = clientRoutes & apiWithCustomErrorScheme
& gargAuthAPI
& authEp
table_ngrams_get_api :: Token
-> NodeId
-> TabType
-> ListId
-> Limit
-> Maybe Offset
-> Maybe ListType
-> Maybe MinSize
-> Maybe MaxSize
-> Maybe OrderBy
-> Maybe Text
-> ClientM (VersionedWithCount NgramsTable)
table_ngrams_get_api (toServantToken -> token) nodeId =
toServantToken :: Token -> S.Token
toServantToken = S.Token . TE.encodeUtf8
update_node :: Token
-> NodeId
-> UpdateNodeParams
-> ClientM (JobStatus 'Safe JobLog)
update_node (toServantToken -> token) nodeId params =
clientRoutes & apiWithCustomErrorScheme
& ($ GES_new)
& backendAPI
& backendAPI'
& mkBackEndAPI
& gargAPIVersion
& gargPrivateAPI
& mkPrivateAPI
& ($ token)
& nodeEp
& nodeEndpointAPI
& ($ nodeId)
& updateAPI
& updateNodeEp
& asyncJobsAPI'
& (\(_ :<|> submitForm :<|> _) -> submitForm (JobInput params Nothing))
get_table_ngrams :: Token
-> NodeId
-> TabType
-> ListId
-> Limit
-> Maybe Offset
-> Maybe ListType
-> Maybe MinSize
-> Maybe MaxSize
-> Maybe OrderBy
-> Maybe Text
-> ClientM (VersionedWithCount NgramsTable)
get_table_ngrams (toServantToken -> token) nodeId =
clientRoutes & apiWithCustomErrorScheme
& ($ GES_new)
& backendAPI
......@@ -93,16 +128,13 @@ table_ngrams_get_api (toServantToken -> token) nodeId =
& tableNgramsGetAPI
& getNgramsTableEp
toServantToken :: Token -> S.Token
toServantToken = S.Token . TE.encodeUtf8
table_ngrams_put_api :: Token
-> NodeId
-> TabType
-> ListId
-> Versioned NgramsTablePatch
-> ClientM (Versioned NgramsTablePatch)
table_ngrams_put_api (toServantToken -> token) nodeId =
put_table_ngrams :: Token
-> NodeId
-> TabType
-> ListId
-> Versioned NgramsTablePatch
-> ClientM (Versioned NgramsTablePatch)
put_table_ngrams (toServantToken -> token) nodeId =
clientRoutes & apiWithCustomErrorScheme
& ($ GES_new)
& backendAPI
......@@ -118,3 +150,51 @@ table_ngrams_put_api (toServantToken -> token) nodeId =
& tableNgramsAPI
& tableNgramsPutAPI
& putNgramsTableEp
get_table :: Token
-> NodeId
-> Maybe TabType
-> Maybe Limit
-> Maybe Offset
-> Maybe Facet.OrderBy
-> Maybe RawQuery
-> Maybe Text
-> ClientM (HashedResponse FacetTableResult)
get_table (toServantToken -> token) nodeId =
clientRoutes & apiWithCustomErrorScheme
& ($ GES_new)
& backendAPI
& backendAPI'
& mkBackEndAPI
& gargAPIVersion
& gargPrivateAPI
& mkPrivateAPI
& ($ token)
& nodeEp
& nodeEndpointAPI
& ($ nodeId)
& tableAPI
& getTableEp
get_children :: Token
-> NodeId
-> Maybe NodeType
-> Maybe Offset
-> Maybe Limit
-> ClientM (NodeTableResult HyperdataAny)
get_children (toServantToken -> token) nodeId =
clientRoutes & apiWithCustomErrorScheme
& ($ GES_new)
& backendAPI
& backendAPI'
& mkBackEndAPI
& gargAPIVersion
& gargPrivateAPI
& mkPrivateAPI
& ($ token)
& nodeEp
& nodeEndpointAPI
& ($ nodeId)
& childrenAPI
& summaryChildrenEp
This diff is collapsed.
......@@ -7,33 +7,38 @@ module Test.Utils where
import Control.Exception.Safe ()
import Control.Monad ()
import Data.Aeson qualified as JSON
import Data.Aeson.KeyMap qualified as KM
import Data.Aeson qualified as JSON
import Data.ByteString.Char8 qualified as B
import Data.ByteString.Lazy qualified as L
import Data.Map.Strict qualified as Map
import Data.Text qualified as T
import Data.Text.Encoding qualified as TE
import Data.Text.Lazy qualified as TL
import Data.Text.Lazy.Encoding qualified as TLE
import Data.Text.Lazy qualified as TL
import Data.Text qualified as T
import Data.TreeDiff
import Fmt (Builder)
import Gargantext.API.Routes.Types (xGargErrorScheme)
import Gargantext.API.Admin.Auth.Types (AuthRequest(..), Token, authRes_token)
import Gargantext.API.Admin.Orchestrator.Types
import Gargantext.API.Routes.Types (xGargErrorScheme)
import Gargantext.Core.Types.Individu (Username, GargPassword)
import Gargantext.Prelude
import Network.HTTP.Client (defaultManagerSettings, newManager)
import Network.HTTP.Types (Header, Method, status200)
import Network.HTTP.Client qualified as HTTP
import Network.HTTP.Types.Header (hAccept, hAuthorization, hContentType)
import Network.HTTP.Types (Header, Method, status200)
import Network.Wai.Handler.Warp (Port)
import Network.Wai.Test (SResponse(..))
import Prelude qualified
import Servant.Client (ClientEnv, baseUrlPort, mkClientEnv, parseBaseUrl, runClientM)
import Servant.Client (ClientEnv, baseUrlPort, mkClientEnv, parseBaseUrl, runClientM, makeClientRequest, defaultMakeClientRequest)
import Servant.Client.Core (BaseUrl)
import Servant.Client.Core.Request qualified as Client
import System.Environment (lookupEnv)
import System.Timeout qualified as Timeout
import Test.API.Routes (auth_api, mkUrl)
import Test.Hspec.Expectations
import Test.Hspec.Wai (MatchBody(..), WaiExpectation, WaiSession, request)
import Test.Hspec.Wai.JSON (FromValue(..))
import Test.Hspec.Wai (MatchBody(..), WaiExpectation, WaiSession, request)
import Test.Hspec.Wai.Matcher (MatchHeader(..), ResponseMatcher(..), bodyEquals, formatHeader, match)
import Test.Tasty.HUnit (Assertion, assertBool)
import Test.Types
......@@ -183,12 +188,27 @@ withValidLogin port ur pwd act = do
case result of
Left err -> liftIO $ throwIO $ Prelude.userError (show err)
Right res -> do
traceEnabled <- isJust <$> liftIO (lookupEnv "GARG_DEBUG_LOGS")
let token = res ^. authRes_token
act clientEnv0 token
act (clientEnv0 { makeClientRequest = gargMkRequest traceEnabled }) token
-- | Allows to enable/disable logging of the input 'Request' to check what the
-- client is actually sending to the server.
-- FIXME(adn) We cannot upgrade to servant-client 0.20 due to OpenAlex:
-- https://gitlab.iscpif.fr/gargantext/crawlers/openalex/blob/main/src/OpenAlex/ServantClientLogging.hs#L24
gargMkRequest :: Bool -> BaseUrl -> Client.Request -> HTTP.Request
gargMkRequest traceEnabled bu clientRq =
let httpReq = defaultMakeClientRequest bu clientRq
in case traceEnabled of
True ->
traceShowId httpReq
False -> httpReq
-- | Poll the given job URL every second until it finishes.
-- Retries up to 60 times (i.e. for 1 minute, before giving up)
-- /NOTE(adn)/: Check the content of the \"events\" logs as a stopgap
-- measure for #390.
pollUntilFinished :: HasCallStack
=> Token
-> Port
......@@ -208,7 +228,15 @@ pollUntilFinished tkn port mkUrlPiece = go 60
| _jph_status h == "IsFailure"
-> panicTrace $ "JobPollHandle contains a failure: " <> TE.decodeUtf8 (L.toStrict $ JSON.encode h)
| otherwise
-> pure h
-> case any hasError (_jph_log h) of
True -> panicTrace $ "JobPollHandle contains a failure: " <> TE.decodeUtf8 (L.toStrict $ JSON.encode h)
False -> pure h
-- FIXME(adn) This is wrong, errs should be >= 1.
hasError :: JobLog -> Bool
hasError JobLog{..} = case _scst_failed of
Nothing -> False
Just errs -> errs > 1
-- | Like HUnit's '@?=', but With a nicer error message in case the two entities are not equal.
(@??=) :: (HasCallStack, ToExpr a, Eq a) => a -> a -> Assertion
......
......@@ -363,23 +363,30 @@ testMarkProgress = do
myEnv <- newTestEnv
-- evts <- newTBQueueIO 7
evts <- newTVarIO []
let expectedEvents = 7
let getStatus hdl = do
liftIO $ threadDelay 100_000
st <- getLatestJobStatus hdl
-- liftIO $ atomically $ writeTBQueue evts st
liftIO $ atomically $ modifyTVar evts (\xs -> xs ++ [st])
readAllEvents = do
readAllEvents = do
-- We will get thread blocking if there is ANY error in the job
-- Hence we assert the `readAllEvents` test doesn't take too long
mRet <- timeout 1_000_000 $ atomically $ do
mRet <- timeout 5_000_000 $ atomically $ do
-- allEventsArrived <- isFullTBQueue evts
evts' <- readTVar evts
-- STM retry if things failed
-- check allEventsArrived
check (length evts' == 7)
check (length evts' == expectedEvents)
-- flushTBQueue evts
return evts'
return $ fromMaybe [] mRet
pure evts'
case mRet of
Nothing -> Prelude.fail $ "testMarkProgress: timeout exceeded, but didn't receive all 7 required events."
Just xs
| length xs == expectedEvents
-> pure xs
| otherwise
-> Prelude.fail $ "testMarkProgress: received some events, but they were not of the expected number (" <> show expectedEvents <> "): " <> show xs
withJob_ myEnv $ \hdl _input -> do
markStarted 10 hdl
......@@ -406,6 +413,8 @@ testMarkProgress = do
getStatus hdl
evts' <- readAllEvents
-- This pattern match should never fail, because the precondition is
-- checked in 'readAllEvents'.
let [jl0, jl1, jl2, jl3, jl4, jl5, jl6] = evts'
-- Check the events are what we expect
......@@ -468,7 +477,7 @@ test = do
testExceptions
it "fairly picks equal-priority-but-different-kind jobs" $
testFairness
describe "job status update and tracking" $ do
describe "job status update and tracking" $ sequential $ do
it "can fetch the latest job status" $
testFetchJobStatus
it "can spin two separate jobs and track their status separately" $
......
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