copy_files_from_container() | Sandbox Container Utility | teradataml - 17.00 - copy_files_from_container() - Teradata Package for Python

Teradata® Package for Python User Guide

Product
Teradata Package for Python
Release Number
17.00
Release Date
November 2021
Content Type
User Guide
Publication ID
B700-4006-070K
Language
English (United States)

Use the copy_files_from_container() function to copy files from a container to local file system.

Files are copied to a directory under the .teradataml directory in user's home directory. User is responsible for cleaning up this directory.

The container can be specified by the argument container_id or indicated by configure.sandbox_container_id.

See sandbox_container_id for details about this teradataml configuration option.

Required argument:
  • files_to_copy specifies the names of the files to be copied from a container.
    The files to be copied should be in the /home/tdatuser directory inside the container.
Optional argument:
  • container_id specifies the container from which files are to be copied.

    If this argument is not specified, then files are copied from the container indicated in configure.sandbox_container_id.

Example 1: Copy a single file

This example copies a single file from /home/tdatuser inside a container started by teradataml to local host.

  1. Import required module.
    >>> from teradataml.table_operators.sandbox_container_util import copy_files_from_container
  2. Copy a file from the container indicated in configure.sandbox_container_id.
    >>> copy_files_from_container(files_to_copy="file1.txt")
        Files copied to: /<user's home directory>/.teradataml/files_from_container_210110_19394

Example 2: Copy multiple files

This example copies multiple files from /home/tdatuser inside a container started by teradataml to local host.

  1. Import required module.
    >>> from teradataml.table_operators.sandbox_container_util import copy_files_from_container
  2. Copy a file from the container indicated in configure.sandbox_container_id.
    >>> copy_files_from_container(files_to_copy=["output/file1.txt", "file2.txt"])
        Files copied to: /<user's home directory>/.teradataml/files_from_container_210110_19394