Skip to content

S3 method handlers are not exported automatically on R>4.0 #256

Closed
@Zhuk66

Description

@Zhuk66

The following code does not work with clustermq. It worked with R 3.5.3 and it works in sequential mode. It also works with doParallel but not with clustermq. I tested with multisession and SLURM backends. Both gave me an error:

Error in summarize_result(job_result, n_errors, n_warnings, cond_msgs, :
5/5 jobs failed (0 warnings). Stopping.
(Error #1) no applicable method for 'f' applied to an object of class "c('integer', 'numeric')"

library(future)
library(foreach)
library(clustermq)

f <- function(i) {
  UseMethod('f')
}

f.numeric <- function(i) {
  Sys.sleep(10)
  sqrt(i)
}
# It does not do anything
if(getRversion() >= "3.6.0") {
  .S3method('f', 'numeric', 'f.numeric')
}

ncores <- 12
memory <- 1024

options(clustermq.scheduler="multiprocess")

register_dopar_cmq(n_jobs=ncores, memory=memory) 
# registerDoSEQ()
res <- foreach(i=1:ncores) %dopar% { f(i) }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions