diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index 4128518..bd8cb97 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ -Version: 1.1.1 -Date: 2024-02-07 17:45:58 UTC -SHA: c69f5c5308ae5c0c96d955d46d309231299f9c2f +Version: 1.1.2 +Date: 2024-02-16 16:22:21 UTC +SHA: 7e7dcf69b9d37cbd43f3b4ddb63916019f3bb32b diff --git a/DESCRIPTION b/DESCRIPTION index 0eca603..e0d47de 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: jlmerclusterperm Title: Cluster-Based Permutation Analysis for Densely Sampled Time Data -Version: 1.1.1 +Version: 1.1.2 Authors@R: person("June", "Choe", , "jchoe001@gmail.com", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0002-0701-921X")) diff --git a/NEWS.md b/NEWS.md index 33833d0..5954077 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,10 @@ -# jlmerclusterperm 1.1.1 +# jlmerclusterperm 1.1.2 + +- `jlmerclusterperm()` exposes a `cache_dir` argument for manually specifying the cache directory. This was added largely for the convenience of testing. The default value of `cache_dir = NULL` preserves old behavior. + +Fixes for CRAN: + +- Write cache to `tempdir()` for the purposes of running examples and tests. # jlmerclusterperm 1.1.1 diff --git a/R/aaa.R b/R/aaa.R index 1a3a5af..2d00ab9 100644 --- a/R/aaa.R +++ b/R/aaa.R @@ -42,6 +42,9 @@ julia_setup_ok <- function() { #' Initial setup for the jlmerclusterperm package #' #' @param ... Ignored. +#' @param cache_dir The location to write out package cache files (namely, Manifest.toml). +#' If `NULL` (default), attempts to write to the package's cache directory discovered via +#' `R_user_dir()` and falls back to `tempdir()`. #' @param restart Whether to set up a fresh Julia session, given that one is already running. #' If `FALSE` and `jlmerclusterperm_setup()` has already been called, nothing happens. #' @param verbose Print progress and messages from Julia in the console @@ -49,7 +52,7 @@ julia_setup_ok <- function() { #' @examplesIf julia_setup_ok() #' \donttest{ #' options("jlmerclusterperm.nthreads" = 2) -#' jlmerclusterperm_setup(verbose = FALSE) +#' jlmerclusterperm_setup(cache_dir = tempdir(), verbose = FALSE) #' #' \dontshow{ #' JuliaConnectoR::stopJulia() @@ -58,12 +61,12 @@ julia_setup_ok <- function() { #' #' @export #' @return TRUE -jlmerclusterperm_setup <- function(..., restart = TRUE, verbose = TRUE) { +jlmerclusterperm_setup <- function(..., cache_dir = NULL, restart = TRUE, verbose = TRUE) { if (!JuliaConnectoR::juliaSetupOk()) cli::cli_abort("No Julia installation detected.") if (!julia_version_compatible()) cli::cli_abort("Julia version >=1.8 required.") if (restart || !is_setup()) { JuliaConnectoR::stopJulia() - setup_with_progress(verbose = verbose) + setup_with_progress(cache_dir = cache_dir, verbose = verbose) .jlmerclusterperm$is_setup <- TRUE } else { cli::cli_inform("Julia instance already running - skipping setup.") @@ -71,9 +74,9 @@ jlmerclusterperm_setup <- function(..., restart = TRUE, verbose = TRUE) { invisible(TRUE) } -setup_with_progress <- function(..., verbose = TRUE) { +setup_with_progress <- function(..., cache_dir = NULL, verbose = TRUE) { start_with_threads(verbose = verbose) - set_projenv(verbose = verbose) + set_projenv(cache_dir = cache_dir, verbose = verbose) source_jl(verbose = verbose) define_globals() cleanup_jl() @@ -96,19 +99,25 @@ start_with_threads <- function(..., max_threads = 7L, verbose = TRUE) { invisible(TRUE) } -set_projenv <- function(..., verbose = TRUE) { +set_projenv <- function(..., cache_dir = NULL, verbose = TRUE) { if (verbose) cli::cli_progress_step("Activating package environment") - pkgdir <- system.file("julia/", package = "jlmerclusterperm") - cachedir <- R_user_dir("jlmerclusterperm", which = "cache") - userdir <- if (dir.exists(dirname(cachedir))) cachedir else tempdir() + userdir <- if (!is.null(cache_dir)) { + cache_dir + } else { + pkg_cache_dir <- R_user_dir("jlmerclusterperm", which = "cache") + if (dir.exists(dirname(pkg_cache_dir))) pkg_cache_dir else tempdir() + } projdir <- file.path(userdir, "julia") manifest <- file.path(projdir, "Manifest.toml") - manifest_cached <- file.exists(manifest) && (parse_julia_version(readLines(manifest)[3]) == julia_version()) + manifest_cached <- file.exists(manifest) && + (julia_version() == parse_julia_version(readLines(manifest)[3])) if (!dir.exists(userdir)) { dir.create(userdir) - } else if (!manifest_cached) { - unlink(dir(userdir, full.names = TRUE), recursive = TRUE) } + if (!manifest_cached) { + unlink(manifest) + } + pkgdir <- system.file("julia/", package = "jlmerclusterperm") file.copy(from = pkgdir, to = userdir, recursive = TRUE) JuliaConnectoR::juliaCall("cd", projdir) JuliaConnectoR::juliaEval("using Pkg") diff --git a/R/calculate_pvalue.R b/R/calculate_pvalue.R index 37264a5..f1d4126 100644 --- a/R/calculate_pvalue.R +++ b/R/calculate_pvalue.R @@ -12,7 +12,7 @@ #' \donttest{ #' \dontshow{ #' options("jlmerclusterperm.nthreads" = 2) -#' jlmerclusterperm_setup(verbose = FALSE) +#' jlmerclusterperm_setup(cache_dir = tempdir(), verbose = FALSE) #' julia_progress(show = FALSE) #' } #' diff --git a/R/clusterpermute.R b/R/clusterpermute.R index 6058ed7..5fe79c4 100644 --- a/R/clusterpermute.R +++ b/R/clusterpermute.R @@ -13,7 +13,7 @@ #' \donttest{ #' \dontshow{ #' options("jlmerclusterperm.nthreads" = 2) -#' jlmerclusterperm_setup(verbose = FALSE) +#' jlmerclusterperm_setup(cache_dir = tempdir(), verbose = FALSE) #' julia_progress(show = FALSE) #' } #' diff --git a/R/compute_timewise_statistics.R b/R/compute_timewise_statistics.R index fa5cfdb..37b06d0 100644 --- a/R/compute_timewise_statistics.R +++ b/R/compute_timewise_statistics.R @@ -17,7 +17,7 @@ #' \donttest{ #' \dontshow{ #' options("jlmerclusterperm.nthreads" = 2) -#' jlmerclusterperm_setup(verbose = FALSE) +#' jlmerclusterperm_setup(cache_dir = tempdir(), verbose = FALSE) #' julia_progress(show = FALSE) #' } #' diff --git a/R/extract_clusters.R b/R/extract_clusters.R index da5790f..dff2eed 100644 --- a/R/extract_clusters.R +++ b/R/extract_clusters.R @@ -16,7 +16,7 @@ #' \donttest{ #' \dontshow{ #' options("jlmerclusterperm.nthreads" = 2) -#' jlmerclusterperm_setup(verbose = FALSE) +#' jlmerclusterperm_setup(cache_dir = tempdir(), verbose = FALSE) #' julia_progress(show = FALSE) #' } #' @@ -83,7 +83,7 @@ extract_empirical_clusters <- function(empirical_statistics, threshold, binned = #' \donttest{ #' \dontshow{ #' options("jlmerclusterperm.nthreads" = 2) -#' jlmerclusterperm_setup(verbose = FALSE) +#' jlmerclusterperm_setup(cache_dir = tempdir(), verbose = FALSE) #' julia_progress(show = FALSE) #' } #' diff --git a/R/interop-utils.R b/R/interop-utils.R index 72686e1..d24193a 100644 --- a/R/interop-utils.R +++ b/R/interop-utils.R @@ -11,7 +11,7 @@ JuliaConnectoR::stopJulia #' \donttest{ #' \dontshow{ #' options("jlmerclusterperm.nthreads" = 2) -#' jlmerclusterperm_setup(verbose = FALSE) +#' jlmerclusterperm_setup(cache_dir = tempdir(), verbose = FALSE) #' } #' #' # Show current progress options diff --git a/R/jlmer.R b/R/jlmer.R index d35b6ff..61732b5 100644 --- a/R/jlmer.R +++ b/R/jlmer.R @@ -14,7 +14,7 @@ #' \donttest{ #' \dontshow{ #' options("jlmerclusterperm.nthreads" = 2) -#' jlmerclusterperm_setup(verbose = FALSE) +#' jlmerclusterperm_setup(cache_dir = tempdir(), verbose = FALSE) #' julia_progress(show = FALSE) #' } #' @@ -57,7 +57,7 @@ to_jlmer <- function(formula, data, family = c("gaussian", "binomial"), jlmer_sp #' \donttest{ #' \dontshow{ #' options("jlmerclusterperm.nthreads" = 2) -#' jlmerclusterperm_setup(verbose = FALSE) +#' jlmerclusterperm_setup(cache_dir = tempdir(), verbose = FALSE) #' julia_progress(show = FALSE) #' } #' diff --git a/R/julia_rng.R b/R/julia_rng.R index 883da63..b11d9d0 100644 --- a/R/julia_rng.R +++ b/R/julia_rng.R @@ -5,7 +5,7 @@ #' \donttest{ #' \dontshow{ #' options("jlmerclusterperm.nthreads" = 2) -#' jlmerclusterperm_setup(verbose = FALSE) +#' jlmerclusterperm_setup(cache_dir = tempdir(), verbose = FALSE) #' julia_progress(show = FALSE) #' } #' diff --git a/R/permute.R b/R/permute.R index 65c75b3..cd93c31 100644 --- a/R/permute.R +++ b/R/permute.R @@ -9,7 +9,7 @@ #' \donttest{ #' \dontshow{ #' options("jlmerclusterperm.nthreads" = 2) -#' jlmerclusterperm_setup(verbose = FALSE) +#' jlmerclusterperm_setup(cache_dir = tempdir(), verbose = FALSE) #' julia_progress(show = FALSE) #' } #' diff --git a/R/permute_timewise_statistics.R b/R/permute_timewise_statistics.R index 44ce884..f3af579 100644 --- a/R/permute_timewise_statistics.R +++ b/R/permute_timewise_statistics.R @@ -10,7 +10,7 @@ #' \donttest{ #' \dontshow{ #' options("jlmerclusterperm.nthreads" = 2) -#' jlmerclusterperm_setup(verbose = FALSE) +#' jlmerclusterperm_setup(cache_dir = tempdir(), verbose = FALSE) #' julia_progress(show = FALSE) #' } #' diff --git a/R/threshold_search.R b/R/threshold_search.R index c94c3f4..2098073 100644 --- a/R/threshold_search.R +++ b/R/threshold_search.R @@ -10,7 +10,7 @@ #' \donttest{ #' \dontshow{ #' options("jlmerclusterperm.nthreads" = 2) -#' jlmerclusterperm_setup(verbose = FALSE) +#' jlmerclusterperm_setup(cache_dir = tempdir(), verbose = FALSE) #' julia_progress(show = FALSE) #' } #' diff --git a/R/tidy.R b/R/tidy.R index f325492..ad93344 100644 --- a/R/tidy.R +++ b/R/tidy.R @@ -14,7 +14,7 @@ generics::tidy #' \donttest{ #' \dontshow{ #' options("jlmerclusterperm.nthreads" = 2) -#' jlmerclusterperm_setup(verbose = FALSE) +#' jlmerclusterperm_setup(cache_dir = tempdir(), verbose = FALSE) #' julia_progress(show = FALSE) #' } #' @@ -99,7 +99,7 @@ tidy.jlmer_mod <- function(x, effects = c("var_model", "ran_pars", "fixed"), ... #' \donttest{ #' \dontshow{ #' options("jlmerclusterperm.nthreads" = 2) -#' jlmerclusterperm_setup(verbose = FALSE) +#' jlmerclusterperm_setup(cache_dir = tempdir(), verbose = FALSE) #' julia_progress(show = FALSE) #' } #' diff --git a/README.md b/README.md index 4cc83e9..b612966 100644 --- a/README.md +++ b/README.md @@ -273,7 +273,7 @@ following as you see fit. To cite jlmerclusterperm: - Choe, J. (2023). jlmerclusterperm: Cluster-Based Permutation Analysis - for Densely Sampled Time Data. R package version 1.1.1. + for Densely Sampled Time Data. R package version 1.1.2. . To cite the cluster-based permutation test: diff --git a/cran-comments.md b/cran-comments.md index 0037a2f..6a315d7 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,3 +1,7 @@ +Fixes for CRAN: + +* Write cache to `tempdir()` for the purposes of running examples and tests. + ## R CMD check results 0 errors | 0 warnings | 0 notes diff --git a/docs/404.html b/docs/404.html index 6cf2a37..822e137 100644 --- a/docs/404.html +++ b/docs/404.html @@ -33,7 +33,7 @@ jlmerclusterperm - 1.1.1 + 1.1.2