Skip to content

Commit

Permalink
fix astore register with missing variable labels/measure
Browse files Browse the repository at this point in the history
  • Loading branch information
pinduzera committed Jul 24, 2023
1 parent 9671b90 commit 3498a77
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 31 deletions.
2 changes: 1 addition & 1 deletion R/logon_clients.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/microanalyticScore.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}


Expand Down
46 changes: 25 additions & 21 deletions R/model_repository.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -299,31 +299,35 @@ 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

if (forced_created_project) {

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,
...)

}

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1021,7 +1025,7 @@ delete_model_contents <- function(session, model, content, exact = TRUE){

}

return(del_content)
invisible(del_content)

}

Expand Down
6 changes: 3 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -321,7 +321,7 @@ payload for a MAS call, which doesn’t have a standard format.
### Payload for Viya MAS
{"inputs": [
{"name": "<input1_name>", "value": decimal_value},
{"name": "<input1_name>", "value": 123},
{"name": "<input2_name>", "value": "string_value"},
{"name": "<input3_name>", "value": null} ## if value: NA
]
Expand All @@ -332,7 +332,7 @@ payload for a MAS call, which doesn’t have a standard format.
{
"metadata": {
"<metadata_1>": 1,
"<metadata_2>": 'any detail',
"<metadata_2>": "any metadata string",
"<metadata_3>": 3
},
"data": {
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -303,7 +303,7 @@ payload for a MAS call, which doesn’t have a standard format.
### Payload for Viya MAS

{"inputs": [
{"name": "<input1_name>", "value": decimal_value},
{"name": "<input1_name>", "value": 123},
{"name": "<input2_name>", "value": "string_value"},
{"name": "<input3_name>", "value": null} ## if value: NA
]
Expand All @@ -314,7 +314,7 @@ payload for a MAS call, which doesn’t have a standard format.
{
"metadata": {
"<metadata_1>": 1,
"<metadata_2>": 'any detail',
"<metadata_2>": "any metadata string",
"<metadata_3>": 3
},
"data": {
Expand Down
2 changes: 1 addition & 1 deletion man/create_project.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/register_model.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3498a77

Please sign in to comment.