Teradata Package for Python Function Reference | 20.00 - test_script - 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 - 20.00
- Deployment
- VantageCloud
- VantageCore
- Edition
- Enterprise
- IntelliFlex
- VMware
- Product
- Teradata Package for Python
- Release Number
- 20.00.00.03
- Published
- December 2024
- ft:locale
- en-US
- ft:lastEdition
- 2024-12-19
- dita:id
- TeradataPython_FxRef_Enterprise_2000
- Product Category
- Teradata Vantage
- teradataml.table_operators.Script.test_script = test_script(self, supporting_files=None, input_data_file=None, script_args='', exec_mode='local', **kwargs)
- DESCRIPTION:
Function enables user to run script locally outside Vantage.
Input data for user script is either read from a file or from database.
Note:
1. Purpose of test_script() function is to enable the user to test their scripts for any errors without
installing it on Vantage, using the input data provided.
2. Data is not partitioned for testing the script if read from input data file.
3. Function can produce different output if input is read from a file than input from database.
PARAMETERS:
supporting_files:
Optional Argument.
Specifies a file or list of supporting files like model files to be
copied to the container.
Types: string or list of str
input_data_file:
Optional Argument.
Specifies the name of the input data file.
It should have a path relative to the location specified in
"files_local_path" argument.
If set to None, read data from AMP, else from file passed in the argument
'input_data_file'.
File should have at least permissions of mode 644.
Types: str
script_args:
Optional Argument.
Specifies command line arguments required by the user script.
Types: str
exec_mode:
Optional Argument.
Specifies the mode in which user wants to test the script.
When set to 'local', the user script will run locally on user's system.
Permitted Values: 'local'
Default Value: 'local'
Types: str
kwargs:
Optional Argument.
Specifies the keyword arguments required for testing.
Keys can be:
data_row_limit:
Optional Argument. Ignored when data is read from file.
Specifies the number of rows to be taken from all amps when
reading from a table or view on Vantage.
Default Value: 1000
Types: int
password:
Optional Argument. Required when reading from database.
Specifies the password to connect to vantage where the data
resides.
Types: str
data_file_delimiter:
Optional Argument.
Specifies the delimiter used in the input data file. This
argument can be specified when data is read from file.
Default Value: ' '
Types: str
data_file_header:
Optional Argument.
Specifies whether the input data file contains header. This
argument can be specified when data is read from file.
Default Value: True
Types: bool
data_file_quote_char:
Optional Argument.
Specifies the quotechar used in the input data file.
This argument can be specified when data is read from file.
Default Value: '"'
logmech:
Optional Argument.
Specifies the type of logon mechanism to establish a connection to
Teradata Vantage.
Permitted Values: 'TD2', 'TDNEGO', 'LDAP', 'KRB5' & 'JWT'.
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:
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:
A directory-based user logon to Vantage with a directory
username and password and is authenticated by the directory.
KRB5 (Kerberos):
A directory-based user logon to Vantage with a domain
username and password and is authenticated by
Kerberos (KRB5 mechanism).
Note:
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.
Note:
User must use logdata parameter when using 'JWT' as
the logon mechanism.
Default Value: TD2
Types: str
Note:
teradataml expects the client environments are already setup with appropriate
security mechanisms and are in working conditions.
For more information please refer Teradata Vantage™ - Advanced SQL Engine
Security Administration at https://www.info.teradata.com/
logdata:
Optional Argument.
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.
Types: str
Types: dict
RETURNS:
Output from user script.
RAISES:
TeradataMlException
EXAMPLES:
# Assumption - sto is Script() object. Please refer to help(Script)
# for creating Script object.
# Run user script in local mode with input from data file.
>>> sto.test_script(input_data_file='../barrier.csv',
... data_file_delimiter=',',
... data_file_quote_char='"',
... data_file_header=True,
... 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
>>>
# Run user script in local mode with input from table.
>>> sto.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