diff --git a/.gitignore b/.gitignore index 666a2d4..68bc70c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ README_cache _authinfo README_old.md inst/doc +myModel diff --git a/DESCRIPTION b/DESCRIPTION index 4e46b05..3884163 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: sasctl Title: The sasctl package enables easy communication between the SAS Viya platform APIs and the R runtime -Version: 0.7.0 +Version: 0.7.1 Author: Eduardo Hellas Authors@R: c( person(given = "Eduardo", diff --git a/NEWS.md b/NEWS.md index 48129f9..a087697 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# sasctl 0.7.1 + +* Fixed misleading error messages in `register_model()` +* Small tweaks to the documentation + # sasctl 0.7.0 * Fixed correct release retrieval when using `session` to connect to Viya 2020.x diff --git a/R/codegen.R b/R/codegen.R index a072f97..9ce45af 100644 --- a/R/codegen.R +++ b/R/codegen.R @@ -9,6 +9,9 @@ #' Other models and frameworks will be added in due time. #' Use [sasctl::create_scoreSample()] to get a structure sample #' +#' Disclaimer: The score code that is generated is designed to be a working template for an R model, +#' but is not guaranteed to work out of the box for scoring, publishing, or validating the model. +#' #' @param model model object (lm, glm ...) #' @param path file name and path to write #' @param libs vector of libraries to be added to the code. Some may be guessed from the type. diff --git a/R/model_repository.R b/R/model_repository.R index 8a53142..efa350f 100644 --- a/R/model_repository.R +++ b/R/model_repository.R @@ -6,11 +6,11 @@ #' Registers a zip formatted model in SAS Model Manager. #' #' @param session viya_connection object, obtained through `session` function -#' @param file path to file +#' @param file path to file to be uploaded #' @param name model name that will be used when registering #' @param project `MMproject` object, project ID or project name. If name, will try to find a single project with exact name match. See `exact` parameter #' @param exact the filter query should use "contains" for partial match or "eq" for exact match -#' @param type string, pmml, spk, zip, astore or CAS, +#' @param type string, pmml, spk, zip or astore #' @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"` @@ -137,23 +137,23 @@ register_model <- function(session, file, name, project, type, ### trying to define them while uploading with the model are just ignored ### automatically create project and model version - if (missing(file)) { - stop("A path to pmml file must be set") + if (missing(file) | !is.character(file)) { + stop("A valid filepath must be set") } - if (missing(name)) { + if (missing(name) | !is.character(name)) { stop("A name must be given to the model") } - if (missing(project)) { - stop("Automatic project creation not implemented") + if (missing(project) | !is.character(project)) { + stop("The project name must be a defined character string") } - if (missing(type)) { - stop("Type must be defined as SPK, ZIP, ASTORE, PMML or CAS") + if (missing(type) | !is.character(type) | !(tolower(type) %in% c("spk", "zip", "astore", "pmml")) ) { + # TBD: CAS model + stop("Type must be 'SPK', 'ZIP', 'ASTORE' or 'PMML'") } - type <- tolower(type) ### astore treatment @@ -180,7 +180,7 @@ register_model <- function(session, file, name, project, type, if (type == "pmml") { if ( !(tools::file_ext(file) %in% c("pmml", "xml")) ) { - stop("For type = pmml, file must be .pmml, .xml") + stop("For type = pmml, file must be a valid .pmml or .xml") } if (force_pmml_translation) { @@ -263,7 +263,7 @@ register_model <- function(session, file, name, project, type, additional_parameters = additional_project_parameters, ...) - message(paste("The project with the name", project$name, "has been successfully created")) + message(paste0("The project ' ", project$name, " 'has been successfully created")) forced_created_project <- TRUE } else { diff --git a/man/codegen.Rd b/man/codegen.Rd index 39448b6..f15bf3f 100644 --- a/man/codegen.Rd +++ b/man/codegen.Rd @@ -50,6 +50,9 @@ a code string Score code will only be generated successfully for supported models. Other models and frameworks will be added in due time. Use \code{\link[=create_scoreSample]{create_scoreSample()}} to get a structure sample + +Disclaimer: The score code that is generated is designed to be a working template for an R model, +but is not guaranteed to work out of the box for scoring, publishing, or validating the model. } \section{Methods (by class)}{ \itemize{ diff --git a/man/register_model.Rd b/man/register_model.Rd index b67ef22..35cf283 100644 --- a/man/register_model.Rd +++ b/man/register_model.Rd @@ -23,13 +23,13 @@ register_model( \arguments{ \item{session}{viya_connection object, obtained through \code{session} function} -\item{file}{path to file} +\item{file}{path to file to be uploaded} \item{name}{model name that will be used when registering} \item{project}{\code{MMproject} object, project ID or project name. If name, will try to find a single project with exact name match. See \code{exact} parameter} -\item{type}{string, pmml, spk, zip, astore or CAS,} +\item{type}{string, pmml, spk, zip or astore} \item{force_pmml_translation}{default is TRUE, set to false will upload pmml as is, but may not work properly. Only if \code{type = "pmml"}}