td_publish_model() | Teradata R Package - 17.00 - td_publish_model() - Teradata R Package

Teradata® R Package User Guide

prodname
Teradata R Package
vrm_release
17.00
created_date
November 2020
category
User Guide
featnum
B700-4005-090K

Use the td_publish_model() function to set the access level of a saved model in the catalog, along with the status of the model.

For example, the status of a model can be 'In-Development' when the model is being fine tuned. Once it is tested, it can be set to 'Active' or 'Production'.

A model can only be published by its creator.

Required arguments:

name specifies the name of the model to be published.
Optional arguments:
At least one of the following two optional arguments must be specified.
  • grantee specifies a user or role to update the model's access level to one of the following:
    • Private

      When a model is saved using the td_save_model() function, the access is set to 'Private'.

    • Public

      A user can set the access level to Public by passing 'PUBLIC' as the value to the grantee argument.

    • Team

      The access level is set to Team when the user passes a user or a role other than PUBLIC, or his or her own username to the grantee argument.

    Currently,
    • The td_publish_model() function allows the setting of access level only when the current access level is 'Private', and setting to 'Private' from any other access level is not supported.
    • When setting a grantee (or access level), the td_publish_model() function shows the user which model tables need to be granted access to the grantee. Once these SQL GRANT commands are issued, the model becomes accessible to the intended user(s).
  • status specifies a string to set the status of the model to one of the following permitted values:
    • Active
    • Retired
    • Candidate
    • Production
    • In-Development

Example Prerequisites

Follow the steps in td_save_model() to create and save a model.

Example 1: Update only the access.

Use td_describe_model() function to check the update.

> td_publish_model('glm_model', grantee='john')
Model published successfully!
Please execute the following GRANT statements:
GRANT SELECT ON "alice"."r__t__sqlmr_stdout_1594617222690011" to john;
GRANT SELECT ON "alice"."r__t__td_glm_mle0_1594617222126955" to john;

To make sure 'john' can access this model's information, you must issue the SQL GRANT statements as suggested in the output message.

Example 2: Update only the status.

Use td_describe_model() function to check the update.

> td_publish_model('glm_model', status='Active')
Model published successfully!

Example 3: Update both the access and status.

Use td_describe_model() function to check the update.

  • Save the mode again with a different name.

    As noted earlier, the td_publish_model() function currently supports updating access level only when the the current access level is 'Private'. If Example 1 has been run, the model saved earlier cannot be used for this example as the access level for it will be different from 'Private'.

    > td_save_model(model = td_glm_out1, name = "glm_model_2", description = "GLM test 2")
  • Update both the access and status of the newly saved model.
    > td_publish_model('glm_model_2', grantee='PUBLIC', status='Production')
    Model published successfully!
    Please execute the following GRANT statements:
    GRANT SELECT ON "alice"."r__t__sqlmr_stdout_1594617222690011" to PUBLIC;
    GRANT SELECT ON "alice"."r__t__td_glm_mle0_1594617222126955" to PUBLIC;

    To make sure the role 'PUBLIC' can access this model's information, you must issue the SQL GRANT statements as suggested in the output message.