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

Teradata® Package for Python User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00
Published
March 2024
Language
English (United States)
Last Update
2024-04-09
dita:mapPath
nvi1706202040305.ditamap
dita:ditavalPath
plt1683835213376.ditaval
dita:id
rkb1531260709148
Product Category
Teradata Vantage

The set_license() function allows a user to set the license information associated with the externally generated model in a session level variable which is required by H2O DAI models. It is used by the retrieve_byom() function to retrieve the license information while retrieving the specific model.

If specified table name does not exist and is not the same as BYOM catalog tables, then this function creates the table and stores the license information; otherwise, this function just validates and sets the license information.

The license can be set by passing the license in the following ways:
  • Passing the license as a variable;
  • Passing the column name in the model table itself;
  • Passing the table and the column name containing the license;
  • Passing the license in a file.
Required Arguments:
  • license specifies the license key information that can be passed as:
    • a variable;
    • in a file;
    • name of the column containing license information in a table specified by the table_name argument.
    Argument source must be set accordingly.
  • source specifies whether the license key specified in license is a string, file or column name.

    The default value is string.

Optional Arguments:
  • table_name specifies the name of the table containing the license information.
  • schema_name specifies the name of the schema in which the table specified in table_name is looked up.

    If not specified, then table is looked up in current schema/database.

Specify either both or neither of the arguments table_name and schema_name.

Example Setup

>>> import os, teradataml
>>> from teradataml import save_byom, retrieve_byom, get_context, set_license, set_byom_catalog

Example 1: License is passed as a string

>>> set_license(license='eZSy3peBVRtjA-ibVuvNw5A5sUL9KU_kP35Vq4ZNBQ3iGY6oVSpE6g97sFY2LI', 
table_name=None, schema_name=None, source='string')

The license parameters are set.
The license is : eZSy3peBVRtjA-ibVuvNw5A5sUL9KU_kP35Vq4ZNBQ3iGY6oVSpE6g97sFY2LI

Example 2: License is stored in a file

The file that contains the license is passed as input to license and source must be set to 'file'.

>>> license_file = os.path.join(os.path.dirname(teradataml.__file__), 'data', 'models', 'License_file.txt')
>>> set_license(license=license_file, source='file')

The license parameters are set.
The license is: license_string

Example 3: License is present in the byom model catalog table itself

  • Store a model with license information in the model table.
    >>> model_file = os.path.join(os.path.dirname(teradataml.__file__), 'data', 'models', 'iris_kmeans_model')
    >>> save_byom('licensed_model1', model_file, 'byom_licensed_models', additional_columns={"license_data": "A5sUL9KU_kP35Vq"})
    
    Created the model table 'byom_licensed_models' as it does not exist.
    Model is saved.
    >>> set_byom_catalog(table_name='byom_licensed_models', schema_name='alice')
    
    The model cataloging parameters are set to table_name='byom_licensed_models' and schema_name='alice'.
  • Set license.
    >>> set_license(license='license_data', source='column')
    
    The license parameters are set.
    The license is present in the table='byom_licensed_models',schema='alice' and column='license_data'.

Example 4: License is stored in a column

The license information is stored in the column 'license_key' of a table 'license_table'.

  • Create a table and insert the license information in the table.
    >>> license = 'eZSy3peBVRtjA-ibVuvNw5A5sUL9KU_kP35Vq4ZNBQ3iGY6oVSpE6g97sFY2LI'
    >>> lic_table = 'create table license (id integer between 1 and 1,
    license_key varchar(2500)) unique primary index(id);'
    >>> get_context().execute(lic_table)
    <sqlalchemy.engine.cursor.LegacyCursorResult object at 0x000001DC4F2EE9A0>
    
    >>> get_context().execute("insert into license values (1, 'peBVRtjA-ib')")
    <sqlalchemy.engine.cursor.LegacyCursorResult object at 0x000001DC4F2EEF10>
  • Set license.
    >>> set_license(license='license_key', table_name='license', schema_name='alice', source='column')
    
    The license parameters are set.
    The license is present in the table='license', schema='alice' and column='license_key'.