Teradata Package for Python Function Reference on VantageCloud Lake | 17.20 - set_license - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.

Teradata® Package for Python Function Reference on VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Package for Python
Release Number
17.20
Publication Date
November 2022
Content Type
Programming Reference
Publication ID
B700-4500-112K
ft:locale
en-US
ft:lastEdition
2024-02-21
ft:sourceId
FTML
dita:id
TeradataPython_FxRef_Lake_1720
Product Category
Teradata Vantage
teradataml.catalog.byom.set_license = set_license(license, table_name=None, schema_name=None, source='string')
DESCRIPTION:
    Function sets the license information associated with the externally
    generated model at the session level to be used by 'retrieve_byom()'.
 
PARAMETERS:
    license:
        Required Argument.
        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 "table_name" argument.
        Note:
            Argument "source" must be set accordingly.
        Types: str
 
    table_name:
        Required Argument.
        Specifies the table name containing the license information.
        Note:
            Argument "table_name" and "schema_name"
            both should be specified or both should be None.
        Types: str
 
    schema_name:
        Optional Argument.
        Specifies the name of the schema in which the table specified in
        "table_name" is looked up.
        Note:
            Argument "table_name" and "schema_name"
            both should be specified or both should be None.
        Types: str
 
    source:
        Required Argument.
        Specifies whether license key specified in "license" is a string, file
        or column name.
        Default value: string
        Permitted values: string, file, column
 
RETURNS:
    None.
 
RAISES:
    TeradataMlException
 
EXAMPLES:
    >>> import os
    >>> from teradataml import save_byom, retrieve_byom, get_context, set_license, set_byom_catalog
 
    # Example 1: When 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: When license is stored in a file and file is passed as input to "license".
    #            "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: When 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(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: Set the license information using the license stored in a 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(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'.