Skip to content

[Feature Request]: More information showed about reasons why transofmrator failed #1518

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

Open
3 tasks done
strebuh opened this issue Apr 25, 2025 · 4 comments
Open
3 tasks done
Labels
core enhancement New feature or request

Comments

@strebuh
Copy link

strebuh commented Apr 25, 2025

Feature description

When trying to transform output of the tm_variable_browser module instead of the ouptut I just get:
"One of the transformators failed. Please check its inputs." , console doesn't show any error.

Image

It would be very helpful to have more information about error.

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.
@strebuh strebuh added the enhancement New feature or request label Apr 25, 2025
@vedhav
Copy link
Contributor

vedhav commented Apr 25, 2025

@strebuh Could you provide the app code you used? It looks like the issue is in the teal_transform_moduleobject. So, having a look at that would help in testing this during feature development.

@vedhav
Copy link
Contributor

vedhav commented Apr 25, 2025

I will also point out that there is a work in progress for creating a modular validation in PR #1509 which will provide some more clarity.

@strebuh
Copy link
Author

strebuh commented Apr 25, 2025

sure, the let it be this:

`%>%` <- purrr::`%>%`

transformator_wbr <- teal::teal_transform_module(
  label = "Select scope of data",
  ui = function(id) {
    ns <- NS(id)
    tags$div(
      radioButtons(inputId = ns("dataScope"), label="", choices = c("all", "ignore constans", "ignore empty", "ignore constans and empty"), selected = "ignore constans and empty",
                   inline = FALSE,
                   width = NULL)
    )
  },
  server = function(id, data) {
    moduleServer(id, function(input, output, session) {
      print("data transformator")
      reactive({
        within(
          data(),
          {
            if(scope == "ignore constans and empty") {
              iris <- iris  %>% dplyr::select(dplyr::where(~dplyr::n_distinct(.) > 1)) %>% dplyr::select_if(colSums(!is.na(.)) > 0)
            } else if(scope == "ignore constans") {
              iris <- iris  %>% dplyr::select(where(~dplyr::n_distinct(.) > 1))
            } else if(scope == "ignore empty") {
              iris <- iris %>% dplyr::select_if(colSums(!is.na(.)) > 0)
            } else {
              iris <- iris
            }
          },
          scope = input$dataScope
        )
      })
    })
  }
)

main_plot_decorator <- teal::teal_transform_module(
  label = "Static decorator",
  server = function(id, data) {
    moduleServer(id, function(input, output, session) {
      print("data transformator")
      reactive({
        req(data())
        within(data(), {
          if(inherits(variable_plot_r, c("ggplot", "grob", "trellis", "Heatmap"))){
            main_plot <- main_plot +
            # variable_plot_r <- variable_plot_r +
                ggplot2::scale_fill_manual(values = c("red", "tan"))
          }
        })
      })
    })
  }
)


run_uivr_app <- function() {
  app <- teal::init(
    data = teal.data::teal_data(iris = iris %>% 
                                  dplyr::mutate(random = sample(
                                    c("alfa", "beta", "gamma"), nrow(.), replace = TRUE))
                                ),
    modules = teal::modules(
      teal.modules.general::tm_data_table(
        label = "Report", 
        datasets_selected = "iris",   
        dt_args = list(extensions = c("Buttons", "ColReorder", "FixedHeader", "SearchPanes")),
        dt_options = list(
          searching = FALSE,
          pageLength = 30,
          lengthMenu = c(5, 15, 25, 50, 100),
          scrollX = FALSE,
          dom = "lBrtip",
          buttons = c( "copy", "csv", "excel", "pdf"),
          colReorder = TRUE,
          fixedHeader = TRUE
        )),
      teal.modules.general::tm_variable_browser(dataname = "iris", parent_dataname = "iris",         
                                                ggplot2_args = teal.widgets::ggplot2_args(labs = list(y = "# of Variable", x = NULL)),
                                                transformators = list(transformator_wbr, main_plot_decorator)) # 
    )
  )
  shiny::shinyApp(ui = app$ui, server = app$server)
}

run_uivr_app()

@m7pr
Copy link
Contributor

m7pr commented Apr 25, 2025

I think this is related to this question insightsengineering/teal.modules.general#873
tm_variable_browser doesn't support decorators. In your decorator you try to change main_plot object created inside the module, but this module doesn't handle such object.

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

4 participants