Commit a70d4704 authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

Merge branch '86-gitlab-ci-correctly-handle-warning-and-note-in-checks' into 'dev'

Resolve "Gitlab-CI: correctly handle WARNING and NOTE in checks"

Closes #86 and #108

See merge request HYCAR-Hydro/airgr!39
Showing with 51 additions and 86 deletions
+51 -86
...@@ -8,3 +8,4 @@ ...@@ -8,3 +8,4 @@
^\.gitlab-ci\.yml$ ^\.gitlab-ci\.yml$
^\.vscode$ ^\.vscode$
^Rplots\.pdf$ ^Rplots\.pdf$
^ci$
stages: stages:
- update_packages - check
- build
- regression - regression
- tests - revdepcheck
default: default:
before_script: before_script:
- echo "setwd(\"$(pwd)\")" > .Rprofile - echo "setwd(\"$(pwd)\")" > .Rprofile
- echo ".libPaths <- c(Sys.getenv(\"R_LIBS_USER\"), .libPaths())" >> .Rprofile
- PATH=~/R/sources/R-${R_VERSION}/bin:$PATH - PATH=~/R/sources/R-${R_VERSION}/bin:$PATH
- rename "s/${R_VERSION}.airGR/airGR/" *.tar.gz - R -e 'remotes::install_deps(dep = T)'
- R -e 'chooseCRANmirror(graphics = FALSE, ind = 1); pkg <- "caRamel"; pkgInst <- installed.packages()[, "Package"]; pkgMiss <- setdiff(pkg, pkgInst); if (length(pkgMiss) > 0) install.packages(pkgMiss)'
.update_packages:
stage: update_packages
only:
refs:
- tags
- schedules
script:
- Rscript -e "update.packages(ask=FALSE, repos=\"http://cran.r-project.org\")"
.build:
stage: build
script:
- cd ..
- echo "setwd(\"$(pwd)\")" > .Rprofile
- R CMD build airgr
- rename "s/airGR/${R_VERSION}.airGR/" airGR_*.tar.gz
- mv *.tar.gz airgr/
artifacts:
untracked: true
expire_in: 1 week
.regression: .regression:
stage: regression stage: regression
...@@ -40,27 +18,20 @@ default: ...@@ -40,27 +18,20 @@ default:
- Rscript tests/testthat/regression_tests.R dev - Rscript tests/testthat/regression_tests.R dev
- Rscript tests/testthat/regression_tests.R compare - Rscript tests/testthat/regression_tests.R compare
.check:
stage: check
script:
- R -e ' rcmdcheck::rcmdcheck(args = ifelse(as.logical(Sys.getenv("NOT_CRAN")), "", "--as-cran"), error_on = "warning")'
.check_not_cran: .check_not_cran:
stage: tests
variables: variables:
NOT_CRAN: "true" NOT_CRAN: "true"
script: extends: .check
- R CMD check airGR_*.tar.gz
.check_as_cran: .check_as_cran:
stage: tests
script:
- R CMD check --as-cran airGR_*.tar.gz
update_packages_patched:
variables: variables:
R_VERSION: "patched" NOT_CRAN: "false"
extends: .update_packages extends: .check
build_patched:
variables:
R_VERSION: "patched"
extends: .build
regression_patched: regression_patched:
variables: variables:
...@@ -93,20 +64,6 @@ check_as_cran_patched: ...@@ -93,20 +64,6 @@ check_as_cran_patched:
R_VERSION: "patched" R_VERSION: "patched"
extends: .check_as_cran extends: .check_as_cran
update_packages_devel:
variables:
R_VERSION: "devel"
extends: .update_packages
build_devel:
only:
refs:
- tags
- schedules
variables:
R_VERSION: "devel"
extends: .build
check_not_cran_devel: check_not_cran_devel:
only: only:
refs: refs:
...@@ -125,35 +82,39 @@ check_as_cran_devel: ...@@ -125,35 +82,39 @@ check_as_cran_devel:
R_VERSION: "devel" R_VERSION: "devel"
extends: .check_as_cran extends: .check_as_cran
update_packages_oldrel: check_not_cran_oldrel:
variables:
R_VERSION: "oldrel"
extends: .update_packages
build_oldrel:
only: only:
refs: refs:
- tags - tags
- schedules - schedules
variables: variables:
R_VERSION: "oldrel" R_VERSION: "oldrel"
extends: .build extends: .check_not_cran
check_not_cran_oldrel: check_as_cran_oldrel:
only: only:
refs: refs:
- tags - tags
- schedules - schedules
variables: variables:
R_VERSION: "oldrel" R_VERSION: "oldrel"
extends: .check_not_cran extends: .check_as_cran
check_as_cran_oldrel: revdepcheck_patched:
stage: revdepcheck
only: only:
refs: refs:
- tags - tags
- schedules - schedules
variables: variables:
R_VERSION: "oldrel" R_VERSION: "patched"
extends: .check_as_cran script:
- R -e 'remotes::install_github("https://github.com/r-lib/revdepcheck")'
- R -e 'revdepcheck::revdep_check(num_workers = 2)'
- R -e 'if (any(sapply(revdepcheck::revdep_summary(), function(x) {any(x$cmp$change == 1)}))) stop()'
artifacts:
paths:
- revdep/README.md
- revdep/problems.md
- revdep/failures.md
- revdep/cran.md
Calibration <- function(InputsModel, Calibration <- function(InputsModel,
RunOptions, RunOptions,
InputsCrit, InputsCrit,
CalibOptions, CalibOptions,
FUN_MOD, FUN_MOD,
FUN_CRIT, # deprecated FUN_CRIT, # deprecated
FUN_CALIB = Calibration_Michel, FUN_CALIB = Calibration_Michel,
FUN_TRANSFO = NULL, FUN_TRANSFO = NULL,
verbose = TRUE) { verbose = TRUE,
...) {
FUN_MOD <- match.fun(FUN_MOD) FUN_MOD <- match.fun(FUN_MOD)
if (!missing(FUN_CRIT)) { if (!missing(FUN_CRIT)) {
FUN_CRIT <- match.fun(FUN_CRIT) FUN_CRIT <- match.fun(FUN_CRIT)
...@@ -16,10 +17,10 @@ Calibration <- function(InputsModel, ...@@ -16,10 +17,10 @@ Calibration <- function(InputsModel,
if (!is.null(FUN_TRANSFO)) { if (!is.null(FUN_TRANSFO)) {
FUN_TRANSFO <- match.fun(FUN_TRANSFO) FUN_TRANSFO <- match.fun(FUN_TRANSFO)
} }
return(FUN_CALIB(InputsModel = InputsModel, RunOptions = RunOptions, InputsCrit = InputsCrit, return(FUN_CALIB(InputsModel = InputsModel, RunOptions = RunOptions, InputsCrit = InputsCrit,
CalibOptions = CalibOptions, CalibOptions = CalibOptions,
FUN_MOD = FUN_MOD, FUN_TRANSFO = FUN_TRANSFO, FUN_MOD = FUN_MOD, FUN_TRANSFO = FUN_TRANSFO,
verbose = verbose)) verbose = verbose, ...))
} }
...@@ -16,7 +16,7 @@ Calibration algorithm that optimises the error criterion selected as objective f ...@@ -16,7 +16,7 @@ Calibration algorithm that optimises the error criterion selected as objective f
\usage{ \usage{
Calibration(InputsModel, RunOptions, InputsCrit, CalibOptions, Calibration(InputsModel, RunOptions, InputsCrit, CalibOptions,
FUN_MOD, FUN_CRIT, FUN_CALIB = Calibration_Michel, FUN_MOD, FUN_CRIT, FUN_CALIB = Calibration_Michel,
FUN_TRANSFO = NULL, verbose = TRUE) FUN_TRANSFO = NULL, verbose = TRUE, ...)
} }
...@@ -38,6 +38,8 @@ Calibration(InputsModel, RunOptions, InputsCrit, CalibOptions, ...@@ -38,6 +38,8 @@ Calibration(InputsModel, RunOptions, InputsCrit, CalibOptions,
\item{FUN_TRANSFO}{(optional) [function] model parameters transformation function, if the \code{FUN_MOD} used is native in the package \code{FUN_TRANSFO} is automatically defined} \item{FUN_TRANSFO}{(optional) [function] model parameters transformation function, if the \code{FUN_MOD} used is native in the package \code{FUN_TRANSFO} is automatically defined}
\item{verbose}{(optional) [boolean] boolean indicating if the function is run in verbose mode or not, default = \code{TRUE}} \item{verbose}{(optional) [boolean] boolean indicating if the function is run in verbose mode or not, default = \code{TRUE}}
\item{...}{Further arguments to pass to \code{\link{RunModel}}}
} }
...@@ -53,11 +55,11 @@ library(airGR) ...@@ -53,11 +55,11 @@ library(airGR)
data(L0123001) data(L0123001)
## preparation of InputsModel object ## preparation of InputsModel object
InputsModel <- CreateInputsModel(FUN_MOD = RunModel_GR4J, DatesR = BasinObs$DatesR, InputsModel <- CreateInputsModel(FUN_MOD = RunModel_GR4J, DatesR = BasinObs$DatesR,
Precip = BasinObs$P, PotEvap = BasinObs$E) Precip = BasinObs$P, PotEvap = BasinObs$E)
## calibration period selection ## calibration period selection
Ind_Run <- seq(which(format(BasinObs$DatesR, format = "\%Y-\%m-\%d")=="1990-01-01"), Ind_Run <- seq(which(format(BasinObs$DatesR, format = "\%Y-\%m-\%d")=="1990-01-01"),
which(format(BasinObs$DatesR, format = "\%Y-\%m-\%d")=="1999-12-31")) which(format(BasinObs$DatesR, format = "\%Y-\%m-\%d")=="1999-12-31"))
## preparation of RunOptions object ## preparation of RunOptions object
...@@ -65,7 +67,7 @@ RunOptions <- CreateRunOptions(FUN_MOD = RunModel_GR4J, ...@@ -65,7 +67,7 @@ RunOptions <- CreateRunOptions(FUN_MOD = RunModel_GR4J,
InputsModel = InputsModel, IndPeriod_Run = Ind_Run) InputsModel = InputsModel, IndPeriod_Run = Ind_Run)
## calibration criterion: preparation of the InputsCrit object ## calibration criterion: preparation of the InputsCrit object
InputsCrit <- CreateInputsCrit(FUN_CRIT = ErrorCrit_NSE, InputsModel = InputsModel, InputsCrit <- CreateInputsCrit(FUN_CRIT = ErrorCrit_NSE, InputsModel = InputsModel,
RunOptions = RunOptions, Obs = BasinObs$Qmm[Ind_Run]) RunOptions = RunOptions, Obs = BasinObs$Qmm[Ind_Run])
## preparation of CalibOptions object ## preparation of CalibOptions object
...@@ -74,24 +76,24 @@ CalibOptions <- CreateCalibOptions(FUN_MOD = RunModel_GR4J, FUN_CALIB = Calibrat ...@@ -74,24 +76,24 @@ CalibOptions <- CreateCalibOptions(FUN_MOD = RunModel_GR4J, FUN_CALIB = Calibrat
## calibration ## calibration
OutputsCalib <- Calibration(InputsModel = InputsModel, RunOptions = RunOptions, OutputsCalib <- Calibration(InputsModel = InputsModel, RunOptions = RunOptions,
InputsCrit = InputsCrit, CalibOptions = CalibOptions, InputsCrit = InputsCrit, CalibOptions = CalibOptions,
FUN_MOD = RunModel_GR4J, FUN_MOD = RunModel_GR4J,
FUN_CALIB = Calibration_Michel) FUN_CALIB = Calibration_Michel)
## simulation ## simulation
Param <- OutputsCalib$ParamFinalR Param <- OutputsCalib$ParamFinalR
OutputsModel <- RunModel(InputsModel = InputsModel, RunOptions = RunOptions, OutputsModel <- RunModel(InputsModel = InputsModel, RunOptions = RunOptions,
Param = Param, FUN = RunModel_GR4J) Param = Param, FUN = RunModel_GR4J)
## results preview ## results preview
plot(OutputsModel, Qobs = BasinObs$Qmm[Ind_Run]) plot(OutputsModel, Qobs = BasinObs$Qmm[Ind_Run])
## efficiency criterion: Nash-Sutcliffe Efficiency ## efficiency criterion: Nash-Sutcliffe Efficiency
InputsCrit <- CreateInputsCrit(FUN_CRIT = ErrorCrit_NSE, InputsModel = InputsModel, InputsCrit <- CreateInputsCrit(FUN_CRIT = ErrorCrit_NSE, InputsModel = InputsModel,
RunOptions = RunOptions, Obs = BasinObs$Qmm[Ind_Run]) RunOptions = RunOptions, Obs = BasinObs$Qmm[Ind_Run])
OutputsCrit <- ErrorCrit_NSE(InputsCrit = InputsCrit, OutputsModel = OutputsModel) OutputsCrit <- ErrorCrit_NSE(InputsCrit = InputsCrit, OutputsModel = OutputsModel)
## efficiency criterion: Kling-Gupta Efficiency ## efficiency criterion: Kling-Gupta Efficiency
InputsCrit <- CreateInputsCrit(FUN_CRIT = ErrorCrit_KGE, InputsModel = InputsModel, InputsCrit <- CreateInputsCrit(FUN_CRIT = ErrorCrit_KGE, InputsModel = InputsModel,
RunOptions = RunOptions, Obs = BasinObs$Qmm[Ind_Run]) RunOptions = RunOptions, Obs = BasinObs$Qmm[Ind_Run])
OutputsCrit <- ErrorCrit_KGE(InputsCrit = InputsCrit, OutputsModel = OutputsModel) OutputsCrit <- ErrorCrit_KGE(InputsCrit = InputsCrit, OutputsModel = OutputsModel)
} }
...@@ -105,7 +107,7 @@ Laurent Coron, Olivier Delaigue ...@@ -105,7 +107,7 @@ Laurent Coron, Olivier Delaigue
\seealso{ \seealso{
\code{\link{Calibration_Michel}}, \code{\link{Calibration_Michel}},
\code{\link{ErrorCrit}}, \code{\link{TransfoParam}}, \code{\link{ErrorCrit}}, \code{\link{TransfoParam}},
\code{\link{CreateInputsModel}}, \code{\link{CreateRunOptions}}, \code{\link{CreateInputsModel}}, \code{\link{CreateRunOptions}},
\code{\link{CreateInputsCrit}}, \code{\link{CreateCalibOptions}}. \code{\link{CreateInputsCrit}}, \code{\link{CreateCalibOptions}}.
} }
Supports Markdown
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