Skip to content

Commit 97d1963

Browse files
authored
fix logic for preloadData (#50)
* fix logic for preloadData * cleanup * fixes for empty dataset * rename rstudio project to match package name
1 parent 15aefc3 commit 97d1963

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

R/dataset.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ loadCorrectDataset <- function(x) {
22
if (is.matrix(x) || is.data.frame(x)) {
33
return(x)
44
} else if (is.character(x)) {
5-
if (! endsWith(x, ".csv")) {
5+
if (!endsWith(x, ".csv")) {
66
x <- paste0(x, ".csv")
77
}
88

@@ -50,6 +50,11 @@ findAllColumnNamesInOptions <- function(options, allColumnNames) {
5050

5151
preloadDataset <- function(datasetPathOrObject, options) {
5252

53+
if (is.null(datasetPathOrObject)) {
54+
.setInternal("preloadedDataset", data.frame())
55+
return()
56+
}
57+
5358
dataset <- loadCorrectDataset(datasetPathOrObject)
5459

5560
# repair any names like "", which cause false positives in findAllColumnNamesAndTypes

R/options.R

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,17 @@ parsePreloadDataFromDescriptionQml <- function(analysisName) {
297297

298298
description <- parseDescriptionQmlFromAnalysisName(analysisName)
299299

300-
preloadData <- isTRUE(description[["Description"]][["preloadData"]]) || isTRUE(description[[analysisName]][["preloadData"]])
301-
if (!preloadData)
300+
# is preloadData globally set to TRUE?
301+
preloadDataGlobal <- isTRUE(description[["Description"]][["preloadData"]])
302+
# is preloadData even set for this specific analysis?
303+
specifiedPreloadData <- "preloadData" %in% names(description[[analysisName]])
304+
# is preloadData set to TRUE for this specific analysis?
305+
preloadDataAnalysis <- specifiedPreloadData && isTRUE(description[[analysisName]][["preloadData"]])
306+
# if preloadData set to TRUE for the analysis, or if set globally to TRUE and not set for the analysis
307+
preloadData <- preloadDataAnalysis || (preloadDataGlobal && !specifiedPreloadData)
308+
309+
# show a warning but only if the preloadData is not set for the analysis
310+
if (!preloadData && !specifiedPreloadData)
302311
lifecycle::deprecate_warn(
303312
when = "0.19.2",
304313
what = I(sprintf("The analysis `%s` does not preload data. Please update inst/Description.qml, add `preloadData: true`, and fix any minor issues.", analysisName))

R/run.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#'
5555
#'
5656
#' @export runAnalysis
57-
runAnalysis <- function(name, dataset, options, view = TRUE, quiet = FALSE, makeTests = FALSE) {
57+
runAnalysis <- function(name, dataset = NULL, options, view = TRUE, quiet = FALSE, makeTests = FALSE) {
5858
if (is.list(options) && is.null(names(options)) && any(names(unlist(lapply(options, attributes))) == "analysisName"))
5959
stop("The provided list of options is not named. Did you mean to index in the options list (e.g., options[[1]])?")
6060

File renamed without changes.

0 commit comments

Comments
 (0)