Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
27a9f5f
♻️ Improve get_result()
ThierryO Feb 4, 2025
bd47ee1
✅ Update unit tests to changes in get_result()
ThierryO Feb 4, 2025
943f650
🔖 Bump package version
ThierryO Feb 4, 2025
279bfbb
♻️ Add write_s3_fun()
ThierryO Feb 5, 2025
9208378
🥅 Read_manifest() validates fingerprint
ThierryO Feb 5, 2025
aa9b75a
✨ Allow to overwrite existing manifests
ThierryO Feb 5, 2025
b634f1d
🐛 N2k_manifest() get a stable fingerprint
ThierryO Feb 6, 2025
d31902f
✨ Get_result() gains a methode for n2kManifest
ThierryO Mar 7, 2025
828dfe3
🐛 Indirect fit on inla ignore compute settings
ThierryO Mar 7, 2025
3ede963
🚨 Fix indentation linter
ThierryO Apr 1, 2025
ca38402
📝 Update README
ThierryO Apr 1, 2025
3462507
👷 Use lateste checklist GHA
ThierryO Apr 1, 2025
d0809ed
🎨 Apply air format .
ThierryO Sep 18, 2025
9fff811
📝 Update citation
ThierryO Sep 18, 2025
c1ecd5e
✨ Add connect_inbo_s3()
ThierryO Sep 29, 2025
b48b8f0
👷 Use AWS role
ThierryO Oct 2, 2025
af3535e
👷 Use devel version of checklist
ThierryO Dec 19, 2025
049622a
💚 Update checklist settings
ThierryO Feb 6, 2026
1bcb7ba
✅ Fix tests using S3
ThierryO Feb 6, 2026
97bd71d
💚 Install missing dependency
ThierryO Feb 6, 2026
5e0a543
🐛 Fix connect_inbo_s3() on windows
ThierryO Feb 12, 2026
2a63152
👷 Use checklist main version
ThierryO Apr 8, 2026
dfa4314
📝 Update NEWS
ThierryO Apr 8, 2026
553863a
💚 Fix build on main
ThierryO Apr 8, 2026
069db7a
✅ Skip tests with S3 bucket on R-universe
ThierryO Apr 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
^CITATION\.cff$
^LICENSE.md$
^README\.Rmd$
^[.]?air[.]toml$
^\.Rproj\.user$
^\.git$
^\.github$
^\.httr-oauth$
^\.lintr$
^\.vscode$
^\.zenodo\.json$
^_pkgdown.yml$
^checklist.yml$
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/check_on_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ jobs:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
N2KBUCKET: ${{ secrets.N2KBUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
permissions:
id-token: write
contents: read
steps:
- uses: inbo/actions/check_pkg@checklist-0.4.1
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::347082780157:role/inbo-n2kmonitoring-shared-infra-eu-west-1-unittest-role
aws-region: eu-west-1
- uses: inbo/actions/check_pkg@main
26 changes: 23 additions & 3 deletions .github/workflows/check_on_different_r_os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ jobs:
_R_CHECK_SYSTEM_CLOCK_: false
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
N2KBUCKET: ${{ secrets.N2KBUCKET }}

permissions:
id-token: write
contents: read

steps:
- uses: actions/checkout@v3

Expand All @@ -45,11 +46,30 @@ jobs:

- uses: r-lib/actions/setup-pandoc@v2

- name: linux dependencies
if: runner.os == 'linux'
run: |
cd /tmp
wget http://ftp.gnu.org/gnu/glibc/glibc-2.38.tar.gz
tar -xzf glibc-2.38.tar.gz
mkdir glibc-build
cd glibc-build
../glibc-2.38/configure --prefix=/usr/local/glibc-2.38
make -j$(nproc)
sudo make install
ldd --version

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::347082780157:role/inbo-n2kmonitoring-shared-infra-eu-west-1-unittest-role
aws-region: eu-west-1

- uses: r-lib/actions/check-r-package@v2
with:
error-on: '"error"'
13 changes: 9 additions & 4 deletions .github/workflows/check_on_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ jobs:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
N2KBUCKET: ${{ secrets.N2KBUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
permissions:
id-token: write
contents: write
steps:
- uses: inbo/actions/check_pkg@checklist-0.4.1
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::347082780157:role/inbo-n2kmonitoring-shared-infra-eu-west-1-unittest-role
aws-region: eu-west-1
- uses: inbo/actions/check_pkg@main
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"Posit.air-vscode"
]
}
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"[r]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "Posit.air-vscode"
},
"[quarto]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "quarto.quarto"
}
}
2 changes: 1 addition & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "n2kanalysis: Generic Functions to Analyse Data from the 'Natura 2000' Monitoring",
"version": "0.4.0",
"version": "0.4.1",
"license": "GPL-3.0",
"upload_type": "software",
"description": "<p>All generic functions and classes for the analysis for the ‘Natura 2000’ monitoring. The classes contain all required data and definitions to fit the model without the need to access other sources. Potentially they might need access to one or more parent objects. An aggregation object might for example need the result of an imputation object. The actual definition of the analysis, using these generic function and classes, is defined in dedictated analysis R packages for every monitoring scheme. For example ‘abvanalysis’ and ‘watervogelanalysis’.<\/p>",
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ identifiers:
value: 10.5281/zenodo.3576047
- type: url
value: https://inbo.github.io/n2kanalysis/
version: 0.4.0
version: 0.4.1
9 changes: 6 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Package: n2kanalysis
Title: Generic Functions to Analyse Data from the 'Natura 2000' Monitoring
Version: 0.4.0
Version: 0.4.1
Authors@R: c(
person("Thierry", "Onkelinx", , "thierry.onkelinx@inbo.be", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-8804-4216", affiliation = "Research Institute for Nature and Forest (INBO)")),
person("Research Institute for Nature and Forest (INBO)", , , "info@inbo.be", role = c("cph", "fnd"))
person("Research Institute for Nature and Forest (INBO)", , , "info@inbo.be", role = c("cph", "fnd"),
comment = c(ROR = "00j54wy13"))
)
Description: All generic functions and classes for the analysis for the
'Natura 2000' monitoring. The classes contain all required data and
Expand Down Expand Up @@ -62,7 +63,7 @@ Config/checklist/keywords: analysis, reproducible research, natura 2000,
Encoding: UTF-8
Language: en-GB
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
Collate:
'n2k_parameter_class.R'
'n2k_anomaly_class.R'
Expand All @@ -72,6 +73,7 @@ Collate:
'n2k_analysis_metadata_class.R'
'n2k_result_class.R'
'combine_result.R'
'connect_inbo_s3.R'
'import_s3_classes.R'
'delete_model.R'
'display.R'
Expand Down Expand Up @@ -169,3 +171,4 @@ Collate:
'store_model.R'
'union.R'
'valid_object.R'
'write_s3_fun.R'
4 changes: 3 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
S3method(sha1,aggregatedImputed)
S3method(sha1,inla)
S3method(sha1,rawImputed)
export(connect_inbo_s3)
export(display)
export(fit_every_model)
export(get_datafield_id)
Expand All @@ -13,7 +14,7 @@ export(moving_average)
export(moving_difference)
export(moving_trend)
export(order_manifest)
export(select_factor_count_strictly_positive)
export(select_factor_count_non_zero)
export(select_factor_threshold)
export(select_observed_range)
export(sha1)
Expand Down Expand Up @@ -143,6 +144,7 @@ importFrom(fs,file_delete)
importFrom(fs,file_exists)
importFrom(fs,path)
importFrom(fs,path_abs)
importFrom(fs,path_home)
importFrom(git2rdata,is_git2rmeta)
importFrom(git2rdata,update_metadata)
importFrom(git2rdata,verify_vc)
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# `n2kanalysis` 0.4.1

* Improve `get_result()`.
* Add `connect_inbo_s3()` function to make the temporary credentials available
to the R functions.
* Improve automated tests.
* Update code style with `air`.

# `n2kanalysis` 0.4.0

* Handle INLA models with an SPDE element.
Expand Down
13 changes: 9 additions & 4 deletions R/combine.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,19 @@ setMethod(
))
r_package <- r_package[order(r_package$description, r_package$version), ]
analysis_version_r_package <- lapply(
dots, slot, "AnalysisVersionRPackage"
dots,
slot,
"AnalysisVersionRPackage"
) %>%
bind_rows() %>%
distinct()
analysis_version_r_package <- analysis_version_r_package %>%
arrange(.data$analysis_version, .data$r_package)
new(
"n2kAnalysisVersion", AnalysisVersion = analysis_version,
RPackage = r_package, AnalysisVersionRPackage = analysis_version_r_package
"n2kAnalysisVersion",
AnalysisVersion = analysis_version,
RPackage = r_package,
AnalysisVersionRPackage = analysis_version_r_package
)
}
)
Expand All @@ -75,7 +79,8 @@ setMethod(
bind_rows() %>%
distinct()
new(
"n2kParameter", Parameter = parameter,
"n2kParameter",
Parameter = parameter,
ParameterEstimate = parameter_estimate
)
}
Expand Down
4 changes: 3 additions & 1 deletion R/combine_result.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ setMethod(
arrange(.data$fingerprint)

analysis_version_r_package <- lapply(
dots, slot, name = "AnalysisVersionRPackage"
dots,
slot,
name = "AnalysisVersionRPackage"
) %>%
do.call(what = rbind) %>%
distinct() %>%
Expand Down
36 changes: 36 additions & 0 deletions R/connect_inbo_s3.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#' Set environment variables for INBO S3 bucket
#'
#' Before running this function you must have an `.aws` folder in your home
#' directory with a `credentials` file containing the credentials for the INBO
#' shared infrastructure.
#' Run the `aws assume role` command to get the credentials for the INBO shared
#' infrastructure before running this function.
#'
#' @export
#' @importFrom fs dir_exists path path_home
#' @importFrom stats setNames
#' @importFrom utils head tail
connect_inbo_s3 <- function() {
aws_dir <- path_home(".aws")
stopifnot("no `.aws` folder found" = dir_exists(aws_dir))
# Read the credentials file
path(aws_dir, "credentials") |>
readLines() -> creds
# keep credentials related to the role
role <- grep("\\[inbo-shared-infra", creds)
stopifnot("no role found" = length(role) == 1)
tail(creds, -role) -> creds
grep("\\[", creds) |>
c(length(creds) + 1) |>
min() -> other
head(creds, other - 1) -> creds
# set environment variables
gsub("(.*) = (.*)", "\\1", creds) |>
toupper() |>
setNames(object = creds) |>
gsub(pattern = "(.*) = (.*)", replacement = "\\2", x = _) |>
c(AWS_DEFAULT_REGION = "eu-west-1") |>
as.list() |>
do.call(what = Sys.setenv)
return(invisible(NULL))
}
57 changes: 44 additions & 13 deletions R/fit_model_character.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ setMethod(
f = "fit_model",
signature = signature(x = "character"),
definition = function(
x, base, project, status = c("new", "waiting"), verbose = TRUE, ..., bucket
x,
base,
project,
status = c("new", "waiting"),
verbose = TRUE,
...,
bucket
) {
assert_that(is.string(x))
display(verbose, x)
Expand Down Expand Up @@ -50,59 +56,84 @@ setMethod(
}
dots <- list(...)
if (
!has_name(dots, "local") || is.null(dots$local) ||
!inherits(base, "s3_bucket")
!has_name(dots, "local") ||
is.null(dots$local) ||
!inherits(base, "s3_bucket")
) {
analysis <- read_model(hash, base = base, project = project)
display(verbose, paste(status(analysis), "-> "), FALSE)
analysis <- fit_model(
x = analysis, status = status, base = base, project = project, ...
x = analysis,
status = status,
base = base,
project = project,
...
)
display(verbose, status(analysis))
store_model(analysis, base = base, project = project)
result <- data.frame(
fingerprint = get_file_fingerprint(analysis), status = status(analysis)
fingerprint = get_file_fingerprint(analysis),
status = status(analysis)
)
rm(analysis)
gc(verbose = FALSE)
return(invisible(result))
}
dots <- list(...)
to_do <- object_status(
base = base, project = project, status = status, hash = x
base = base,
project = project,
status = status,
hash = x
)
if (length(to_do) == 0) {
display(verbose, "skipping")
gc(verbose = FALSE)
result <- data.frame(
fingerprint = hash, status = "converged"
fingerprint = hash,
status = "converged"
)
return(invisible(result))
}
download_model(
hash = hash, base = base, local = dots$local, project = project,
hash = hash,
base = base,
local = dots$local,
project = project,
verbose = verbose
)
analysis <- read_model(hash, base = dots$local, project = project)
display(verbose, paste(status(analysis), "-> "), FALSE)
slot(analysis, "AnalysisRelation") |>
mutate(
downloaded = map(
.data$parent_analysis, download_model, base = base,
local = dots$local, project = project, verbose = verbose
.data$parent_analysis,
download_model,
base = base,
local = dots$local,
project = project,
verbose = verbose
)
)
analysis <- fit_model(
x = analysis, status = status, base = dots$local, project = project, ...
x = analysis,
status = status,
base = dots$local,
project = project,
...
)
display(verbose, status(analysis))
store_model(analysis, base = dots$local, project = project)
download_model(
hash = hash, local = base, base = dots$local, project = project,
hash = hash,
local = base,
base = dots$local,
project = project,
verbose = verbose
)
result <- data.frame(
fingerprint = get_file_fingerprint(analysis), status = status(analysis)
fingerprint = get_file_fingerprint(analysis),
status = status(analysis)
)
rm(analysis)
gc(verbose = FALSE)
Expand Down
Loading
Loading