-
Notifications
You must be signed in to change notification settings - Fork 8
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
Adding %doFuture% parallel framework for the sim_gs_n.R code and upda… #249
Conversation
…ting associated tests.
Removed a commented out line of code that is not needed.
This comment was marked as resolved.
This comment was marked as resolved.
message("doFuture may exhibit suboptimal performance when using a doParallel backend.") | ||
} else { | ||
message("Backend uses sequential processing.") | ||
} |
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.
We should add test cases for both the doFuture and doParallel backends. I'm pretty sure the GitHub Actions machines have 2 cores available. And if we're worried about CRAN, we can always add skip_on_cran()
for these tests of the parallelization method
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 agree on adding tests. CRAN enforces the max 2 core policy strictly so to avoid any potential trouble, always using skip_on_cran()
is a good idea, just in case someone accidentally added something that used all cores.
Might be worth a brief mention in the vignette on parallelization that now |
This comment was marked as resolved.
This comment was marked as resolved.
…rror handling to "stop" in sim_fixed_n for parity.
…lobal parameters to avoid note from R CMD check. Adding test as an input to the foreach loop to handle the test in multisession Windows.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Confirmed. When I revert |
I confirmed the error handling behavior of library("future")
library("simtrial")
source("tests/testthat/helper-sim_gs_n.R")
ia1_test <- list(
test1 = create_test(wlr, weight = fh(rho = 0, gamma = 0)),
test2 = create_test(wlr, weight = fh(rho = 0, gamma = 0.5)),
test3 = create_test(rmst, tau = 20)
)
ia2_test <- list(
test1 = create_test(wlr, weight = fh(rho = 0, gamma = 0)),
test2 = create_test(wlr, weight = early_zero(6))
)
fa_test <- list(
test1 = create_test(wlr, weight = fh(rho = 0, gamma = 0)),
test3 = create_test(milestone, ms_time = 20)
)
sim_gs_n(
n_sim = 3,
sample_size = 400,
enroll_rate = test_enroll_rate(),
fail_rate = test_fail_rate(),
test = list(ia1 = ia1_test, ia2 = ia2_test, fa = fa_test),
cut = test_cutting()
)
## Backend uses sequential processing.
## Loading required package: foreach
## Error: attempt to apply non-function
plan("multisession")
sim_gs_n(
n_sim = 3,
sample_size = 400,
enroll_rate = test_enroll_rate(),
fail_rate = test_fail_rate(),
test = list(ia1 = ia1_test, ia2 = ia2_test, fa = fa_test),
cut = test_cutting()
)
## Using 16 cores with backend cluster
## Error: attempt to apply non-function |
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.
Looking good. Still needs some examples and tests of sim_gs_n()
running in parallel.
Also, given that updating sim_fixed_n()
is causing problems, maybe we should separate the sim_fixed_n()
updates into a separate PR.
I have reverted the Updating with a parallel example will come soon. |
Commit added with an example using parallel processing that will be skipped by CRAN similar to in |
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.
Great work @cmansch! I just had one minor comment about the test format, but I don't want to delay merging this PR. We can always address it in a future PR if desired
weight = fh(rho = 0, gamma = 0) | ||
) | ||
plan("sequential") | ||
expected <- data.frame( |
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.
Instead of hard-coding the expected output, you could instead set the seed again and run the exact same call to sim_gs_n()
in sequential mode. That would be more succinct and wouldn't require any manual updating if we update the output of sim_gs_n()
Thanks @cmansch for leading this pull request, and I extend my thanks to everyone who has contributed to this exceptional effort. I will proceed with merging it. |
Implementation for sim_gs_n() to have a parallel adaptor similar to sim_fixed_n() (xref: #110).
A seed is now set prior to the function call instead of passed as an argument.
Function now uses %doFuture% to run iterations of n_sim in parallel.
Addresses open issue (xref: #205).
Sequential backend still available (and default) to avoid any delays in development.
Please update "Remove seed argument from sim_gs_n() in (xref: Merck/gsDesign2#288) as part of the implementation.
New pull request created after (xref: #229) merged.
See old PR as (xref: #230)