Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@be-marc
Copy link
Member

@be-marc be-marc commented Apr 15, 2025

No description provided.

@be-marc be-marc requested a review from sebffischer April 15, 2025 12:07
# 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)
Copy link
Member

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.

Copy link
Member Author

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)) {
Copy link
Member

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?

Copy link
Member Author

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.

@be-marc be-marc requested a review from Copilot May 22, 2025 15:09
Copy link
Contributor

Copilot AI left a 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 handle method = "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 (Rd and roxygen) and DESCRIPTION to include .compute parameter 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 try method is not documented in the \value section; add an item describing how errors and return values are handled when method = "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", {

@be-marc be-marc merged commit a0d2158 into main May 23, 2025
3 checks passed
@be-marc be-marc deleted the mirai branch May 23, 2025 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants