-
-
Couldn't load subscription status.
- Fork 4
feat: add mirai as encapsulation method #134
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
Conversation
| # restore RNG state from parent R session | ||
| if (!is.null(.rng_state)) assign(".Random.seed", .rng_state, envir = globalenv()) | ||
|
|
||
| result = mlr3misc::invoke(.f, .args = .args, .opts = .opts, .seed = .seed) |
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.
either we include mlr3misc in .pgs or we use do.call here.
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.
Is there an advantage to loading the whole package? With invoke we can pass the seeds and opts nicely.
| result = result$result | ||
| } | ||
|
|
||
| if (is.null(log)) { |
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.
Do we capture warnings with other encapsulation methods?
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.
Yes the other methods record warnings. Recording warnings with mirai is the only thing missing now.
Co-authored-by: Sebastian Fischer <[email protected]>
Co-authored-by: Sebastian Fischer <[email protected]>
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.
Pull Request Overview
Adds support for the new “mirai” backend for encapsulation, updating code, tests, and docs.
- Extend
encapsulate()to handlemethod = "mirai", including RNG handling, timeouts, and optional daemon reuse - Update tests to cover mirai for core behaviors (results, errors, segfaults, timeouts, RNG, seeding, daemon control)
- Revise documentation (
Rdand roxygen) and DESCRIPTION to include.computeparameter and mirai in imports
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/testthat/test_encapsulate.R | Added mirai to most test loops and new mirai-specific tests |
| man/encapsulate.Rd | Documented new .compute argument and mirai method |
| R/encapsulate.R | Extended encapsulate() with a mirai branch |
| DESCRIPTION | Added mirai to Imports |
Comments suppressed due to low confidence (3)
man/encapsulate.Rd:64
- The
trymethod is not documented in the\valuesection; add an item describing how errors and return values are handled whenmethod = "try".
\item{\code{"callr"}}: Uses the package \CRANpkg{callr} to call the function, measure time and do the logging.
tests/testthat/test_encapsulate.R:25
- Include
"mirai"in this loop so that messages and warnings are also tested for the mirai backend.
for (method in c("evaluate", "callr")) {
tests/testthat/test_encapsulate.R:198
- [nitpick] The test name suggests the daemon should remain running, but it actually asserts zero connections; consider renaming to reflect that mirai uses ephemeral daemons by default.
test_that("mirai daemon is started if not running", {
Co-authored-by: Copilot <[email protected]>
No description provided.