insightsengineering / teal

Exploratory Web Apps for Analyzing Clinical Trial Data
https://insightsengineering.github.io/teal/
Other
176 stars 35 forks source link

[Bug]: `future` warning #1249

Closed chlebowa closed 1 week ago

chlebowa commented 3 months ago

What happened?

After creating an app with init, a future-related warning is raised whn evaluating another expression after a while, but not immediately. Most liekly when the teal_app.lock file is created.

example ``` > library(teal) Loading required package: shiny Loading required package: teal.data Loading required package: teal.code Loading required package: teal.slice Registered S3 method overwritten by 'teal': method from c.teal_slices teal.slice You are using teal version 0.15.2.9045 Attaching package: 'teal' The following objects are masked from 'package:teal.slice': as.teal_slices, teal_slices > data <- teal_data() |> + within(iris <- iris) |> + within(mtcars <- mtcars) > datanames(data) <- c("iris", "mtcars") > modules <- modules( + example_module("Example One"), + example_module("Example Two", "mtcars") + ) > filter <- teal_slices( + teal_slice("iris", "Species", choices = c("virginica", "versicolor"), sele$ + teal_slice("mtcars", "cyl", selected = 6), + module_specific = TRUE, + mapping = list( + "Example Two" = "mtcars cyl", + "global_filters" = "iris Species" + ) + ) > app <- init(data, modules, filter) > head(letters) [1] "a" "b" "c" "d" "e" "f" > Sys.sleep(30) > head(letters) [1] "a" "b" "c" "d" "e" "f" Warning message: UNRELIABLE VALUE: Future ('') unexpectedly generated random numbers without specifying argument 'seed'. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify 'seed=TRUE'. This ensures that proper, parallel-safe random numbers are produced via the L'Ecuyer-CMRG method. To disable this check, use 'seed=NULL', or set option 'future.rng.onMisuse' to "ignore". > ```

30 seconds is sufficient on my machine but it may take longer (e.g. in my Posit Connect environment).

sessionInfo()

> packageVersion("teal")
[1] ‘0.15.2.9045’

Relevant log output

Warning message:
UNRELIABLE VALUE: Future ('<none>') unexpectedly generated random numbers without specifying 
argument 'seed'. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify 'seed=TRUE'. This ensures that proper, parallel-safe random numbers are produced via the L'Ecuyer-CMRG method. To disable this check, use 'seed=NULL', or set option 'future.rng.onMisuse' to "ignore".

Code of Conduct

Contribution Guidelines

Security Policy

donyunardi commented 3 months ago

I agree with your investigation. options(future.rng.onMisuse = "ignore") will remove the warning but this is not a long term solution. adding to backlog.

m7pr commented 3 months ago

I think this will be removed as we will replace future with callr in here https://github.com/insightsengineering/teal/pull/1255

chlebowa commented 3 months ago

Excellent 👌

m7pr commented 2 months ago

If not with #1255 then maybe with another alternative https://github.com/insightsengineering/teal/pull/1263

chlebowa commented 1 week ago

@m7pr Correct, the warning no longer appears in 0.15.2.9064.