Teradata Package for Python Function Reference | 20.00 - setup_sto_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 - 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
- lifecycle
- latest
- Product Category
- Teradata Vantage
- teradataml.table_operators.Script.setup_sto_env = setup_sto_env(self, docker_image_location)
- DESCRIPTION:
Function enables user to load already downloaded sandbox image.
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:
# Note - Refer to User Guide for setting search path and required permissions.
# 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")
# Set SEARCHUIFDBPATH.
>>> get_context().execute("SET SESSION SEARCHUIFDBPATH = alice;")
# Create a Script object that allows us to execute script on Vantage.
>>> import os
>>> td_path = os.path.dirname(teradataml.__file__)
>>> from teradatasqlalchemy import VARCHAR
>>> sto = Script(data=barrierdf,
... script_name='mapper.py',
... files_local_path= os.path.join(td_path, 'data', 'scripts'),
... script_command='python ./alice/mapper.py',
... data_order_column="Id",
... is_local_order=False,
... nulls_first=False,
... sort_ascending=False,
... charset='latin',
... returns=OrderedDict([("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 Vantage.
# Setup the environment by providing local path to docker image file.
>>> sto.setup_sto_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.
Starting a container for stosandbox:1.0 image.
Container d7c73cb498c79a082180576bb5b10bb07b52efdd3026856146fc15e91147b19f
started successfully.