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.
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.
**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.
- password
- Specifies the password to connect to Vantage where the data resides.
- data_file_delimiter
- Specifies the delimiter used in the input data file. Default value is '\t'.
- data_file_header
- Specifies whether the input data file contains header. Default value is True.
- 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 '"'.
- logmech
- Specifies the type of logon mechanism to establish a connection to Vantage.
- 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')