1- # ' pico_p2p futures
1+ # ' p2p futures
22# '
33# ' _WARNING: This function must never be called.
44# ' It may only be used with [future::plan()]_
55# '
6- # ' A 'pico_p2p ' future is an asynchronous multiprocess
6+ # ' A 'p2p ' future is an asynchronous multiprocess
77# ' future that will be evaluated in a background R session.
88# '
99# ' @inheritParams pico_pipe
2323# ' being invited to a shared folder.
2424# '
2525# ' Users who wish to contribute their compute power to the P2P cluster
26- # ' should call [pico_p2p_worker ()].
26+ # ' should call [worker ()].
2727# '
2828# ' Users who wish to take advantage of the compute power of the
29- # ' P2P cluster should use `plan(pico_p2p )`.
29+ # ' P2P cluster should use `plan(future.p2p::cluster )`.
3030# '
3131# ' @examplesIf interactive()
32- # ' ## Futures are pushed to the Pico P2P cluster and
33- # ' ## results are collected from there
34- # ' plan(future.p2p::pico_p2p, .init = FALSE)
32+ # ' # Connect to personal P2P cluster, which is automatically launched
33+ # ' plan(future.p2p::cluster)
3534# '
3635# ' ## Create future
3736# ' a <- 42
4746# '
4847# ' @importFrom future future
4948# ' @export
50- pico_p2p <- function (cluster = p2p_cluster(), name = p2p_name(), host = " pipe.pico.sh" , ssh_args = NULL , ... ) {
51- stop(" INTERNAL ERROR: The future.p2p::pico_p2p() must never be called directly" )
49+ cluster <- function (cluster = p2p_cluster(), name = p2p_name(), host = " pipe.pico.sh" , ssh_args = NULL , ... ) {
50+ stop(" INTERNAL ERROR: The future.p2p::cluster() function must never be called directly" )
5251}
53- class(pico_p2p ) <- c(" pico_p2p" , " multiprocess" , " future" , " function" )
54- attr(pico_p2p , " init" ) <- TRUE
52+ class(cluster ) <- c(" pico_p2p" , " multiprocess" , " future" , " function" )
53+ attr(cluster , " init" ) <- TRUE
5554
5655
5756# ' A Pico P2P future is resolved through a Peer-to-Peer (P2P) workers communicating via pico.sh and Wormhole
5857# '
59- # ' @inheritParams pico_p2p
58+ # ' @inheritParams cluster
6059# '
6160# ' @param \ldots Additional arguments passed to [future::FutureBackend()].
6261# '
@@ -107,7 +106,7 @@ PicoP2PFutureBackend <- function(cluster = p2p_cluster(), name = p2p_name(), hos
107106
108107 core
109108}
110- attr(pico_p2p , " factory" ) <- PicoP2PFutureBackend
109+ attr(cluster , " factory" ) <- PicoP2PFutureBackend
111110
112111
113112
@@ -177,7 +176,7 @@ nbrOfFreeWorkers.PicoP2PFutureBackend <- function(evaluator = NULL, background =
177176# ' It will always return at least one worker, which is yourself.
178177# ' _WARNING: This is currently hardcoded to 10 workers, regardless of the number._
179178# '
180- # ' @rdname pico_p2p
179+ # ' @rdname cluster
181180# ' @export
182181availablePicoP2PWorkers <- function () {
183182 nworkers <- 10L
@@ -302,7 +301,10 @@ print.PicoP2PFutureBackend <- function(x, ...) {
302301 cat(sprintf(" P2P clusters you are hosting: [n=%d]\n " , nrow(clusters )))
303302 for (kk in seq_len(nrow(clusters ))) {
304303 cluster <- clusters [kk , ]
305- cat(sprintf(" %2d. %s (%s)\n " , kk , cluster $ name , cluster $ users ))
304+ users <- strsplit(cluster $ users , split = " ," , fixed = TRUE )[[1 ]]
305+ users <- unique(c(users , pico_username()))
306+ users <- paste(users , collapse = " , " )
307+ cat(sprintf(" %2d. %s (users: %s)\n " , kk , sQuote(cluster $ name ), users ))
306308 }
307309
308310 cat(" Message board:\n " )
@@ -321,7 +323,7 @@ print.PicoP2PFutureBackend <- function(x, ...) {
321323}
322324
323325
324- p2p_can_connect <- function (cluster , name = name , host = " pipe.pico.sh" , ssh_args = NULL , timeout = 10.0 ) {
326+ p2p_can_connect <- function (cluster , name = p2p_name() , host = " pipe.pico.sh" , ssh_args = NULL , timeout = 10.0 ) {
325327 cluster_owner <- dirname(cluster )
326328 if (cluster_owner == pico_username()) {
327329 topic <- sprintf(" %s/future.p2p" , basename(cluster ))
0 commit comments