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

[Bug]: datanames code and environment don't match under edge case #1390

Open
3 tasks done
averissimo opened this issue Oct 21, 2024 · 0 comments
Open
3 tasks done

[Bug]: datanames code and environment don't match under edge case #1390

averissimo opened this issue Oct 21, 2024 · 0 comments
Labels
bug Something isn't working core

Comments

@averissimo
Copy link
Contributor

What happened?

Possible Edge case:

  • App developer uses object in pre-processing
    • Such as a function
  • datanames ≠ "all" (is NOT set to all)
  • 🔴 Data passed to module has discrepancy in code / "content of qenv"
    • pre-processing objects used to generate datanames are not included

In the sample app (code below) we can observe this when comparing ls(data(), all.names = TRUE) and get_code(data())

note: cbind is also not store in .raw_data

image

Sample App code

pkgload::load_all("teal")
library(teal)
data <- teal_data() |>
  within({
    iris <- iris
    mtcars <- mtcars
    new_column <- data.frame(what = "new_column")
    cbind2 <- function(lhs, rhs) cbind(lhs, rhs)
    iris <- cbind2(iris, data.frame(new_column))
  })

app <- init(
  data = data,
  modules = module(
    ui = function(id) {
      shiny::tagList(
        shiny::tags$h3("Code in module"),
        shiny::verbatimTextOutput(shiny::NS(id, "code")),
        shiny::tags$h3("Contents of data() in module"),
        shiny::verbatimTextOutput(shiny::NS(id, "contents")),
        
        example_module()$ui(id)
      )
    },
    server = function(id, data) {
      moduleServer(id, function(input, output, session) {
        output$contents <- renderText({
          paste(
            "Available variables in the qenv env:",
            paste(ls(teal.code::get_env(data()), all.names = TRUE), collapse = ", ")
          )
        })
        output$code <- renderText({
          teal.code::get_code(data()) |> paste(collapse = "\n")
        })
      })
      example_module()$server(id, data)
    },
    datanames = "iris"
  )
)

shiny::runApp(app)

sessionInfo()

No response

Relevant log output

No response

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core
Projects
None yet
Development

No branches or pull requests

1 participant