Teradata Package for Python Function Reference - 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

Product
Teradata Package for Python
Release Number
17.00
Published
November 2021
Language
English (United States)
Last Update
2021-11-19
lifecycle
previous
Product Category
Teradata Vantage
teradataml.table_operators.Script.test_script = test_script(self, supporting_files=None, input_data_file=None, script_args='', exec_mode='sandbox', **kwargs)
DESCRIPTION:
    Function enables user to run script in docker container environment outside
    Vantage.
    Input data for user script is read from file.
 
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:
        Required 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.
        If set to 'sandbox', the user script will run within the sandbox
        environment, else it will run locally on user's system.
        Permitted Values: 'sandbox', 'local'
        Default Value: 'sandbox'
        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
 
            timeout:
                Optional Argument.
                Specifies the timeout for docker API calls when running in
                sandbox mode.
                Default Value: 5000
                Types: int
 
            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 sandbox 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='sandbox')
 
    ############ 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
    
    # Run user script in sandbox mode with logmech as 'TD2'.
    >>> sto.test_script(script_args="4 5 10 6 480", password="alice", logmech="TD2")
 
    # Run user script in sandbox mode with logmech as 'TDNEGO'.
    >>> sto.test_script(script_args="4 5 10 6 480", password="alice", logmech="TDNEGO")
 
    # Run user script in sandbox mode with logmech as 'LDAP'.
    >>> sto.test_script(script_args="4 5 10 6 480", password="alice", logmech="LDAP")
 
    # Run user script in sandbox mode with logmech as 'KRB5'.
    >>> sto.test_script(script_args="4 5 10 6 480", password="alice", logmech="KRB5")
 
    # Run user script in sandbox mode with logmech as 'JWT'.
    >>> sto.test_script(script_args="4 5 10 6 480", password="alice",
                        logmech='JWT', logdata='token=eyJpc...h8dA')