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

Commit 08e8943

Browse files
committed
add terminateJob
1 parent b4248cf commit 08e8943

File tree

4 files changed

+46
-2
lines changed

4 files changed

+46
-2
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ export(setHttpTraffic)
2323
export(setReduce)
2424
export(setVerbose)
2525
export(stopCluster)
26+
export(terminateJob)
2627
export(waitForNodesToComplete)
2728
export(waitForTasksToComplete)

R/utility.R

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,30 @@ deleteJob <- function(jobId, deleteResult = TRUE) {
8484
}
8585
}
8686

87+
#' Terminate a job
88+
#'
89+
#' @param jobId A job id
90+
#'
91+
#' @examples
92+
#' \dontrun{
93+
#' terminateJob("job-001")
94+
#' }
95+
#' @export
96+
terminateJob <- function(jobId) {
97+
response <- rAzureBatch::terminateJob(jobId, content = "response")
98+
99+
if (response$status_code == 202) {
100+
cat(sprintf("Your job '%s' has been terminated.", jobId),
101+
fill = TRUE)
102+
} else if (response$status_code == 404) {
103+
cat(sprintf("Job '%s' does not exist.", jobId),
104+
fill = TRUE)
105+
} else if (response$status_code == 409) {
106+
cat(sprintf("Job '%s' has already completed.", jobId),
107+
fill = TRUE)
108+
}
109+
}
110+
87111
#' Get a list of job statuses from the given filter
88112
#'
89113
#' @param filter A filter containing job state

man/deleteJob.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/terminateJob.Rd

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)