-
Notifications
You must be signed in to change notification settings - Fork 10
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
debugme sets .Random.seed on load #50
Comments
Same exercise when I downgrade shows no
|
Interestingly, I'm only seeing the new test failure locally. Even though GHA is using pillar v1.5.0, the test doesn't fail there. That makes me more convinced this is related to debugme, which is not available in my GHA session.
|
Yeah it's this, which eventually gets called whenever the debugme namespace is loaded:
|
I am not sure if this a problem. Packages are allowed to use the rng, no? If you need full reproducibility then you need to pin down the optional dependencies. Ie. either always run with debugme or always run without it. |
At this point, I've formed the impression that it's best practice not to do this. Thinking back to when ggplot2 used to touch the rng with its startup message thing, people got irritated (because, yeah, it did cause reproducibility problems that were hard to debug). So they stopped: In my case, reprex suggests styler which imports tibble which imports pillar which loads debugme in |
(And, of course, this is again related to the evaluation and leakage problems we've discussed elsewhere.) |
With the recent pillar release, this will affect every package, data analysis, etc. that uses tibble, I think. |
Only slightly related: I've been considering enabling and disabling debugme by doing text substitution in the For now we could call |
Let's assume I should deal with my reprex test issue, one way or another, which I can. I still think it will be noticed, sooner rather than later, that |
We can fix this in debugme, probably that is the best, because it will come up again. OTOH I don't think people can rely on packages not touching the random seed. If they want reproducibility, they have to use the same package versions, including optional packages. There is no other way. Also, debugme_fun <- function() {
withr::with_preserve_seed({
sample(1:5)
})
}
debugme_fun()
#> [1] 5 4 3 1 2
debugme_fun()
#> [1] 5 4 3 1 2 Which can be pretty bad if you are supposed to generate some random id or file name. |
Agreed. I think it's different though, if merely loading a package's namespace can touch the seed. Because that can happen in very invisible and indirect ways. Like in my case, where pillar's decision to use debugme affects reprex. Even if you think it's fine, I think we know from the ggplot2 story, it's going to cause someone pain and, once they figure out who to "blame", they aren't happy 😅 I think devtools::load_all(".")
#> ℹ Loading reprex
head(adjective_animal)
#> [1] "soot-cub" "fishy-coral" "cushy-kitty" "legal-mink" "surly-egg"
#> [6] "beton-pug"
devtools::load_all(".")
#> ℹ Loading reprex
head(adjective_animal)
#> [1] "surly-egg" "beton-pug" "fussy-agama" "jolly-bass" "legal-mink"
#> [6] "rude-stud" Created on 2021-02-26 by the reprex package (v1.0.0.9002) |
Only if there is no random seed. If there is one, then you just always start with that one, and there is no randomness. Which might be what you want, I don't know:
|
I think the typical user of reprex is not going to see the same reprex slug all the time, given how real-world usage actually happens. Personally, I attach it |
I just transferred this from pillar, which is how it came into my life. But once I dug around, it became clear debugme was touching
.Random.seed
upon load. That explains why I talk about pillar a lot.I picked this up because of some tests in reprex re: environment hygiene.
Something new in pillar touches the random seed, presumably something in
.onLoad()
.Once you figure out what it is, hopefully you can make it not so or put it inside
withr::with_preserve_seed()
. I don't see an obvious culprit, so is it debugme?The text was updated successfully, but these errors were encountered: