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

Improve print for teal_data_module/teal_transform_module to be more useful #1403

Open
vedhav opened this issue Nov 6, 2024 · 0 comments
Open
Labels
core enhancement New feature or request

Comments

@vedhav
Copy link
Contributor

vedhav commented Nov 6, 2024

Currently, the teal_data_module and teal_transform_module just prints the UI and Server functions and the attributes when we print them. It will be nice if we can format this to showcase key information.

Similar to #1378. Additionally, it will be helpful if we can use this format to further show more information in the print method of the teal_module that uses transformations.

Example object and current print:

tdm <- teal_data_module(
  ui = function(id) {
    ns <- NS(id)
    actionButton(ns("submit"), label = "Load data")
  },
  server = function(id) {
    moduleServer(id, function(input, output, session) {
      eventReactive(input$submit, {
        data <- within(
          teal_data(),
          {
            dataset1 <- iris
            dataset2 <- mtcars
          }
        )
        datanames(data) <- c("dataset1", "dataset2")

        data
      })
    })
  }
)
> tdm
$ui
function(id) {
    ns <- NS(id)
    actionButton(ns("submit"), label = "Load data")
  }

$server
function(id) {
        data_out <- server(id)
        decorate_err_msg(
          assert_reactive(data_out),
          pre = sprintf("From: 'teal_data_module()':\nA 'teal_data_module' with \"%s\" label:", label),
          post = "Please make sure that this module returns a 'reactive` object containing 'teal_data' class of object." # nolint: line_length_linter.
        )
      }
<environment: 0x000001b695b02828>

attr(,"label")
[1] "data module"
attr(,"class")
[1] "teal_data_module"
attr(,"once")
[1] TRUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant