create_tdapi_context | Google Vertex AI teradataml Extension Library - create_tdapi_context Method - Teradata Vantage

Teradata Vantageā„¢ - API Integration Guide for Cloud Machine Learning

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Vantage
Release Number
1.4
Published
September 2023
Language
English (United States)
Last Update
2023-09-28
dita:mapPath
mgu1643999543506.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
mgu1643999543506

Use the create_tdapi_context method to create a TDAPI context to be used to run TDApiClient functions. Creating TDAPI context object is the first step of using TDApiClient library.

You should have access to Google Cloud credentials, specifically, a service account JSON file.
Required Arguments:
  • type: Specifies the cloud type of the TDAPI context.

    Permitted values are: "aws", "azure", or "gcp".

    If the cloud type is Google Cloud, the only accepted value is "gcp".

  • gcp_bucket_name: Specifies the name of the Google Cloud storage bucket within project.
  • gcp_bucket_path: Specifies a path within the given bucket name.

    This acts as parent folder for all files that TDApiClient creates.

Environment Variables

Create the following environment variables before invoking this API.
  • Required environment variables:
    • GOOGLE_APPLICATION_CREDENTIALS: Specifies the path to the JSON file containing the Google Cloud service account credentials.
    • GCP_REGION: Specifies the location of the Google Cloud project.
    • GCP_PROJECT_ID: Specifies the Project ID of the Google Cloud project.
    • GCP_TD_AUTH_OBJ: Specifies the name of the Google Cloud authorization object in Vantage.

Example

This example creates a TDApiClient context object "td_apiclient", and use the default storage attached to the Google Cloud project to store tmp files.

from tdapiclient import create_tdapi_context
import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "path/to/service/account/file.json"
os.environ["GCP_PROJECT_ID"] = "test-project"
os.environ["GCP_REGION"] = "us-central-1"
os.environ["GCP_TD_AUTH_OBJ"] = "GCPAuth"
tdapi_context = create_tdapi_context("gcp", gcp_bucket_name="tdapiclient", gcp_bucket_path="/tmp/")
td_apiclient = TDApiClient(tdapi_context)