Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
support for add job retry and job cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
paselem committed Feb 22, 2017
1 parent 54cbaeb commit 63353ab
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions R/doAzureParallel.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,33 @@ getparentenv <- function(pkgname) {
assign('exportenv', exportenv, .doAzureBatchGlobals)
assign('packages', obj$packages, .doAzureBatchGlobals)

time <- format(Sys.time(), "%Y%m%d%H%M%S", tz = "GMT")
time <- format(Sys.time(), "%Y%m%d%H%M%OS3", tz = "GMT")
id <- sprintf("%s%s",
"job",
time)

addJob(id, config = data$config, packages = obj$packages)

retryCounter <- 0
maxRetryCount <- 5
while(retryCounter < maxRetryCount){

# try to submit the job. We may run into naming conflicts. If so, try again
tryCatch({
retryCounter <- retryCounter + 1
addJob(id, config = data$config, packages = obj$packages)
},
error=function(e) {
if (retryCounter == maxRetryCount) {
cat(sprintf('Error creating job: %s\n',
conditionMessage(e)))
}

time <- format(Sys.time(), "%Y%m%d%H%M%OS3", tz = "GMT")
id <- sprintf("%s%s",
"job",
time)
})
}

print("Job Summary: ")
job <- getJob(id)
Expand Down Expand Up @@ -255,6 +276,8 @@ getparentenv <- function(pkgname) {

print(sprintf("Number of errors: %i", numberOfFailedTasks))

deleteJob(id)

if (identical(obj$errorHandling, 'stop') && !is.null(errorValue)) {
msg <- sprintf('task %d failed - "%s"', errorIndex,
conditionMessage(errorValue))
Expand Down

0 comments on commit 63353ab

Please sign in to comment.