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

Warn when data contains an object named "all" #1379

Open
gogonzo opened this issue Oct 15, 2024 · 5 comments
Open

Warn when data contains an object named "all" #1379

gogonzo opened this issue Oct 15, 2024 · 5 comments
Labels

Comments

@gogonzo
Copy link
Contributor

gogonzo commented Oct 15, 2024

Because "all" is a reserved word in module(), otherwise this would be ambiguous.

@donyunardi
Copy link
Contributor

We try to prevent the confusion when module(datanames = "all")

Acceptance Criteria

  • teal should give a warning if there's an object in teal_data with name "all"
  • the app should still continue (currently it failed when teal_data has object name "all")

@averissimo
Copy link
Contributor

Teal is crashing with all. It seems related to lockfile generation

Running options("teal.lockfile.mode" = "disabled") before the code below allows the example module to work

data <- teal_data() |>
  within({
    all <- iris
  })

# data <- 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(),
#           {
#             all <- iris
#           }
#         )
#         data
#       })
#     })
#   }
# )


app <- init(
  data = data,
  modules = modules(
    example_module("Module with transformations 1", datanames = "all")
  ),
  title = "yada"
)

shinyApp(app$ui, app$server)

@gogonzo
Copy link
Contributor Author

gogonzo commented Oct 17, 2024

Works for me ;]

image image

@averissimo
Copy link
Contributor

Works after updating renv to v1.0.11 👍

@averissimo
Copy link
Contributor

averissimo commented Oct 18, 2024

.raw_data should also be considered a reserved word as it is being overwritten in the code.

pkgload::load_all("teal")
data <- teal.data::teal_data() |>
  within({
    all <- iris
    air <- datasets::airquality
    .raw_data <- mtcars
  })

app <- teal::init(
  data = data,
  modules = teal::example_module("Module 1", datanames = "all")
)

shiny::runApp(app)

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants