Skip to content

Commit 1891762

Browse files
Properly import private functions => R CMD check with all OK
1 parent 1ae8a13 commit 1891762

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
_R_CHECK_SUGGESTS_ONLY_: true
3939
_R_CHECK_THINGS_IN_TEMP_DIR_: true
4040
_R_CHECK_TESTS_NLINES_: 300
41-
RCMDCHECK_ERROR_ON: warning
41+
RCMDCHECK_ERROR_ON: note
4242
## Specific to futures
4343
R_FUTURE_CONNECTIONS_ONMISUSE: "error[details=TRUE]"
4444
R_FUTURE_GLOBALENV_ONMISUSE: "error"

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: future.p2p
22
Title: A Peer-to-Peer Compute Cluster via Futureverse
3-
Version: 0.1.0-9014
3+
Version: 0.1.0-9015
44
Description: Implementation of the 'Future' API <doi:10.32614/RJ-2021-048> that resolves futures on a peer-to-peer ('P2P') compute environment. By using this future backend, you and your friends can share your spare compute resources with each other.
55
Depends:
66
future (>= 1.67.0)

R/pico_p2p.R

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,28 +298,41 @@ pico_p2p_hosted_clusters <- function(host = "pipe.pico.sh", ssh_args = NULL, tim
298298
#' @importFrom utils file_test
299299
pico_p2p_dispatch_future <- function(future) {
300300
send_future <- function(topic, name, host = host, ssh_args = ssh_args, future_id, file, to, via, duration) {
301-
pico <- future.p2p:::pico_pipe(topic, user = name, host = host, ssh_args = ssh_args)
302-
m <- future.p2p:::pico_p2p_hello(pico, type = "client")
301+
## Import private pico_nnn() functions, because this function
302+
## is run as-is on the parallel worker
303+
import_future.p2p <- function(name, mode = "function", envir = getNamespace("future.p2p"), inherits = FALSE) {
304+
get(name, envir = envir, mode = mode, inherits = inherits)
305+
}
306+
307+
pico_pipe <- import_future.p2p("pico_pipe")
308+
pico_p2p_hello <- import_future.p2p("pico_p2p_hello")
309+
pico_p2p_have_future <- import_future.p2p("pico_p2p_have_future")
310+
pico_p2p_wait_for <- import_future.p2p("pico_p2p_wait_for")
311+
pico_p2p_send_future <- import_future.p2p("pico_p2p_send_future")
312+
pico_p2p_receive_result <- import_future.p2p("pico_p2p_receive_result")
313+
314+
pico <- pico_pipe(topic, user = name, host = host, ssh_args = ssh_args)
315+
m <- pico_p2p_hello(pico, type = "client")
303316

304317
## 2. Announce future
305318
repeat {
306-
m1 <- future.p2p:::pico_p2p_have_future(pico, future = file, duration = duration)
307-
m2 <- future.p2p:::pico_p2p_wait_for(pico, type = "offer", futures = m1[["future"]], expires = m1[["expires"]])
319+
m1 <- pico_p2p_have_future(pico, future = file, duration = duration)
320+
m2 <- pico_p2p_wait_for(pico, type = "offer", futures = m1[["future"]], expires = m1[["expires"]])
308321
if (m2[["type"]] != "expired") break
309322
}
310323

311324
## 3. Send future to workers
312325
worker <- m2[["from"]]
313326
stopifnot(is.character(worker), nzchar(worker))
314-
m3 <- future.p2p:::pico_p2p_send_future(pico, future = file, to = worker, via = via)
327+
m3 <- pico_p2p_send_future(pico, future = file, to = worker, via = via)
315328

316329
## 4. Remove temporary file
317330
file.remove(file)
318331

319332
## 5. Wait for and receive FutureResult file
320333
path <- file.path(dirname(dirname(file)), "results")
321334
tryCatch({
322-
file <- future.p2p:::pico_p2p_receive_result(pico, via = via, path = path)
335+
file <- pico_p2p_receive_result(pico, via = via, path = path)
323336
}, interrupt = function(int) {
324337
cat(file = "foo.log", "interrupted\n")
325338
})

0 commit comments

Comments
 (0)