list_byom() | Teradata Package for Python - list_byom() - Teradata Package for Python

Teradata® Package for Python User Guide

Product
Teradata Package for Python
Release Number
17.10
Published
May 2022
Language
English (United States)
Last Update
2022-08-18
dita:mapPath
rsu1641592952675.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
B700-4006
lifecycle
previous
Product Category
Teradata Vantage

The list_byom() API allows a user to list saved models, filtering the results based on the optional arguments.

Optional Arguments:
  • table_name specifies the name of the table to list models from.
    • You must either specify this argument, or set the byom model catalog table name using set_byom_catalog().
    • If none of them are set, exception is raised; If both of them are set, the settings in list_byom() take precedence and is used for function execution.
  • schema_name specifies the name of the schema in which the table specified in table_name is looked up.

    If this argument is not specified, then table is looked up in the schema associated with the current context.

    • You must either specify this argument and the table_name argument, or set the byom model catalog schema name using set_byom_catalog().
    • If none of them are set, exception is raised; If both of them are set, the settings in list_byom() take precedence and is used for function execution.
    • If you specify schema_name, table_name has to be specified, else exception is raised.

    See table in save_byom() that shows different system behaviors based on different input combinations.

  • model_id specifies the unique model identifier of the model(s).

    If specified, the models with either exact match or a substring match, are listed.

Example Setup

  • Import necessary modules.
    >>> import teradataml, os, datetime
    >>> from teradataml import save_byom, list_byom
  • Get the model file path.
    >>> model_file = os.path.join(os.path.dirname(teradataml.__file__), "data", "models", "iris_kmeans_model")
  • Save three models with different parameters.
    >>> save_byom("model7", model_file, "byom_models")
    Model is saved.
    >>> save_byom("iris_model1", model_file, "byom_models")
    Model is saved.
    >>> save_byom("model8", model_file, "byom_models", schema_name="test")
    Model is saved.

Example 1: List all models in a table

This example lists all the models saved in the table "byom_models".

>>> list_byom(table_name="byom_models")
                                model
model_id
model7       b'504B03041400080808...'
iris_model1  b'504B03041400080808...'

Example 2: List all models with model_id containing a specific string

This example lists all the models with model_id containing the string "iris", from the "byom_models" table.

>>> list_byom(table_name="byom_models", model_id="iris")
                                model
model_id
iris_model1  b'504B03041400080808...'

Example 3: List all models with model_id containing one of the two strings

This example lists all the models with model_id containing either "iris" or "7" string, from the "byom_models" table.

>>> list_byom(table_name="byom_models", model_id=["iris", "7"])
                                model
model_id
model7       b'504B03041400080808...'
iris_model1  b'504B03041400080808...'

Example 4: List all models in a table in the specified database

This example lists all the models from the "byom_models" in the "test" database.

>>> list_byom(table_name="byom_models", schema_name="test")
                                model
model_id
model8       b'504B03041400080808...'

Example 5: List all the models from the model cataloging table set by set_byom_catalog()

  • The model cataloging parameters are set using the set_byom_catalog() function.
    >>> set_byom_catalog(table_name='byom_models', schema_name='alice')
    
    The model cataloging parameters are set to table_name='byom_models' and schema_name='alice'
  • List all the models.
    >>> list_byom()
    model
    model_id
    model8 b'504B03041400080808...'

Example 6: Override session level parameters for BYOM model cataloging

This example shows that you can override the session level BYOM model catalog information set by the set_byom_catalog(), by passing the table as well as schema arguments explicitly.

  • The model cataloging table name is set to 'byom_models' using the set_byom_catalog() function.
    >>> set_byom_catalog(table_name='byom_models', schema_name='alice')
    
    The model cataloging parameters are set to table_name='byom_models' and schema_name='alice'.
  • List all the models from the table specified by the table_name argument in this list_byom() function.
    >>> list_byom(table_name='byom_licensed_models')
    model
    model_id
    iris_model1 b'504B03041400080808...'