Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix logic for preloadData #50

Merged
merged 4 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion R/dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ loadCorrectDataset <- function(x) {
if (is.matrix(x) || is.data.frame(x)) {
return(x)
} else if (is.character(x)) {
if (! endsWith(x, ".csv")) {
if (!endsWith(x, ".csv")) {
x <- paste0(x, ".csv")
}

Expand Down Expand Up @@ -50,6 +50,11 @@ findAllColumnNamesInOptions <- function(options, allColumnNames) {

preloadDataset <- function(datasetPathOrObject, options) {

if (is.null(datasetPathOrObject)) {
.setInternal("preloadedDataset", data.frame())
return()
}

dataset <- loadCorrectDataset(datasetPathOrObject)

# repair any names like "", which cause false positives in findAllColumnNamesAndTypes
Expand Down
13 changes: 11 additions & 2 deletions R/options.R
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,17 @@ parsePreloadDataFromDescriptionQml <- function(analysisName) {

description <- parseDescriptionQmlFromAnalysisName(analysisName)

preloadData <- isTRUE(description[["Description"]][["preloadData"]]) || isTRUE(description[[analysisName]][["preloadData"]])
if (!preloadData)
# is preloadData globally set to TRUE?
preloadDataGlobal <- isTRUE(description[["Description"]][["preloadData"]])
# is preloadData even set for this specific analysis?
specifiedPreloadData <- "preloadData" %in% names(description[[analysisName]])
# is preloadData set to TRUE for this specific analysis?
preloadDataAnalysis <- specifiedPreloadData && isTRUE(description[[analysisName]][["preloadData"]])
# if preloadData set to TRUE for the analysis, or if set globally to TRUE and not set for the analysis
preloadData <- preloadDataAnalysis || (preloadDataGlobal && !specifiedPreloadData)

# show a warning but only if the preloadData is not set for the analysis
if (!preloadData && !specifiedPreloadData)
lifecycle::deprecate_warn(
when = "0.19.2",
what = I(sprintf("The analysis `%s` does not preload data. Please update inst/Description.qml, add `preloadData: true`, and fix any minor issues.", analysisName))
Expand Down
2 changes: 1 addition & 1 deletion R/run.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#'
#'
#' @export runAnalysis
runAnalysis <- function(name, dataset, options, view = TRUE, quiet = FALSE, makeTests = FALSE) {
runAnalysis <- function(name, dataset = NULL, options, view = TRUE, quiet = FALSE, makeTests = FALSE) {
if (is.list(options) && is.null(names(options)) && any(names(unlist(lapply(options, attributes))) == "analysisName"))
stop("The provided list of options is not named. Did you mean to index in the options list (e.g., options[[1]])?")

Expand Down
File renamed without changes.
Loading