test_script | teradataml | APPLY Table Operator for OpenAF on VantageCloud Lake - test_script - 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

Use the test_script() function to run script in Docker container environment outside Vantage. Input data for user script is read from file.

Required Argument

input_data_file
Specifies the name of the input data file, which must have a path relative to the location specified in files_local_pathargument.
If set to None, data is read from AMP, else data is from the file passed in the argument input_data_file.

Optional Arguments

supporting_files
Specifies a file or list of supporting files like model files to be copied to the container.
script_args
Specifies command line arguments required by the user script.
exec_mode
Specifies the mode in which user wants to test the script.
If set to 'sandbox', which is the default value, the user script will run within the sandbox environment.
If set to 'local', it will run locally on user's system.

**kwargs: Specifies the keyword arguments required for testing.

data_row_limit
Specifies the number of rows to be taken from all AMPs when reading from a table or view on Vantage.
Ignored when data is read from file.
password
Specifies the password to connect to Vantage where the data resides.
Required when reading from database.
data_file_delimiter
Specifies the delimiter used in the input data file. Default value is '\t'.
Can be specified when data is read from file.
data_file_header
Specifies whether the input data file contains header. Default value is True.
Can be specified when data is read from file.
timeout
Specifies the timeout for docker API calls when running in sandbox mode. Default value is 5000.
data_file_quote_char
Specifies the quotechar used in the input data file. Default value is '"'.
Can be specified when data is read from file.
logmech
Specifies the type of logon mechanism to establish a connection to Vantage.
Permitted values include:
  • TD2: The Teradata 2 (TD2) mechanism provides authentication using a Vantage username and password. This is the default logon mechanism using which the connection is established to Vantage.
  • TDNEGO: This is a security mechanism that automatically determines the actual mechanism required, based on policy, without user's involvement. The actual mechanism is determined by the TDGSS server configuration and by the security policy's mechanism restrictions.
  • LDAP: This is a directory-based user logon to Vantage with a directory username and password and is authenticated by the directory.
  • KRB5 (Kerberos): This is a directory-based user logon to Vantage with a domain username and password and is authenticated by Kerberos (KRB5 mechanism).
    User must have a valid ticket-granting ticket in order to use this logon mechanism.
  • JWT: The JSON Web Token (JWT) authentication mechanism enables single sign-on (SSO) to the Vantage after the user successfully authenticates to Teradata UDA User Service.
    User must use logdata parameter when using 'JWT' as the logon mechanism.
logdata
Specifies parameters to the LOGMECH command beyond those needed by the logon mechanism, such as user ID, password and tokens (in case of JWT) to successfully authenticate the user.
The following examples assume that an APPLY object 'apply' has been created using the steps in teradataml Apply Class for APPLY Table Operator.

Example 1: Run user script in sandbox mode with input from data file

>>> apply.test_script(input_data_file='../barrier.csv',
                      data_file_delimiter=',',
                      data_file_quote_char='"',
                      data_file_header=True,
                      exec_mode='sandbox')
############ STDOUT Output ############
        word  count_input
0          1            1
1        Old            1
2  Macdonald            1
3        Had            1
4          A            1
5       Farm            1

Example 2: Run user script in local mode with input from table

>>> apply.test_script(data_row_limit=300, password='alice', exec_mode='local')
############ STDOUT Output ############
        word  count_input
0          1            1
1        Old            1
2  Macdonald            1
3        Had            1
4          A            1
5       Farm            1

Example 3: Run user script in sandbox mode with different logon mechanisms

  • Run user script in sandbox mode with logmech as 'TD2'.
    >>> apply.test_script(script_args="4 5 10 6 480", password="alice", logmech="TD2")
  • Run user script in sandbox mode with logmech as 'TDNEGO'.
    >>> apply.test_script(script_args="4 5 10 6 480", password="alice", logmech="TDNEGO")
  • Run user script in sandbox mode with logmech as 'LDAP'.
    >>> apply.test_script(script_args="4 5 10 6 480", password="alice", logmech="LDAP")
  • Run user script in sandbox mode with logmech as 'KRB5'.
    >>> apply.test_script(script_args="4 5 10 6 480", password="alice", logmech="KRB5")
  • Run user script in sandbox mode with logmech as 'JWT'.
    >>> apply.test_script(script_args="4 5 10 6 480", password="alice",
                          logmech='JWT', logdata='token=eyJpc   h8dA')