Skip to content

[Bug]: Functions with side effects are not detected as dependencies #278

@llrs-roche

Description

@llrs-roche

What happened?

Functions with side effects like options and set.seed are omitted on teal Show R code but they are needed to make the code reproducible:

data <- within(teal.data::teal_data(), { 
  ADSL <- teal.data::rADSL
  set.seed(1000)
  options(test = 1)
  ind <- sample(nrow(ADSL), 5)
  ADSL$STUDYID[ind] <- 1L
})

app <- teal::init(data = data, modules = teal::example_module())
runApp(app)

The code on apps will omit the second and third lines. But when user copies and pastes the code result will be different as it will use a different seed and the check step ( stopifnot(rlang::hash(ADSL) == "...) will fail.

srv_source_code() doesn't return those lines because on teal app because on the reactive module_teal_data of the module() function any code that is not a dependency of the data required is dropped (L468 of module_nested_tabs.R).

sessionInfo()

Relevant log output

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcore

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions