-
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
Deterministic seeded random streams across runs #194
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d5c03f2
Create failing test
jkrumbiegel c12ff3b
simplify
jkrumbiegel 8b3ea0a
feed all eval requests through a single channel
jkrumbiegel 212724c
formatting
jkrumbiegel 7336afe
`var"` macros not necessary after all
jkrumbiegel ce3d265
typos
jkrumbiegel 24a7eff
catch errors not seen locally to understand CI failures better
jkrumbiegel 102fe6d
add env to make `Random` available
jkrumbiegel 393b3e3
formatting
jkrumbiegel ae3a300
remove copypasted code that unnecessarily created a new notebook file…
jkrumbiegel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[deps] | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: Random seed | ||
--- | ||
|
||
```{julia} | ||
using Random | ||
Random.seed!(123) | ||
rand() | ||
``` | ||
|
||
```{julia} | ||
rand() | ||
``` | ||
|
||
```{julia} | ||
rand() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
include("../utilities/prelude.jl") | ||
|
||
@testset "seeded random numbers are consistent across runs" begin | ||
notebook = joinpath(@__DIR__, "../examples/random_seed/random_seed.qmd") | ||
|
||
server = QuartoNotebookRunner.Server() | ||
|
||
jsons = map(1:2) do _ | ||
QuartoNotebookRunner.run!(server, notebook; showprogress = false) | ||
end | ||
|
||
_output(cell) = only(cell.outputs).data["text/plain"] | ||
|
||
@test tryparse(Float64, _output(jsons[1].cells[2])) !== nothing | ||
@test tryparse(Float64, _output(jsons[1].cells[4])) !== nothing | ||
@test tryparse(Float64, _output(jsons[1].cells[6])) !== nothing | ||
|
||
@test length(unique([_output(jsons[1].cells[i]) for i in [2, 4, 6]])) == 3 | ||
|
||
@test _output(jsons[1].cells[2]) == _output(jsons[2].cells[2]) | ||
@test _output(jsons[1].cells[4]) == _output(jsons[2].cells[4]) | ||
@test _output(jsons[1].cells[6]) == _output(jsons[2].cells[6]) | ||
|
||
close!(server) | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think QuartoNotebookWorker has its own error handling, but you may want to catch errors from this call to prevent future
put!(stable_execution_task_channel_in, ...)
to fail after an exception.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm yes I might have to think about what to do in this case, but for normal notebook usage, barring bugs in QuartoNotebookRunner, the error handling inside the passed expressions should be sufficient (as indicated by the test suite passing). Of course it would be nicer if in case of bugs, the behavior was still somewhat robust