Skip to content

Commit

Permalink
Merge branch 'main' into spotfire_poc2
Browse files Browse the repository at this point in the history
  • Loading branch information
gogonzo committed Nov 15, 2024
2 parents 4d47422 + d9fb47d commit 2da7ec9
Show file tree
Hide file tree
Showing 10 changed files with 230 additions and 180 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: teal
Title: Exploratory Web Apps for Analyzing Clinical Trials Data
Version: 0.15.2.9082
Date: 2024-11-08
Version: 0.15.2.9085
Date: 2024-11-11
Authors@R: c(
person("Dawid", "Kaledkowski", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-9533-457X")),
Expand Down Expand Up @@ -37,7 +37,7 @@ BugReports: https://github.com/insightsengineering/teal/issues
Depends:
R (>= 4.0),
shiny (>= 1.8.1),
teal.data (>= 0.6.0.9015),
teal.data (>= 0.6.0.9017),
teal.slice (>= 0.5.1.9009)
Imports:
checkmate (>= 2.1.0),
Expand All @@ -49,7 +49,7 @@ Imports:
rlang (>= 1.0.0),
shinyjs,
stats,
teal.code (>= 0.5.0.9012),
teal.code (>= 0.5.0.9015),
teal.logger (>= 0.2.0),
teal.reporter (>= 0.3.1.9004),
teal.widgets (>= 0.4.0),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# teal 0.15.2.9082
# teal 0.15.2.9085

### New features

Expand Down
2 changes: 1 addition & 1 deletion R/module_nested_tabs.R
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ srv_teal_module.teal_module <- function(id,
req(inherits(transformed_teal_data(), "teal_data"))
all_teal_data <- transformed_teal_data()
module_datanames <- .resolve_module_datanames(data = all_teal_data, modules = modules)
.subset_teal_data(all_teal_data, module_datanames)
all_teal_data[c(module_datanames, ".raw_data")]
})

srv_validate_reactive_teal_data(
Expand Down
30 changes: 1 addition & 29 deletions R/teal_data_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#' @param data (`teal_data`)
#' @param code (`character`) code to append to the object's code slot.
#' @param objects (`list`) objects to append to object's environment.
#' @param datanames (`character`) names of the datasets
#' @return modified `teal_data`
#' @keywords internal
#' @name teal_data_utilities
Expand All @@ -20,10 +19,7 @@ NULL
#' @rdname teal_data_utilities
.append_evaluated_code <- function(data, code) {
checkmate::assert_class(data, "teal_data")
data@code <- c(data@code, code)
data@id <- c(data@id, max(data@id) + 1L + seq_along(code))
data@messages <- c(data@messages, rep("", length(code)))
data@warnings <- c(data@warnings, rep("", length(code)))
data@code <- c(data@code, code2list(code))
methods::validObject(data)
data
}
Expand All @@ -37,27 +33,3 @@ NULL
data@.xData <- new_env
data
}

#' @rdname teal_data_utilities
.subset_teal_data <- function(data, datanames) {
checkmate::assert_class(data, "teal_data")
checkmate::assert_class(datanames, "character")
datanames_corrected <- intersect(datanames, names(data))
datanames_corrected_with_raw <- c(datanames_corrected, ".raw_data")
if (!length(datanames_corrected)) {
return(teal_data())
}

new_data <- do.call(
teal.data::teal_data,
args = c(
mget(x = datanames_corrected_with_raw, envir = as.environment(data)),
list(
code = teal.code::get_code(data, names = datanames_corrected_with_raw),
join_keys = teal.data::join_keys(data)[datanames_corrected]
)
)
)
new_data@verified <- data@verified
new_data
}
1 change: 1 addition & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ RcodeBlock <- getFromNamespace("RcodeBlock", "teal.reporter") # nolint: object_n
# Use non-exported function(s) from teal.code
# This one is here because lang2calls should not be exported from teal.code
lang2calls <- getFromNamespace("lang2calls", "teal.code")
code2list <- getFromNamespace("code2list", "teal.data")
2 changes: 2 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Hoffmann
MAEs
ORCID
Reproducibility
Shiny's
TLG
UI
UX
Expand All @@ -16,6 +17,7 @@ favicon
favicons
funder
lockfile
modularized
omics
pre
programmatically
Expand Down
5 changes: 0 additions & 5 deletions man/teal_data_utilities.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions tests/testthat/test-module_teal.R
Original file line number Diff line number Diff line change
Expand Up @@ -1413,10 +1413,10 @@ testthat::describe("srv_teal filters", {
c(
"iris <- iris",
"mtcars <- mtcars",
sprintf('stopifnot(rlang::hash(iris) == "%s")', rlang::hash(iris)),
sprintf('stopifnot(rlang::hash(mtcars) == "%s")', rlang::hash(mtcars)),
sprintf('stopifnot(rlang::hash(iris) == "%s") # @linksto iris', rlang::hash(iris)),
sprintf('stopifnot(rlang::hash(mtcars) == "%s") # @linksto mtcars', rlang::hash(mtcars)),
".raw_data <- list2env(list(iris = iris, mtcars = mtcars))",
"lockEnvironment(.raw_data)",
"lockEnvironment(.raw_data) # @linksto .raw_data",
"mtcars <- dplyr::filter(mtcars, cyl == 4)"
),
collapse = "\n"
Expand Down Expand Up @@ -1591,10 +1591,10 @@ testthat::describe("srv_teal teal_module(s) transformer", {
expected_code <- paste(collapse = "\n", c(
"iris <- iris",
"mtcars <- mtcars",
sprintf('stopifnot(rlang::hash(iris) == "%s")', rlang::hash(iris)),
sprintf('stopifnot(rlang::hash(mtcars) == "%s")', rlang::hash(mtcars)),
sprintf('stopifnot(rlang::hash(iris) == "%s") # @linksto iris', rlang::hash(iris)),
sprintf('stopifnot(rlang::hash(mtcars) == "%s") # @linksto mtcars', rlang::hash(mtcars)),
".raw_data <- list2env(list(iris = iris, mtcars = mtcars))",
"lockEnvironment(.raw_data)",
"lockEnvironment(.raw_data) # @linksto .raw_data",
'iris <- dplyr::filter(iris, Species == "versicolor")',
"mtcars <- dplyr::filter(mtcars, cyl == 6)",
"iris <- head(iris, n = 6)",
Expand Down Expand Up @@ -1637,10 +1637,10 @@ testthat::describe("srv_teal teal_module(s) transformer", {
expected_code <- paste(collapse = "\n", c(
"iris <- iris",
"mtcars <- mtcars",
sprintf('stopifnot(rlang::hash(iris) == "%s")', rlang::hash(iris)),
sprintf('stopifnot(rlang::hash(mtcars) == "%s")', rlang::hash(mtcars)),
sprintf('stopifnot(rlang::hash(iris) == "%s") # @linksto iris', rlang::hash(iris)),
sprintf('stopifnot(rlang::hash(mtcars) == "%s") # @linksto mtcars', rlang::hash(mtcars)),
".raw_data <- list2env(list(iris = iris, mtcars = mtcars))",
"lockEnvironment(.raw_data)",
"lockEnvironment(.raw_data) # @linksto .raw_data",
"mtcars <- dplyr::filter(mtcars, cyl == 4)",
"iris <- head(iris, n = 6)",
"mtcars <- head(mtcars, n = 6)"
Expand Down Expand Up @@ -2445,7 +2445,7 @@ testthat::describe("Datanames with special symbols", {
}
),
modules = modules(
module("module_1", server = function(id, data) data, , datanames = c("iris"))
module("module_1", server = function(id, data) data, datanames = c("iris"))
),
filter = teal_slices(
module_specific = TRUE
Expand Down Expand Up @@ -2483,7 +2483,7 @@ testthat::describe("teal.data code with a function defined", {
}
})),
modules = modules(module("module_1", server = function(id, data) data))
), ,
),
expr = {
session$setInputs("teal_modules-active_tab" = "module_1")
session$flushReact()
Expand Down Expand Up @@ -2545,9 +2545,9 @@ testthat::describe("teal.data code with a function defined", {
"y <- x + 1",
"y + 3",
"}",
sprintf("stopifnot(rlang::hash(deparse1(fun)) == \"%s\")", local_env$hash),
sprintf("stopifnot(rlang::hash(deparse1(fun)) == \"%s\") # @linksto fun", local_env$hash),
".raw_data <- list2env(list(fun = fun))",
"lockEnvironment(.raw_data)"
"lockEnvironment(.raw_data) # @linksto .raw_data"
)
)
}
Expand Down
13 changes: 6 additions & 7 deletions tests/testthat/test-shinytest2-show-rcode.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,15 @@ testthat::test_that("e2e: teal app initializes with Show R Code modal", {
)

# Check R code output.
testthat::expect_identical(
app$get_text(app$active_module_element("rcode-verbatim_content")),
paste(
testthat::expect_setequal(
strsplit(app$get_text(app$active_module_element("rcode-verbatim_content")), "\n")[[1]],
c(
"iris <- iris",
"mtcars <- mtcars",
sprintf('stopifnot(rlang::hash(iris) == "%s")', rlang::hash(iris)),
sprintf('stopifnot(rlang::hash(mtcars) == "%s")', rlang::hash(mtcars)),
sprintf('stopifnot(rlang::hash(iris) == "%s") # @linksto iris', rlang::hash(iris)),
sprintf('stopifnot(rlang::hash(mtcars) == "%s") # @linksto mtcars', rlang::hash(mtcars)),
".raw_data <- list2env(list(iris = iris, mtcars = mtcars))",
"lockEnvironment(.raw_data)",
sep = "\n"
"lockEnvironment(.raw_data) # @linksto .raw_data"
)
)

Expand Down
Loading

0 comments on commit 2da7ec9

Please sign in to comment.