diff --git a/R/logon_clients.R b/R/logon_clients.R index 4b32f9b..fbeaf20 100644 --- a/R/logon_clients.R +++ b/R/logon_clients.R @@ -90,7 +90,7 @@ delete_client <- function(session, client){ del_client <- vDELETE(session, paste0("SASLogon/oauth/clients/", client_id)) - return(del_client) + invisible(del_client) } #' Get a client diff --git a/R/microanalyticScore.R b/R/microanalyticScore.R index 17d587a..e1749b5 100644 --- a/R/microanalyticScore.R +++ b/R/microanalyticScore.R @@ -124,7 +124,7 @@ delete_masmodule <- function(session, module, exact = TRUE){ del_module <- vDELETE(session, paste0("microanalyticScore/modules/", module_id)) - return(del_module) + invisible(del_module) } diff --git a/R/model_repository.R b/R/model_repository.R index efa350f..a9a477d 100644 --- a/R/model_repository.R +++ b/R/model_repository.R @@ -14,7 +14,7 @@ #' @param force Boolean, force the creation of project if unavailable #' @param version This parameter indicates to create a new project version, use the latest version, or use an existing version to import the model into. Valid values are 'NEW', 'LATEST', or a number. #' @param force_pmml_translation default is TRUE, set to false will upload pmml as is, but may not work properly. Only if `type = "pmml"` -#' @param model_function [sasctl::create_project()] parameter of model function of the created project if `force = TRUE`. Valid values: analytical, classification, cluster, forecasting, prediction, Text categorization, Text extraction, Text sentiment, Text topics, transformation +#' @param model_function [sasctl::create_project()] parameter of project model function of the created project if `force = TRUE`. Valid values: analytical, classification, cluster, forecasting, prediction, Text categorization, Text extraction, Text sentiment, Text topics, transformation #' @param additional_project_parameters list of additional parameters to be passed to [sasctl::create_project()] `additional_parameters` parameter #' @param project_description description string of additional parameters to be passed to [sasctl::create_project()] `description` parameter #' @param ... pass to `sasctl::vPOST()` function @@ -263,7 +263,7 @@ register_model <- function(session, file, name, project, type, additional_parameters = additional_project_parameters, ...) - message(paste0("The project ' ", project$name, " 'has been successfully created")) + message(paste0("The project '", project$name, "' has been successfully created")) forced_created_project <- TRUE } else { @@ -299,16 +299,12 @@ register_model <- function(session, file, name, project, type, ... ) - - model <- create_sasctl_obj(model$items, "MMmodel") + message(paste0("The model '", name, "' has been successfully imported")) - ### this will transform lists to DF, make similar to MMmodel - model$links <- model$links[[1]] - model$inputVariables <- model$inputVariables[[1]] - model$outputVariables <- model$outputVariables[[1]] - model$modelVersions <- model$modelVersions[[1]] - model$tags <- model$tags[[1]] - model$globalTags <- model$globalTags[[1]] + # it guarantees that transformations has the correct information + # if any translation happened + model <- create_sasctl_obj(model$items, "MMmodel") + model <- get_model(session, model) ### additional project updates @@ -316,14 +312,22 @@ register_model <- function(session, file, name, project, type, variable_columns <- c("name", "length", "type", "level", "role") + in_vars <- model[["inputVariables"]] + out_vars <- model[["outputVariables"]] + + ## fix if 'level' is missing + out_vars[setdiff(variable_columns, names(out_vars))] <- "" + in_vars[setdiff(variable_columns, names(in_vars))] <- "" + + vars <- rbind( + in_vars[,variable_columns], + out_vars[,variable_columns] + ) + projectVars <- update_project_variables(session, project, - sasctl_vars = rbind( - model$inputVariables[variable_columns], - model$outputVariables[variable_columns] - ), - ... - ) + sasctl_vars = vars, + ...) } @@ -465,7 +469,7 @@ list_models <- function(session, start = 0, limit = 10, filters = list(), exact #' #' @param session viya_connection object, obtained through `session` function #' @param name The name of the project -#' @param model_function The model function of the project. Valid values: analytical, classification, cluster, forecasting, prediction, Text categorization, Text extraction, Text sentiment, Text topics, transformation +#' @param model_function The project model function of the project. Valid values: analytical, classification, cluster, forecasting, prediction, Text categorization, Text extraction, Text sentiment, Text topics, transformation #' @param description The description of the project. #' @param input_vars `data.frame` with the input data sample to configure the project variables. #' @param output_vars `data.frame` with the output data sample to configure the project variables. @@ -945,7 +949,7 @@ delete_project <- function(session, project, exact = TRUE){ del_proj <- vDELETE(session, paste0("modelRepository/projects/", project_id)) - return(del_proj) + invisible(del_proj) } @@ -975,7 +979,7 @@ delete_model <- function(session, model, exact = TRUE){ del_model <- vDELETE(session, paste0("modelRepository/models/", model_id)) - return(del_model) + invisible(del_model) } #' Delete a model content @@ -1021,7 +1025,7 @@ delete_model_contents <- function(session, model, content, exact = TRUE){ } - return(del_content) + invisible(del_content) } diff --git a/README.Rmd b/README.Rmd index eb79b37..2321a76 100644 --- a/README.Rmd +++ b/README.Rmd @@ -263,7 +263,7 @@ diags <- diagnosticsJson(validadedf = scoreddf[scoreddf$partition == 3,], ## writing other files write_in_out_json(hmeq[,-1], input = TRUE, path = path) -write_in_out_json(scoreddf[-4], input = FALSE, path = path) +write_in_out_json(scoreddf[-c(4, 8, 9)], input = FALSE, path = path) write_fileMetadata_json(scoreCodeName = "scoreCode.R", scoreResource = "rlogistic.rda", @@ -321,7 +321,7 @@ payload for a MAS call, which doesn’t have a standard format. ### Payload for Viya MAS {"inputs": [ - {"name": "", "value": decimal_value}, + {"name": "", "value": 123}, {"name": "", "value": "string_value"}, {"name": "", "value": null} ## if value: NA ] @@ -332,7 +332,7 @@ payload for a MAS call, which doesn’t have a standard format. { "metadata": { "": 1, - "": 'any detail', + "": "any metadata string", "": 3 }, "data": { diff --git a/README.md b/README.md index 3cfabf7..f06d56e 100644 --- a/README.md +++ b/README.md @@ -246,7 +246,7 @@ diags <- diagnosticsJson(validadedf = scoreddf[scoreddf$partition == 3,], ## writing other files write_in_out_json(hmeq[,-1], input = TRUE, path = path) -write_in_out_json(scoreddf[-4], input = FALSE, path = path) +write_in_out_json(scoreddf[-c(4, 8, 9)], input = FALSE, path = path) write_fileMetadata_json(scoreCodeName = "scoreCode.R", scoreResource = "rlogistic.rda", @@ -303,7 +303,7 @@ payload for a MAS call, which doesn’t have a standard format. ### Payload for Viya MAS {"inputs": [ - {"name": "", "value": decimal_value}, + {"name": "", "value": 123}, {"name": "", "value": "string_value"}, {"name": "", "value": null} ## if value: NA ] @@ -314,7 +314,7 @@ payload for a MAS call, which doesn’t have a standard format. { "metadata": { "": 1, - "": 'any detail', + "": "any metadata string", "": 3 }, "data": { diff --git a/man/create_project.Rd b/man/create_project.Rd index aeb8472..39c0d2d 100644 --- a/man/create_project.Rd +++ b/man/create_project.Rd @@ -23,7 +23,7 @@ create_project( \item{description}{The description of the project.} -\item{model_function}{The model function of the project. Valid values: analytical, classification, cluster, forecasting, prediction, Text categorization, Text extraction, Text sentiment, Text topics, transformation} +\item{model_function}{The project model function of the project. Valid values: analytical, classification, cluster, forecasting, prediction, Text categorization, Text extraction, Text sentiment, Text topics, transformation} \item{input_vars}{\code{data.frame} with the input data sample to configure the project variables.} diff --git a/man/register_model.Rd b/man/register_model.Rd index 35cf283..f12d9c3 100644 --- a/man/register_model.Rd +++ b/man/register_model.Rd @@ -37,7 +37,7 @@ register_model( \item{force}{Boolean, force the creation of project if unavailable} -\item{model_function}{\code{\link[=create_project]{create_project()}} parameter of model function of the created project if \code{force = TRUE}. Valid values: analytical, classification, cluster, forecasting, prediction, Text categorization, Text extraction, Text sentiment, Text topics, transformation} +\item{model_function}{\code{\link[=create_project]{create_project()}} parameter of project model function of the created project if \code{force = TRUE}. Valid values: analytical, classification, cluster, forecasting, prediction, Text categorization, Text extraction, Text sentiment, Text topics, transformation} \item{additional_project_parameters}{list of additional parameters to be passed to \code{\link[=create_project]{create_project()}} \code{additional_parameters} parameter}