Teradata Package for Python Function Reference on VantageCloud Lake | 17.20 - setup_test_env - 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 on VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Package for Python
Release Number
17.20
Published
November 2022
ft:locale
en-US
ft:lastEdition
2024-02-21
dita:id
TeradataPython_FxRef_Lake_1720
Product Category
Teradata Vantage
teradataml.table_operators.Apply.setup_test_env = setup_test_env(self, docker_image_location)
DESCRIPTION:
    Function enables user to load already downloaded sandbox image.
    This will enable users to run the Python scripts on client machine outside of
    Open Analytics Framework.
 
PARAMETERS:
    docker_image_location:
        Required Argument.
        Specifies the location of image on user's system.
        Types: str
        Note:
            For location to download docker image refer teradataml User Guide.
 
RETURNS:
    None.
 
RAISES:
    TeradataMlException
 
EXAMPLES:
    # Load example data.
    load_example_data("Script", ["barrier"])
 
    # Example - The script mapper.py reads in a line of text input ("Old Macdonald Had A Farm") from csv and
    # splits the line into individual words, emitting a new row for each word.
 
    # Create teradataml DataFrame objects.
    >>> barrierdf = DataFrame.from_table("barrier")
 
    # Create remote user environment.
    >>> test_env = create_env('test_env', 'python_3.7.9', 'Demo environment');
    User environment test_env created.
 
    # Create an Apply object that allows user to execute script using Open Analytics Framework.
    >>> apply_obj = Apply(data=barrierdf,
                script_name='mapper.py',
                files_local_path='data/scripts',
                apply_command='python mapper.py',
                delimiter=',',
                env_name = "test_env",
                data_partition_column="Id",
                returns={"word": VARCHAR(15), "count_input": VARCHAR(2)}
                )
 
    # Run user script locally within docker container and using data from csv.
    # This helps the user to fix script level issues outside of Open Analytics Framework.
    # Setup the environment by providing local path to docker image file.
    >>> apply_obj.setup_test_env(docker_image_location='/tmp/sto_sandbox_docker_image.tar'))
    Loading image from /tmp/sto_sandbox_docker_image.tar. It may take few minutes.
    Image loaded successfully.