-
-
Notifications
You must be signed in to change notification settings - Fork 46
{teal}
module returns a teal_report
object that extends from teal_data
#1541
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
base: main
Are you sure you want to change the base?
Conversation
# Conflicts: # R/module_nested_tabs.R # R/module_teal.R # R/module_transform_data.R
# Conflicts: # R/module_nested_tabs.R
# Conflicts: # DESCRIPTION # R/module_data_summary.R # R/module_nested_tabs.R # R/module_teal.R # R/module_transform_data.R
# Conflicts: # R/module_teal.R
Hey @vedhav @gogonzo just letting you know that I am merging `main` into `test@bslib@main` branch, so that on other repositories, like `tmg`, we can install `teal` from this branch and also we can satisfy condition for `teal` to be `>= 0.16.0`. https://github.com/insightsengineering/teal.modules.general/blob/report_redesign_poc%40main/DESCRIPTION#L83 https://github.com/insightsengineering/teal.modules.general/blob/report_redesign_poc%40main/DESCRIPTION#L30 --------- Co-authored-by: Dony Unardi <donyunardi@gmail.com> Co-authored-by: insights-engineering-bot <68416928+insights-engineering-bot@users.noreply.github.com>
Companion to insightsengineering/teal.reporter#334 Consequence of changing naming convention for `teal_report` object. --------- Signed-off-by: André Veríssimo <211358+averissimo@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com>
R/after.R
Outdated
moduleServer(id, function(input, output, session) { | ||
original_out <- if (all(c("input", "output", "session") %in% names(formals(`_x`)))) { | ||
original_args$module <- `_x` | ||
do.call(call_module, args = original_args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gogonzo is this a typo? call_module
is not defined anywhere
do.call(call_module, args = original_args) | |
do.call(shiny::callModule, args = original_args) |
Code Coverage Summary
Diff against main
Results for commit: abb2307 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Some thoughts before closing for the week:
|
@@ -15,9 +15,11 @@ S3method(ui_teal_module,teal_modules) | |||
S3method(within,teal_data_module) | |||
export(TealReportCard) | |||
export(add_landing_modal) | |||
export(after) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this is a really bad name that can mean anything. It feels very much async related. Please reassess the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to let you know @pawelru - this is a function that edits/manipulates teal_data
(now extended to teal_report
class) after it was returned by module's server
. It is applied on a module level.
So basically it is:
module() |>
edit_data_returned_by_server()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about modify_teal_module
or edit_teal_module
?
Then, we'll have .modify/edit_teal_module_ui
and .modify/edit_teal_module_srv
EDIT: I saw the comment that this was previously called modify_reactive_output
.
#' @param x (`teal_data`) | ||
#' @param ui (`function(id, elem, ...)`) function to receive output (`shiny.tag`) from `x$ui` | ||
#' @param server (`function(input, output, session, data, ...)`) function to receive output data from `x$server` | ||
#' @param ... additional argument passed to `ui` and `server` by matching their formals names. | ||
#' @return A `teal_report` object with the result of the server function. | ||
#' @export | ||
after <- function(x, | ||
ui = function(id, elem) elem, | ||
server = function(input, output, session, data) data, | ||
...) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since after
is applied like below
<teal_module> |> after(
server = function(data) {
teal.reporter::teal_card(data) <- c(
teal.reporter::teal_card(data),
"# added content",
"This content has been added through `after`"
)
data
}
)
I think
#' @param x (`teal_data`)
should be updated to
#' @param x (`teal_module`)
and
server = function(input, output, session, data) data
to
server = function(data) data
?
if (!is.function(server) || !all(names(formals(server)) %in% c("input", "output", "session", "data"))) { | ||
stop("server should be a function of `input` and `output`, `session`, `data`") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are those checks even working if we pass server function without input
, output
and session
?
<teal_module> |> after(
server = function(data) {
teal.reporter::teal_card(data) <- c(
teal.reporter::teal_card(data),
"# added content",
"This content has been added through `after`"
)
data
}
)
#' | ||
#' Primarily used to modify the output object of module to change the containing | ||
#' report. | ||
#' @param x (`teal_data`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#' @param x (`teal_data`) | |
#' @param x (`teal_module`) |
When teal_module's server returns an error (validation error, qenv error etc.) teal.reporter-add button has no protection against it. This PR fixes following: - To not display error received from a module - To disable add-to-report-button when error occurs --------- Signed-off-by: Dawid Kałędkowski <dawid.kaledkowski@gmail.com> Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com>
…l_data` (#255) # Pull Request Fixes: - insightsengineering/teal#1526 Built on top of: - insightsengineering/teal.reporter#307 - _(#307 will be closed once this PR is stable)_ ### Companion PRs: - insightsengineering/teal#1541 - #255 - insightsengineering/teal.data#370 - insightsengineering/teal.reporter#331 - insightsengineering/teal.modules.general#884 ### Changes description - [x] Add new parameter `cache` - Caches the result of the last evaluation in the respective `@code` slot - [ ] Decide on name - [x] Remove signature with multiple arguments to allow overriding `eval_code` in other packages without showing a note ``` r pkgload::load_all("teal.code") #> ℹ Loading teal.code q <- qenv() |> eval_code(1 + 1, cache = TRUE) |> eval_code(mtcars <- head(mtcars)) attr(q@code[[1]], "cache") #> [1] 2 ``` <sup>Created on 2025-06-03 with [reprex v2.1.1](https://reprex.tidyverse.org)</sup> --------- Co-authored-by: Dawid Kaledkowski <dawid.kaledkowski@gmail.com> Co-authored-by: Marcin <133694481+m7pr@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
…l_data` (#370) # Pull Request Fixes: - insightsengineering/teal#1526 Built on top of: - insightsengineering/teal.reporter#307 - _(#307 will be closed once this PR is stable)_ ### Companion PRs: - insightsengineering/teal#1541 - insightsengineering/teal.code#255 - #370 - insightsengineering/teal.reporter#331 - insightsengineering/teal.modules.general#884 ### Changes description - [x] Cleanup of `teal_data` class to allow for `teal_report` extension - [x] Change the `show()` method to remove reference to `teal_data` specifically --------- Co-authored-by: Dawid Kaledkowski <dawid.kaledkowski@gmail.com> Co-authored-by: Marcin <133694481+m7pr@users.noreply.github.com>
First off, I really appreciate the exploration and research that been poured into this PR. I have two observations so far: Automatic conversion from
|
I will just add that I think learning about |
I prefer a solution on top of |
When I conduct training/workshop, I usually show users that the We agreed that Although it's possible, it's hard for me to think that someone will intentionally include any content that is not related to the teal_data/real_report object. Arguably, I can even do that with the current R6 solution with the In addition to
Is the idea to also introduce From release perspective, this means teal.data will have to be released before teal.reporter. Not a big deal we agree if this is the way to go. |
The team had another go at discussing this solution. The fundamental change in this approach is that we are now including We also talked about the benefit of automatically converting this to This also means that module developers no longer need to worry about passing the Modules need to return a reactive From the user’s perspective, I think this solution will be well received by our module developers and will simplify the process of building teal modules. This solution may also enable automatic creation of the "Show R Code" button, another feature we may offer by default in the teal framework. We will not introduce There is one question that I thought when drafting this summary, if in the future we decide to add another feature involving both data and reporting, how easy will it be to extend the proposed design? Would we need to extend |
From user's perspective, I like that this proposal makes it much simpler for the user (module developer) to be able to create a module with the reporter feature, in a nice structured way. In terms of converting the Agree to Not expose or instruct users to use |
Pull Request
Fixes:
Built on top of:
teal.reporter
Cards #1499 (will be closed once this PR is stable)Companion PRs:
{teal}
module returns ateal_report
object that extends fromteal_data
#1541{teal}
module returns ateal_report
object that extends fromteal_data
teal.code#255{teal}
module returns ateal_report
object that extends fromteal_data
teal.data#370{teal}
module returns ateal_report
object that extends fromteal_data
teal.reporter#331{teal}
module returns ateal_report
object that extends fromteal_data
teal.modules.general#884Changes description
teal_report
object is returned from the modulemodify_reactive_output()
toafter()
Sample app