This repository has been archived by the owner on Oct 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
418 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ Title: Interface with Azure Machine Learning datasets and web services | |
Description: Functions and datasets to support Azure Machine Learning. This | ||
allows you to interact with datasets, as well as publish and consume R functions | ||
as API services. | ||
Version: 0.2.6 | ||
Date: 2015-12-18 | ||
Version: 0.2.7 | ||
Date: 2015-12-19 | ||
Authors@R: c( | ||
person("Raymond", "Laghaeian", role=c("aut", "cre"), email="[email protected]"), | ||
person(family="Microsoft Corporation", role="cph"), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
validate.AzureML.config <- function(config = getOption("AzureML.config"), stopOnError = FALSE){ | ||
# Stop if the config file is missing | ||
if(!file.exists(config)) { | ||
msg <- sprintf("config file is missing: '%s'", config) | ||
if(stopOnError) | ||
stop(msg, call. = FALSE) | ||
else | ||
return(simpleError(msg)) | ||
} | ||
|
||
# Stop if the config is a directory, not a file | ||
if(file.info(config)$isdir){ | ||
msg <- paste( | ||
"The config argument should point to a file.", | ||
sprintf(" You provided a directory (%s)", | ||
normalizePath(config, winslash = "/", mustWork = FALSE) | ||
), sep = "\n" | ||
) | ||
if(stopOnError) | ||
stop(msg, call. = FALSE) | ||
else | ||
return(simpleError(msg)) | ||
} | ||
TRUE | ||
} | ||
|
||
#' Reads settings from configuration file in JSON format. | ||
#' | ||
#' @inheritParams workspace | ||
#' | ||
#' @export | ||
#' @seealso write.AzureML.config | ||
#' @seealso workspace | ||
read.AzureML.config <- function(config = getOption("AzureML.config")){ | ||
z <- tryCatch(fromJSON(file(config)), | ||
error = function(e)e | ||
) | ||
# Error check the settings file for invalid JSON | ||
if(inherits(z, "error")) { | ||
msg <- sprintf("Your config file contains invalid json", config) | ||
msg <- paste(msg, z$message, sep = "\n\n") | ||
stop(msg, call. = FALSE) | ||
} | ||
z | ||
} | ||
|
||
#' Writes settings to configuration file. | ||
#' | ||
#' @inheritParams workspace | ||
#' @param file either a character string naming a file or a connection open for writing. "" indicates output to the console. | ||
#' | ||
#' @rdname read.AzureML.config | ||
#' | ||
#' @export | ||
#' @seealso write.AzureML.config | ||
#' @seealso workspace | ||
write.AzureML.config <- function(id = NULL, auth = NULL, | ||
api_endpoint = NULL, | ||
management_endpoint = NULL, | ||
file = ""){ | ||
# Construct list | ||
x <- list( | ||
id = id, | ||
authorization_token = auth, | ||
api_endpoint = api_endpoint, | ||
management_endpoint = management_endpoint | ||
) | ||
# Remove null values | ||
conf <- list( | ||
workspace = x[!sapply(x, is.null)] | ||
) | ||
# Convert to JSON | ||
js <- jsonlite::toJSON(conf, pretty = TRUE) | ||
if(!missing(file) && !is.null(file)) { | ||
writeLines(js, con = file) | ||
} else { | ||
js | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
AzureML.config.default <- "~/.azureml/settings.json" | ||
options(AzureML.config = AzureML.config.default) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This function is used in unit testing to skip tests if the config file is missing | ||
# | ||
skip_if_missing_config <- function(f){ | ||
if(!file.exists(f)) { | ||
msg <- paste("To run tests, add a file ~/.azureml/settings.json containing AzureML keys.", | ||
"See ?workspace for help", | ||
sep = "\n") | ||
message(msg) | ||
skip("settings.json file is missing") | ||
} | ||
} |
Oops, something went wrong.