Skip to content

Commit

Permalink
Improved error messages and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
pinduzera committed Jul 18, 2023
1 parent 0c0681d commit 9671b90
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ README_cache
_authinfo
README_old.md
inst/doc
myModel
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions R/codegen.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
24 changes: 12 additions & 12 deletions R/model_repository.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions man/codegen.Rd

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

4 changes: 2 additions & 2 deletions 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 9671b90

Please sign in to comment.