td_copy_files_from_container() | Sandbox Container Utility | tdplyr - td_copy_files_from_container() - Teradata Package for R

Teradata® Package for R User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for R
Release Number
17.20
Published
March 2024
Language
English (United States)
Last Update
2024-04-09
dita:mapPath
efv1707506846369.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
nqx1518630623256
Product Category
Teradata Vantage

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

The container can be specified by the argument container or indicated by the option sandbox.container.

  • Files are copied to a directory under the .tdplyr directory in user's home directory.

    The user can get home directory using Sys.getenv("HOME"). If this is not present, then user can find the files in R home directory which can be obtained using Sys.getenv("R_HOME").

  • User is responsible for cleaning up this directory.
  • If copying succeeds for one or more files, the list of files for which copying is successful and the location in which files are copied are displayed in console output.
  • If copying fails for one or more files, then the failed file names and the reasons for failure are displayed in the console output.
  • If there are duplicate elements in the argument files.to.copy, then all the duplicate elements are copied only once.

The following examples show different scenarios of copying multiple files, assuming that the container 'my_container' is already up and running.

Example 1: All requested files are present in the container

> td_copy_files_from_container(c("script_executor.R"), container = "my_container")
The following file(s) is/are copied SUCCESSFULLY from container to 
'<user_home_directory>/.tdplyr/r_t__files_from_container_1621880338383105':
          file_name
1 script_executor.R

Example 2: All requested files are NOT present in the container

> td_copy_files_from_container(c("script_executor_1.R", "invalid_file.txt"), container = "my_container")
Copying files from container FAILED for the following files:
            file_name                                                                  error_message
1 script_executor_1.R Error: No such container:path: my_container:/home/tdatuser/script_executor_1.R
2    invalid_file.txt    Error: No such container:path: my_container:/home/tdatuser/invalid_file.txt

Example 3: Some requested files are present and others are not

In this example, the function runs without the container argument. The function uses the container set by the option sandbox.container.

This function can use a container set by either the function td_setup_sandbox_env() or the option sandbox.container.

  1. Set the option sandbox.container.
    > options(sandbox.container = "my_container")
  2. Run the copy files function.
    > td_copy_files_from_container(c("script_executor_1.R", "invalid_file.txt", "script_executor.R"))
    The following file(s) is/are copied SUCCESSFULLY from container to 
    '<user_home_directory>/.tdplyr/r_t__files_from_container_1621880977147695':
              file_name
    1 script_executor.R
     
    Copying files from container FAILED for the following files:
                file_name                                                                  error_message
    1 script_executor_1.R Error: No such container:path: my_container:/home/tdatuser/script_executor_1.R
    2    invalid_file.txt    Error: No such container:path: my_container:/home/tdatuser/invalid_file.txt