delete_byom() | Teradata Package for Python - delete_byom() - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

The delete_byom() API allows a user to delete a model from the user specified table in Vantage.

Required Arguments:
  • model_id specifies the unique model identifier of the model to be deleted.
Optional Argument:
  • table_name specifies the name of the table to delete the model 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 delete_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 delete_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.

Example Setup

  • Import necessary modules.
    >>> import teradataml, os, datetime
    >>> # importing delete_byom from teradataml
    >>> from teradataml from teradataml import save_byom, delete_byom
  • Get the model file path to use it in examples.
    >>> model_file = os.path.join(os.path.dirname(teradataml.__file__), "data", "models", "iris_kmeans_model")
  • Save some models with different parameters.
    >>> save_byom("model3", model_file, "byom_models")
    Model is saved.
    >>> save_byom("model4", model_file, "byom_models", schema_name="test")
    Model is saved.

Example 1: Delete a model with specific model_id from a specific table

This example deletes a model with id "model3" from the table "byom_models".

>>> delete_byom(model_id="model3", table_name="byom_models")
Model is deleted.

Example 2: Delete a model with specific model_id from a specific table in a specific database

This example deletes a model with id "model4" from the table "byom_models" is in the "test" database.

>>> delete_byom(model_id="model4", table_name="byom_models", schema_name="test")
Model is deleted.

Example 3: Delete a model with specific model_id from a table specified by set_byom_catalog() function

  • 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'
  • Delete the a model with id 'model4' from the model catalog table specified by set_byom_catalog() function.
    >>> delete_byom(model_id='model4')
    
    Model is deleted.

Example 4: 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'.
  • The model is saved in a different table 'byom_licensed_models' which is specified by the table_name argument in the save_byom() function.
    >>> save_byom('licensed_model2', model_file=model_file, table_name='byom_licensed_models')
    
    Created the model table 'byom_licensed_models' as it does not exist.
    Model is saved.
  • Delete the model from the table specified by the table_name argument in this delete_byom() function.
    >>> delete_byom(model_id='licensed_model2', table_name='byom_licensed_models')
    
    Model is deleted.