-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from EvolEcolGroup/dev
Fix Krapp2021 to work with new version of terra
- Loading branch information
Showing
53 changed files
with
640 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ ci_dependencies | |
^cran-comments.md | ||
^cran-comments\.md$ | ||
^CRAN-SUBMISSION$ | ||
^codecov.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: [main, master, rcheck] | ||
pull_request: | ||
branches: [main, master] | ||
|
||
name: test-coverage | ||
|
||
jobs: | ||
test-coverage: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: r-lib/actions/setup-pandoc@v2 | ||
# with: | ||
# pandoc-version: '2.17.1' | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: any::covr | ||
needs: coverage | ||
|
||
- name: Test coverage | ||
run: covr::codecov(type="all") | ||
shell: Rscript {0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#' Clean the data path | ||
#' | ||
#' This function deletes old reconstructions that have been superseded in the | ||
#' data_path. It assumes that the only files in data_path are part of pastclim | ||
#' (i.e. there are no custom datasets stored in that directory). | ||
#' | ||
#' @param ask boolean on whether the user should be asked before deleting | ||
#' @returns TRUE if files are deleted successfully | ||
#' @export | ||
|
||
clean_data_path <- function(ask=TRUE) { | ||
if (is.null(get_data_path(silent=TRUE))){ | ||
message("The data path has not been set yet; use set_data_path() first!") | ||
return(FALSE) | ||
} | ||
files_now <- list.files(get_data_path()) | ||
possible_files <- unique(getOption("pastclim.dataset_list")$file_name) | ||
files_to_remove <- files_now[!files_now %in% possible_files] | ||
if (length(files_to_remove)>0){ | ||
if (ask){ | ||
this_answer <- utils::menu(choices = c("yes","no"), | ||
title = paste("The following files are obsolete:\n", | ||
paste(files_to_remove,collapse = ", "), | ||
"\n Do you want to delete them?")) | ||
} else { # default to delete if we are not asking | ||
this_answer <- 1 | ||
} | ||
if (this_answer==1){ | ||
file.remove(file.path(get_data_path(),files_to_remove)) | ||
} | ||
} else { | ||
message("Everything is up-to-date; no files need removing.") | ||
} | ||
return(TRUE) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#' Load the dataset list | ||
#' | ||
#' This function returns a dataframe with the details for each variable | ||
#' available in every dataset. It defaults to the copy stored within the | ||
#' package, but it checks in case there is an udpated version stored as | ||
#' 'data_list.csv' in | ||
#' `tools::R_user_dir("pastclim","config")`. If the latter is present, the last | ||
#' column, named 'dataset_list_v', provides the version of this table, and the | ||
#' most advanced table is used. | ||
#' | ||
#' @param on_cran boolean to make this function run on ci tests using tempdir | ||
#' @returns the dataset list | ||
#' @keywords internal | ||
|
||
load_dataset_list <- function(on_cran=FALSE) { | ||
if (!on_cran){ | ||
config_dir <- tools::R_user_dir("pastclim", "config") | ||
} else { | ||
config_dir <- tempdir() | ||
} | ||
if (file.exists(file.path( | ||
config_dir, | ||
"dataset_list_included.csv" | ||
))) { | ||
table_in_config <- utils::read.csv(file.path( | ||
config_dir, | ||
"dataset_list_included.csv" | ||
)) | ||
table_in_config$dataset <- as.factor(table_in_config$dataset) | ||
# we should check that the new table includes all the columns in the original file | ||
if (utils::compareVersion(table_in_config$dataset_list_v[1], | ||
dataset_list_included$dataset_list_v[1])==1){ | ||
# need to update | ||
return(table_in_config) | ||
} | ||
} | ||
return(dataset_list_included) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#' Update the dataset list | ||
#' | ||
#' If a newer dataset list (which includes all the information about the files | ||
#' storing the data for pastclim), download it and start using it as | ||
#' 'dataset_list_included.csv' in | ||
#' `tools::R_user_dir("pastclim","config")`. If the latter is present, the last | ||
#' column, named 'dataset_list_v', provides the version of this table, and the | ||
#' most advanced table is used. | ||
#' | ||
#' @param on_cran boolean to make this function run on ci tests using tempdir | ||
#' @returns TRUE if the dataset was updated | ||
#' @export | ||
|
||
update_dataset_list <- function(on_cran=FALSE) { | ||
curl::curl_download("https://raw.githubusercontent.com/EvolEcolGroup/pastclim/dataset_list/dataset_list_included.csv", | ||
destfile = file.path(tempdir(), "dataset_list_included.csv"), | ||
quiet = FALSE) | ||
new_table_github <- utils::read.csv(file.path(tempdir(), "dataset_list_included.csv")) | ||
# if the github version is more recent, copy it into config | ||
if (utils::compareVersion(new_table_github$dataset_list_v[1], | ||
getOption("pastclim.dataset_list")$dataset_list_v[1])==1){ | ||
file.copy(utils::read.csv(file.path(tempdir(), "dataset_list_included.csv")), | ||
to= file.path(tools::R_user_dir("pastclim", "config"),"dataset_list_included.csv")) | ||
load_dataset_list() | ||
message("The dataset list was updated.") | ||
return(TRUE) | ||
} else { | ||
message("The dataset list currently installed is already the latest version.") | ||
return(FALSE) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.