[Discussion]: Handling operations that use/modify RNG
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Iniziate con i percorsi del codice within e teal.code::eval_code, quindi seguite il modo in cui get_code(names = ...) e il parser del codice costruiscono codice parziale. Leggete issue 278 e i riferimenti RNG collegati per comprendere il tracciamento dei seed e la riproducibilità. Il lavoro può dirsi concluso quando i contributori concordano e implementano una policy riproducibile per le operazioni casuali nell’esecuzione di codice parziale.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What is your question?
Per discussion with @llrs-roche, here are some topics for the contributors to discuss and research.
Problem
Random/stoichastic operations are not being well handled in within/teal.code::eval_code, in particular when code parse is being used.
In the section below you can observe that q |> get_code(names = "IRIS") is not fully reproducible as the random operations before were not included, nor was the RNG state updated before code execution
Reproducible code
This code highlights the 2 main problems:
set.seed()and other random operations are not kept in partial code (q |> get_code(names = "XXX"))MTCARS/IRISrandom operations are influenced by preceding code
library(teal.code)
q <- qenv() |>
within({
IRIS <- datasets::iris
MTCARS <- datasets::mtcars
set.seed(1)
.random <- runif(1)
IRIS$new <- runif(nrow(IRIS))
MTCARS$new <- runif(nrow(MTCARS))
})
q |> get_code() |> cat()
#> iris <- datasets::iris
#> mtcars <- datasets::mtcars
#> set.seed(1)
#> .random <- runif(1)
#> iris$new <- runif(nrow(iris))
#> mtcars$new <- runif(nrow(mtcars))
q |> get_code(names = "IRIS") |> cat()
#> IRIS <- datasets::iris
#> IRIS$new <- runif(nrow(IRIS))
local({
eval(str2expression(q |> get_code(names = "IRIS")))
q$IRIS |> rlang::hash() |> cat("# hash qenv IRIS\n")
IRIS |> rlang::hash() |> cat("# hash reproduced IRIS\n")
})
#> 9bba33c8ed5cd90cd13316f35f812f55 # hash qenv IRIS
#> c90a89c1814206bc19fdc32d04d1eefa # hash reproduced IRIS
q |> get_code(names = "MTCARS") |> cat()
#> MTCARS <- datasets::mtcars
#> MTCARS$new <- runif(nrow(MTCARS))
local({
eval(str2expression(q |> get_code(names = "MTCARS")))
q$mtcars |> rlang::hash() |> cat("# hash qenv MTCARS\n")
mtcars |> rlang::hash() |> cat("# hash reproduced MTCARS\n")
})
#> 2c0a8a99dc147d5445c3b49d035665b2 # hash qenv MTCARS
#> 6755d143ff87b73a1196c186cec7e86a # hash reproduced MTCARS
Reference material
- ref1: https://github.com/insightsengineering/teal.code/issues/278
- ref2: https://www.jottr.org/2020/09/21/detect-when-the-random-number-generator-was-used/
- Detect when random seed is modified
- ref3: https://blog.djnavarro.net/posts/2023-12-27_seedcatcher/
Possible set of solutions
- Use
teal.code::eval_code()and# @linksto XXXXXto include random operations- Status quo
- Cons: Requires character base code execution and requires manual maintenance
- Detect random seed at start and inform user
- Track random seed and incorporate it in code execution
- When using code parser, re-run partial code to sync modules with reproducible code (while keeping
set.seed()expressions)- cons: slow down teal app even more and data is not consistent with initial
dataargument in teal.
- cons: slow down teal app even more and data is not consistent with initial
- Always include
set.seed()expression and hope it doesn't have a big impact
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.
- Lingua principale
- R
- Stelle
- 12
- Fork
- 12
- Merge medio
- 4g 22h
- PR unite (30g)
- 3
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pharmaverse/teal.code
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
pharmaverse/teal.code#305 ·
-
[Feature Request]: High cyclomatic complexity leds to bad readabilityForse già presa @llrs-roche l’ha presa 87 giorni fa. Apertaenhancement
Difficoltà 3/5 3-5 giorni Idoneità per principianti 45/100
pharmaverse/teal.code#295 ·
-
bug core
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
pharmaverse/teal.code#275 ·
-
This is test issue to test copilot capabilitiesForse già presa @copilot-swe-agent l’ha presa 484 giorni fa. Apertabug
pharmaverse/teal.code#266 · 1 reazione · 1 assegnatario ·
-
core enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
pharmaverse/teal.code#204 ·
Tutte le issue di pharmaverse/teal.code
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
Bioconductor/BiocParallel#289 ·
-
automation
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
waldronlab/BugSigDBcuration#2224 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
merliseclyde/BAS#118 ·