From 9c7fce1f13709bcf9250ee0eb254ec11b1ba67b8 Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Tue, 30 May 2017 20:43:32 +0100 Subject: [PATCH] Add pollStatus function for script actions #62 --- NAMESPACE | 1 + R/AzureHDI.R | 16 +++++++++------- R/pollStatus.R | 6 +++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 0bc2553..b5c4d85 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,7 @@ S3method(print,azureActiveContext) S3method(str,azureActiveContext) +S3method(summary,azureScriptActionHistory) export(AzureListRG) export(as.azureActiveContext) export(azureAuthenticate) diff --git a/R/AzureHDI.R b/R/AzureHDI.R index 9ae381b..135a610 100644 --- a/R/AzureHDI.R +++ b/R/AzureHDI.R @@ -356,9 +356,9 @@ azureResizeHDI <- function(azureActiveContext, clustername, #' @inheritParams azureAuthenticate #' @inheritParams azureListHDI #' -#' @return Returns Dataframe of HDInsight Clusters information +#' @return Data frame with HDInsight clusters information #' @family HDInsight functions -#' @reference https://docs.microsoft.com/en-us/rest/api/hdinsight/hdinsight-cluster#delete +#' @references https://docs.microsoft.com/en-us/rest/api/hdinsight/hdinsight-cluster#delete #' @export azureDeleteHDI <- function(azureActiveContext, clustername, subscriptionID, resourceGroup, verbose = FALSE) { @@ -509,13 +509,15 @@ azureScriptActionHistory <- function(azureActiveContext, resourceGroup, } #' @export +#' @param object azureScriptActionHistory object, created by [azureScriptActionHistory()] +#' @param ... not used #' @rdname azureScriptActionHistory -summary.azureScriptActionHistory <- function(x) { - do.call(rbind, lapply(x, function(x) { +summary.azureScriptActionHistory <- function(object, ...) { + do.call(rbind, lapply(object, function(x) { data.frame( - x[c("name", "scriptExecutionId", "startTime")], - if (is.null(x$endTime)) list(endTime = NA) else x["endTime"], - x[c("status", "uri", "parameters")] + x[c("name", "scriptExecutionId", "startTime")], + if (is.null(x$endTime)) list(endTime = NA) else x["endTime"], + x[c("status", "uri", "parameters")] ) })) } diff --git a/R/pollStatus.R b/R/pollStatus.R index 7313947..b83390c 100644 --- a/R/pollStatus.R +++ b/R/pollStatus.R @@ -135,7 +135,7 @@ pollStatusScriptAction <- function(azureActiveContext, scriptname) { while (iteration < 500 && waiting) { status <- azureScriptActionHistory(azureActiveContext) - idx <- which(sapply(z, "[[", "name") == scriptname)[1] + idx <- which(sapply(status, "[[", "name") == scriptname)[1] summary <- status[[idx]]$status rc <- switch(tolower(summary), accepted = "A", @@ -144,7 +144,7 @@ pollStatusScriptAction <- function(azureActiveContext, scriptname) { failed = "F", inprogress = ".", "?" - ) + ) message(rc, appendLF = FALSE) if (rc %in% c("S", "E", "F")) { @@ -160,7 +160,7 @@ pollStatusScriptAction <- function(azureActiveContext, scriptname) { iteration <- iteration + 1 if (!rc %in% c("S", "E", "F")) Sys.sleep(5) - } + } message("") message("Script action completed: ", Sys.time()) return(TRUE)