Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelru committed Jul 5, 2024
1 parent cc5a077 commit 5f5a432
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
1 change: 0 additions & 1 deletion .github/workflows/rhub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
name: R-hub
uses: insightsengineering/r.pkg.template/.github/workflows/rhub.yaml@test-rhub-workflows
with:
config: 'r-devel-linux-x86_64-debian-clang,r-devel-linux-x86_64-debian-gcc,r-patched-linux-x86_64,r-release-linux-x86_64,ATLAS,C23,clang-ASAN,clang16,clang17,clang18,clang19,gcc13,gcc14,noLD,valgrind,MKL,Intel,donttest,noSuggests,rchk,r-devel-windows-x86_64,r-release-windows-x86_64,r-oldrel-windows-x86_64,r-devel-windows,r-release-windows,r-oldrel-windows,r-release-macos-x86_64,r-oldrel-macos-x86_64,r-release-macos-arm64,r-oldrel-macos-arm64,linux'
lookup-refs: |
insightsengineering/teal.code
insightsengineering/teal.data
Expand Down
26 changes: 9 additions & 17 deletions R/teal_lockfile.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,22 @@ teal_lockfile <- function() {
}

if (!(is_in_test() || is_r_cmd_check())) {
old_plan <- future::plan()
# If there is already a parallel (non-sequential) backend, reuse it.
if (inherits(old_plan, "sequential")) {
future::plan(future::multisession, workers = 2)
current_plan <- future::plan()
# If there is already a tweaked plan - don't change it.
if (!inherits(current_plan, "tweaked")) {
new_plan <- future::plan(future::multisession, workers = 2)
shiny::onStop(function() future::plan(new_plan))
}

lockfile_task <- ExtendedTask$new(create_renv_lockfile)
lockfile_task$invoke(close = inherits(old_plan, "sequential"), lockfile_path)
lockfile_task$invoke(lockfile_path)
logger::log_trace("lockfile creation invoked.")
}
}

create_renv_lockfile <- function(close = FALSE, lockfile_path = NULL) {
checkmate::assert_flag(close)
create_renv_lockfile <- function(lockfile_path = NULL) {
checkmate::assert_string(lockfile_path, na.ok = TRUE)
promise <- promises::future_promise({
# Below we can not use a file created in tempdir() directory.
promises::future_promise({
# If a file is created in tempdir(), it gets deleted on 'then(onFulfilled' part.
shiny::onStop(function() file.remove(lockfile_path))

Expand All @@ -75,14 +74,7 @@ create_renv_lockfile <- function(close = FALSE, lockfile_path = NULL) {
}

lockfile_path
})
if (close) {
# If the initial backend was only sequential, bring it back.
promises::then(promise, onFulfilled = function() {
future::plan(future::sequential)
})
}
promise
}, seed = NULL)
}

teal_lockfile_downloadhandler <- function() {
Expand Down

0 comments on commit 5f5a432

Please sign in to comment.