Use the cleanup_sandbox_env() function to clean up sandbox environment set up by teradataml using the setup_sandbox_env() function. This function removes the image and container used to set up the sandbox environment.
Example 1: Clean up sandbox environment set up by the setup_sandbox_env() function
In this example, you first set up a sandbox environment using the setup_sandbox_env() function and then clean it up using this cleanup_sandbox _env() function.
- Import the required modules.
>>> from teradataml.table_operators.sandbox_container_util import *
- Load a sandbox image and start a container, to set up a sandbox environment.
>>> setup_sandbox_env(sandbox_image_location='/tmp/stosandbox.tar.gz', sandbox_image_name='stosandbox:1.0') Loading image from /tmp/stosandbox.tar.gz. It may take few minutes. Image loaded successfully. Starting a container for stosandbox:1.0 image. Container c1dd4d4b722cc54b643ab2bdc57540a3a3e6db98c299defc672227de97d2c345 started successfully.
- Clean up the sandbox environment created in step 2.
>>> cleanup_sandbox_env() Removed container: c1dd4d4b722cc54b643ab2bdc57540a3a3e6db98c299defc672227de97d2c345 Removed image: stosandbox:1.0
Example 2: Clean up sandbox environment set up by the setup_sandbox_env() function, not affecting other containers
In this example, you first set configure.sandbox_container_id manually, then run setup_sandbox_env() and clean it up using cleanup_sandbox_env() function. This only cleans up image and container created by setup_sandbox_env() and does not affect the sandbox that is manually set in configure.sandbox_container_id.
- Load the required modules.
>>> from teradataml.table_operators.sandbox_container_util import *
- Set configure.sandbox_container_id manually to use an existing container.
>>> configure.sandbox_container_id = '<container_id_set_by_user>'
- Load a sandbox image and start a container, to set up a new sandbox environment.
>>> setup_sandbox_env(sandbox_image_location='/tmp/stosandbox.tar.gz', sandbox_image_name='stosandbox:1.0') Loading image from /tmp/stosandbox.tar.gz. It may take few minutes. Image loaded successfully. Starting a container for stosandbox:1.0 image. Container c1dd4d4b722cc54b643ab2bdc57540a3a3e6db98c299defc672227de97d2c345 started successfully.
- Clean up the sandbox environment created by the setup_sandbox_env() function in step 3.
>>> cleanup_sandbox_env() Removed container: c1dd4d4b722cc54b643ab2bdc57540a3a3e6db98c299defc672227de97d2c345 Removed image: stosandbox:1.0
The cleanup_sandbox_env() function won't affect the container in step 2.