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

Commit 11f6484

Browse files
committed
handle various corner cases
1 parent 08e8943 commit 11f6484

File tree

2 files changed

+48
-27
lines changed

2 files changed

+48
-27
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
# Change Log
2+
## [0.5.2] 2017-10-30
3+
### Added
4+
- Support for users to delete job and terminate job
5+
### Changed
6+
- Add retry to get job result
7+
- Add errorHandling and wait option to job metadata
8+
- Save job metadata to job result storage blob
9+
210
## [0.5.1] 2017-09-28
311
### Added
412
- Support for users to get job and job results for long running job

R/utility.R

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,24 @@ getJobResult <- function(jobId) {
426426
}
427427

428428
# if the job has failed task
429-
if (job$tasks$failed > 0 && metadata$errorHandling == "stop") {
430-
stop(
431-
sprintf(
432-
"job %s has failed tasks and error handling is set to 'stop', no result will be avaialble",
433-
job$jobId
429+
if (job$tasks$failed > 0) {
430+
if (metadata$errorHandling == "stop") {
431+
stop(
432+
sprintf(
433+
"job %s has failed tasks and error handling is set to 'stop', no result will be avaialble",
434+
job$jobId
435+
)
434436
)
435-
)
437+
} else {
438+
if (job$tasks$succeeded == 0) {
439+
stop(
440+
sprintf(
441+
"all tasks failed for job %s, no result will be avaialble",
442+
job$jobId
443+
)
444+
)
445+
}
446+
}
436447
}
437448
}
438449

@@ -461,15 +472,12 @@ getJobResult <- function(jobId) {
461472

462473
if (is.vector(results)) {
463474
results <- readRDS(tempFile)
464-
break
465-
475+
return(results)
466476
}
467477

468478
# wait for 10 seconds for the result to be available
469479
Sys.sleep(10)
470480
}
471-
472-
return(results)
473481
}
474482

475483
#' Utility function for creating an output file
@@ -713,25 +721,30 @@ readMetadataBlob <- function(jobId) {
713721
downloadPath = tempFile,
714722
overwrite = TRUE
715723
)
716-
result <- readRDS(tempFile)
717-
result <- xml2::as_xml_document(result)
718-
chunkSize <- getXmlValues(result, ".//chunkSize")
719-
packages <- getXmlValues(result, ".//packages")
720-
errorHandling <- getXmlValues(result, ".//errorHandling")
721-
wait <- getXmlValues(result, ".//wait")
722-
enableCloudCombine <-
723-
getXmlValues(result, ".//enableCloudCombine")
724724

725-
metadata <-
726-
list(
727-
chunkSize = chunkSize,
728-
packages = packages,
729-
errorHandling = errorHandling,
730-
enableCloudCombine = enableCloudCombine,
731-
wait = wait
732-
)
725+
if (is.vector(result)) {
726+
result <- readRDS(tempFile)
727+
result <- xml2::as_xml_document(result)
728+
chunkSize <- getXmlValues(result, ".//chunkSize")
729+
packages <- getXmlValues(result, ".//packages")
730+
errorHandling <- getXmlValues(result, ".//errorHandling")
731+
wait <- getXmlValues(result, ".//wait")
732+
enableCloudCombine <-
733+
getXmlValues(result, ".//enableCloudCombine")
734+
735+
metadata <-
736+
list(
737+
chunkSize = chunkSize,
738+
packages = packages,
739+
errorHandling = errorHandling,
740+
enableCloudCombine = enableCloudCombine,
741+
wait = wait
742+
)
733743

734-
metadata
744+
metadata
745+
} else {
746+
stop(paste0(result, "\r\n"))
747+
}
735748
}
736749

737750
areShallowEqual <- function(a, b) {

0 commit comments

Comments
 (0)