Prerequisites for All Use Cases | Open Analytics Framework | VantageCloud Lake - Prerequisites for All Use Cases - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905
Before working on any use case, you must establish a connection to a target VantageCloud Lake system with your credentials and additional authentication. For the authentication process, you need the following:
  • The Open Analytics Endpoint URL that you obtain from your VantageCloud Lake Console user information.
    This is present in the Overview tab of the Environments panel. See the following image for example.
    Overview environment settings
  • Client_id.
    • If you are using teradataml 17.20.00.05/06, this is required and the value is <organization_name>-oaf-device.
      You need to include these steps in addition to the following "Sample code snippet":
      from teradataml import set_auth_token
      # Use the following specified authentication parameters to set an authentication token.
      # where the ues_url parameter is the Open Analytics Endpoint URL string.
      set_auth_token(ues_url='<ues_url>',
                     client_id = '<org_name>-oaf-device')
See Prerequisite to Use Open Analytics Framework in the teradataml User Guide for more details.

Furthermore, you need to set the session to an analytic compute group that you have access to. These steps are illustrated in the following statements.

You need to repeat the same sequence to establish a connection every time you start a teradataml session.

Sample code snippet:

# Specify the necessary library imports.
from teradataml import create_context, remove_context

from teradataml import set_auth_token
from teradataml import list_base_envs, list_user_envs
from teradataml import create_env, remove_env, get_env
from teradataml import DataFrame, copy_to_sql, Apply, configure
from teradataml.options.display import display
import getpass
import json, os, sys, warnings
# Create teradataml connection context with your database credentials.
print("Creating the context...")
host = input("Host: ")
username = input("Username: ")
password = getpass.getpass()
con = create_context(host = host, username = username, password = password)
For all the following sample use cases, assume the analytic compute group is called "Analytic_Test".
# To work with OpenAF, set session to an analytic compute group.
set_session = '''
SET SESSION COMPUTE GROUP Analytic_Test'''


from teradataml import execute_sql
df_base = execute_sql(set_session)