Title: | Client for the 'Alteryx Promote' API |
---|---|
Description: | Deploy, maintain, and invoke predictive models using the 'Alteryx Promote' REST API. 'Alteryx Promote' is available at the URL: <https://www.alteryx.com/products/alteryx-promote>. |
Authors: | Paul E. Promote <[email protected]> |
Maintainer: | Paul E. Promote <[email protected]> |
License: | FreeBSD |
Version: | 1.1.1 |
Built: | 2025-03-12 05:00:52 UTC |
Source: | https://github.com/alteryx/promote-r-client |
Private function that adds a package to the list of dependencies that will be installed on the Promote server
add.dependency(name, importName, src, version, install, auth_token, ref, subdir)
add.dependency(name, importName, src, version, install, auth_token, ref, subdir)
name |
name of the package to be installed |
importName |
name under which the package is imported (for a github package, this may be different from the name used to install it) |
src |
source that the package is installed from (CRAN or github) |
version |
version of the package |
install |
whether or not the package should be installed in the model image |
auth_token |
a personal access token for github or gitlab repositories |
ref |
The git branch, tag, or SHA of the package to be installed |
subdir |
The path to the repo subdirectory holding the package to be installed |
Private function that adds metadata about the model that will be installed on the Promote server the metadata is arranged as key-value pairs
add.metadata(key, value)
add.metadata(key, value)
key |
key name for the metadata entry |
value |
value for the metadata entry |
Private function for catpuring the source code of model
capture.src(funcs, capture.model.require = TRUE)
capture.src(funcs, capture.model.require = TRUE)
funcs |
functions to capture, defaults to required promote model functions |
capture.model.require |
flag to capture the model.require function |
Private function for checking the size of the user's image.
check.image.size()
check.image.size()
Private predicate function that checks if the protocol of a url is https.
is.https(x)
is.https(x)
x |
is a url string |
This function takes model.predict and creates
a model on promote's servers which can be called from any programming language
via promote's REST API (see promote.predict
).
promote.deploy(model_name, confirm = TRUE, custom_image = NULL)
promote.deploy(model_name, confirm = TRUE, custom_image = NULL)
model_name |
name of your model |
confirm |
boolean indicating whether to prompt before deploying |
custom_image |
name of the image you'd like your model to use |
promote.config <- c( username = "your username", apikey = "your apikey", env = "http://sandbox.promotehq.com/" ) iris$Sepal.Width_sq <- iris$Sepal.Width^2 fit <- glm(I(Species)=="virginica" ~ ., data=iris) model.predict <- function(df) { data.frame("prediction"=predict(fit, df, type="response")) } ## Not run: promote.library("randomForest") promote.deploy("irisModel") ## End(Not run)
promote.config <- c( username = "your username", apikey = "your apikey", env = "http://sandbox.promotehq.com/" ) iris$Sepal.Width_sq <- iris$Sepal.Width^2 fit <- glm(I(Species)=="virginica" ~ ., data=iris) model.predict <- function(df) { data.frame("prediction"=predict(fit, df, type="response")) } ## Not run: promote.library("randomForest") promote.deploy("irisModel") ## End(Not run)
Private function for performing a GET request
promote.get(endpoint, query = c())
promote.get(endpoint, query = c())
endpoint |
/path for REST request |
query |
url parameters for request |
Import one or more libraries and add them to the promote model's dependency list
promote.library(name, src = "version", version = NULL, user = NULL, install = TRUE, auth_token = NULL, url = NULL, ref = "master", subdir = NULL)
promote.library(name, src = "version", version = NULL, user = NULL, install = TRUE, auth_token = NULL, url = NULL, ref = "master", subdir = NULL)
name |
name of the package to be added |
src |
source from which the package will be installed on Promote (github or CRAN) |
version |
version of the package to be added |
user |
Github username associated with the package |
install |
Whether the package should also be installed into the model on the Promote server; this is typically set to False when the package has already been added to the Promote base image. |
auth_token |
Personal access token string associated with a private package's repository |
url |
A valid URL pointing to a remote hosted git repository |
ref |
The git branch, tag, or SHA of the package to be installed |
subdir |
The path to the repo subdirectory holding the package to be installed |
## Not run: promote.library("MASS") promote.library(c("wesanderson", "stringr")) promote.library("hilaryparker/cats") promote.library("cats", src="github", user="hilaryparker") promote.library("my_public_package", install=FALSE) promote.library("my_public_package", src="git", url="https://gitlab.com/userName/rpkg.git") promote.library("my_proprietary_package", src="github", auth_token=<yourToken>) promote.library("testPkg", src="github", user="emessess", auth_token=<yourToken>) promote.library("priv_pkg", src="git", url="https://x-access-token:<PersonalAccessToken>ATgithub.com/username/rpkg.git") promote.library("priv_pkg", src="git", url="https://x-access-token:<PersonalAccessToken>ATgitlab.com/username/rpkg.git", ref="stage") promote.library("my_package", src="github", auth_token=<yourToken> subdir="/pathToSubdir/") ## End(Not run)
## Not run: promote.library("MASS") promote.library(c("wesanderson", "stringr")) promote.library("hilaryparker/cats") promote.library("cats", src="github", user="hilaryparker") promote.library("my_public_package", install=FALSE) promote.library("my_public_package", src="git", url="https://gitlab.com/userName/rpkg.git") promote.library("my_proprietary_package", src="github", auth_token=<yourToken>) promote.library("testPkg", src="github", user="emessess", auth_token=<yourToken>) promote.library("priv_pkg", src="git", url="https://x-access-token:<PersonalAccessToken>ATgithub.com/username/rpkg.git") promote.library("priv_pkg", src="git", url="https://x-access-token:<PersonalAccessToken>ATgitlab.com/username/rpkg.git", ref="stage") promote.library("my_package", src="github", auth_token=<yourToken> subdir="/pathToSubdir/") ## End(Not run)
List all object names which are dependencies of and 'model.predict'.
promote.ls()
promote.ls()
Add metadata to the deployment of your promote model
promote.metadata(name, value)
promote.metadata(name, value)
name |
key name for the metadata entry |
value |
value for the metadata entry |
## Not run: promote.metadata("key", "value") promote.metadata("R_squared", summary(fit)$r.squared) promote.metadata("R_squared_adj", summary(fit)$adj.r.squared) promote.metadata("deploy_node", Sys.info()[["nodename"]]) ## End(Not run)
## Not run: promote.metadata("key", "value") promote.metadata("R_squared", summary(fit)$r.squared) promote.metadata("R_squared_adj", summary(fit)$adj.r.squared) promote.metadata("deploy_node", Sys.info()[["nodename"]]) ## End(Not run)
Private function for performing a POST request
promote.post(endpoint, query = c(), data, silent = TRUE, bulk = FALSE)
promote.post(endpoint, query = c(), data, silent = TRUE, bulk = FALSE)
endpoint |
/path for REST request |
query |
url parameters for request |
data |
payload to be converted to raw JSON |
silent |
should output of url to console be silenced?
Default is |
bulk |
is this a bulk style request? Default is |
This function calls promote's REST API and returns a response formatted as a data frame.
promote.predict(model_name, data, model_owner, raw_input = FALSE, silent = TRUE)
promote.predict(model_name, data, model_owner, raw_input = FALSE, silent = TRUE)
model_name |
the name of the model you want to call |
data |
input data for the model |
model_owner |
the owner of the model [optional] |
raw_input |
when true, incoming data will NOT be coerced into data.frame |
silent |
should output of url to console (via |
promote.config <- c( username = "your username", apikey = "your apikey", env = "http://sandbox.promotehq.com/" ) ## Not run: promote.predict("irisModel", iris) ## End(Not run)
promote.config <- c( username = "your username", apikey = "your apikey", env = "http://sandbox.promotehq.com/" ) ## Not run: promote.predict("irisModel", iris) ## End(Not run)
Calls promote's REST API and returns a JSON document containing both the prediction and associated metadata.
promote.predict_raw(model_name, data, model_owner, raw_input = FALSE, silent = TRUE)
promote.predict_raw(model_name, data, model_owner, raw_input = FALSE, silent = TRUE)
model_name |
the name of the model you want to call |
data |
input data for the model |
model_owner |
the owner of the model [optional] |
raw_input |
when true, incoming data will NOT be coerced into data.frame |
silent |
should output of url to console (via |
promote.config <- c( username = "your username", apikey = "your apikey", env="http://ip_of_alteryx_promote.com" ) ## Not run: promote.predict_raw("irisModel", iris) ## End(Not run)
promote.config <- c( username = "your username", apikey = "your apikey", env="http://ip_of_alteryx_promote.com" ) ## Not run: promote.predict_raw("irisModel", iris) ## End(Not run)
Private function for recursively looking for variables
promote.spider.block(block, defined.vars = c())
promote.spider.block(block, defined.vars = c())
block |
code block to spider |
defined.vars |
variables which have already been defined within the scope of the block. e.g. function argument |
Private function for spidering function source code
promote.spider.func(func.name)
promote.spider.func(func.name)
func.name |
name of function you want to spider |
Removes a library from the promote model's dependency list
promote.unload(name)
promote.unload(name)
name |
of the package to be removed |
## Not run: promote.unload("wesanderson") ## End(Not run)
## Not run: promote.unload("wesanderson") ## End(Not run)
Private function that generates a model.require function based on the libraries that have been imported in this session.
set.model.require()
set.model.require()