BatchTools integration?
We have been researching R tools for experiment storage/registry/metadata/job management/scale out. Been testing heavily the batchtools package. Very positive evaluation so far (amazing work), was wondering if it would be too complicated to add doAzureParallel support in batchtools. Pretty good match in job apis? Would be great to leverage doazureparallel for our experiments also.
example from the (local) docker swarm integration: https://rdrr.io/cran/batchtools/src/R/clusterFunctionsDocker.R makeClusterFunctionsDocker = function(image, docker.args = character(0L), image.args = character(0L), scheduler.latency = 1, fs.latency = 65) { # nocov start assertString(image) assertCharacter(docker.args, any.missing = FALSE) assertCharacter(image.args, any.missing = FALSE) user = Sys.info()["user"]
submitJob = function(reg, jc) { assertRegistry(reg, writeable = TRUE) assertClass(jc, "JobCollection") assertIntegerish(jc$resources$ncpus, lower = 1L, any.missing = FALSE, .var.name = "resources$ncpus") assertIntegerish(jc$resources$memory, lower = 1L, any.missing = FALSE, .var.name = "resources$memory") timeout = if (is.null(jc$resources$walltime)) character(0L) else sprintf("timeout %i", asInt(jc$resources$walltime, lower = 0L))
cmd = c("docker", docker.args, "run", "--detach=true", image.args,
sprintf("-e DEBUGME='%s'", Sys.getenv("DEBUGME")),
sprintf("-e OMP_NUM_THREADS=%i", jc$resources$threads %??% 1L),
sprintf("-e OPENBLAS_NUM_THREADS=%i", jc$resources$threads %??% 1L),
sprintf("-c %i", jc$resources$ncpus),
sprintf("-m %im", jc$resources$memory),
sprintf("--memory-swap %im", jc$resources$memory),
sprintf("--label batchtools=%s", jc$job.hash),
sprintf("--label user=%s", user),
sprintf("--name=%s_bt_%s", user, jc$job.hash),
image, timeout, "Rscript", stri_join("-e", shQuote(sprintf("batchtools::doJobCollection('%s', '%s')", jc$uri, jc$log.file)), sep = " "))
res = runOSCommand(cmd[1L], cmd[-1L])
if (res$exit.code > 0L) {
housekeeping(reg)
no.res.msg = "no resources available"
if (res$exit.code == 1L && any(stri_detect_fixed(res$output, no.res.msg)))
return(makeSubmitJobResult(status = 1L, batch.id = NA_character_, msg = no.res.msg))
return(cfHandleUnknownSubmitError(stri_flatten(cmd, " "), res$exit.code, res$output))
} else {
if (length(res$output != 1L)) {
matches = which(stri_detect_regex(res$output, "^[[:alnum:]]{64}$"))
if (length(matches) != 1L)
stopf("Command '%s' did not return a long UUID identitfier", stri_flatten(cmd, " "))
res$output = res$output[matches]
}
return(makeSubmitJobResult(status = 0L, batch.id = stri_sub(res$output, 1L, 12L)))
}
}
listJobs = function(reg, filter = character(0L)) { assertRegistry(reg, writeable = FALSE) # use a workaround for DockerSwarm: docker ps does not (...)