cleanup_sandbox_env() | Sandbox Container Utility | Teradata Python Package - cleanup_sandbox_env() - Teradata Package for Python

Teradata® Package for Python User Guide

Product
Teradata Package for Python
Release Number
17.00
Published
November 2021
Language
English (United States)
Last Update
2022-01-14
dita:mapPath
bol1585763678431.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
B700-4006
lifecycle
previous
Product Category
Teradata Vantage

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.

  1. Import the required modules.
    >>> from teradataml.table_operators.sandbox_container_util import *
  2. 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.
  3. 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.

  1. Load the required modules.
    >>> from teradataml.table_operators.sandbox_container_util import *
  2. Set configure.sandbox_container_id manually to use an existing container.
    >>> configure.sandbox_container_id = '<container_id_set_by_user>'
  3. 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.
  4. 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.