Teradata Package for Python Function Reference on VantageCloud Lake - refresh - 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 on VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
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_Lake_2000
Product Category
Teradata Vantage
teradataml.scriptmgmt.UserEnv.UserEnv.refresh = refresh(self)
DESCRIPTION:
    Function refreshes the UserEnv properties 'files' and 'libs'.
    'files' and 'libs' properties cache user environment file and library
    information respectively when invoked. This information is refreshed
    when user invokes any of the following methods of 'UserEnv' class:
        * install_lib
        * uninstall_lib
        * update_lib
        * install_file
        * remove_file
        * refresh
 
    This method should be used when user environment is updated outside
    of teradataml or cache is not updated after user environment updates.
 
PARAMETERS:
    None
 
RETURNS:
    None
 
RAISES:
    NOne
 
EXAMPLES:
    # Create a remote user environment.
    >>> env = create_env('test_env', 'python_3.7.9', 'Test environment')
    User environment 'test_env' created.
 
    # Example 1: Install the libs in the 'test_env' environment.
    # View existing libraries installed.
    >>> env.libs
             name version
    0         pip  22.0.4
    1  setuptools  47.1.0
 
    # Install additional Python library using UserEnv method.
    >>> env.install_lib("joblib")
                                   Claim Id File/Libs  Method Name     Stage             Timestamp Additional Details
    0  263c4600-9b68-4cae-b601-270936cb965a    joblib  install_lib   Started  2023-09-22T10:47:09Z
    1  263c4600-9b68-4cae-b601-270936cb965a    joblib  install_lib  Finished  2023-09-22T10:47:15Z
 
    # View installed libraries.
    >>> env.libs
             name version
    0      joblib   1.3.2
    1         pip  22.0.4
    2  setuptools  47.1.0
 
    # Install additional 'numpy' Python library from outside, i.e. without using the UserEnv methods.
 
    # View installed libraries. Note that 'numpy' library is not visible as "libs" cache is not updated.
    # To refresh cache execute the 'refresh()' method.
    >>> env.libs
             name version
    0      joblib   1.3.2
    1         pip  22.0.4
    2  setuptools  47.1.0
 
    # Refresh the 'libs' and 'files' in the environment.
    >>> env.refresh()
 
    # View refreshed libraries.
    >>> env.libs
             name version
    0      joblib   1.3.2
    1       numpy  1.21.6
    2         pip  22.0.4
    3  setuptools  47.1.0
 
    # Example 2: Install the files in the 'test_env' environment.
    # View existing files.
    >>> env.files
    No files found in remote user environment test_env.
 
    # Install the file mapper.py in the 'test_env' environment using UserEnv method.
    >>> import os, teradataml
    >>> file_path = os.path.join(os.path.dirname(teradataml.__file__), "data", "scripts", "mapper.py")
    >>> env.install_file(file_path = file_path)
    File 'mapper.py' installed successfully in the remote user environment 'test_env'.
    True
 
    # View installed files.
    >>> env.files
            File  Size             Timestamp
    0  mapper.py   532  2023-09-22T11:28:02Z
 
    # Install 'mapper_replace.py' file from outside, i.e. without using the UserEnv methods.
 
    # View installed files. Note that recently installed file using REST call
    # is not visible as "files" cache is not updated. To refresh cache execute the 'refresh()' method.
    >>> env.files
            File  Size             Timestamp
    0  mapper.py   532  2023-09-22T11:28:02Z
 
    # Refresh the 'libs' and 'files' in the environment.
    >>> env.refresh()
 
    # View refreshed files.
    >>> env.files
                    File  Size             Timestamp
    0          mapper.py   532  2023-09-22T11:28:02Z
    1  mapper_replace.py   537  2023-09-22T11:30:11Z
 
    # Create a remote R user environment.
    >>> env = create_env('r_test_env', 'r_4.1', 'R Test environment')
    User environment 'test_env' created.
 
    # Example 1: Install the libs in the R environment 'r_test_env'.
    # View existing libraries installed.
    >>> env.libs
              name  version
    0   KernSmooth  2.23-20
    1         MASS   7.3-55
    2       Matrix    1.4-0
    3         base    4.1.3
    4         boot   1.3-28
    5        class   7.3-20
    6      cluster    2.1.2
    7    codetools   0.2-18
    8     compiler    4.1.3
    9     datasets    4.1.3
    10     foreign   0.8-82
    11   grDevices    4.1.3
    12    graphics    4.1.3
    13        grid    4.1.3
    14     lattice  0.20-45
    15     methods    4.1.3
    16        mgcv   1.8-39
    17        nlme  3.1-155
    18        nnet   7.3-17
    19    parallel    4.1.3
    20     remotes    2.4.2
    21       rpart   4.1.16
    22     spatial   7.3-15
    23     splines    4.1.3
    24       stats    4.1.3
    25      stats4    4.1.3
    26    survival   3.2-13
    27       tcltk    4.1.3
    28       tools    4.1.3
    29       utils    4.1.3
 
    # Install additional R library using UserEnv method.
    >>> env.install_lib("glm2")
                                   Claim Id File/Libs  Method Name     Stage             Timestamp Additional Details
    0  8eceab10-cc12-4889-b17e-8bed3757a123      glm2  install_lib   Started  2023-09-22T11:38:27Z
    1  8eceab10-cc12-4889-b17e-8bed3757a123      glm2  install_lib  Finished  2023-09-22T11:38:33Z
 
    # View installed libraries.
    >>> env.libs
              name  version
    0   KernSmooth  2.23-20
    1         MASS   7.3-55
    2       Matrix    1.4-0
    3         base    4.1.3
    4         boot   1.3-28
    5        class   7.3-20
    6      cluster    2.1.2
    7    codetools   0.2-18
    8     compiler    4.1.3
    9     datasets    4.1.3
    10     foreign   0.8-82
    11   grDevices    4.1.3
    12    graphics    4.1.3
    13        grid    4.1.3
    14     lattice  0.20-45
    15     methods    4.1.3
    16        mgcv   1.8-39
    17        nlme  3.1-155
    18        nnet   7.3-17
    19    parallel    4.1.3
    20     remotes    2.4.2
    21       rpart   4.1.16
    22     spatial   7.3-15
    23     splines    4.1.3
    24       stats    4.1.3
    25      stats4    4.1.3
    26    survival   3.2-13
    27       tcltk    4.1.3
    28       tools    4.1.3
    29       utils    4.1.3
    30        glm2    1.2.1
 
    # Install additional 'anytime' and 'stringi' R libraries from outside, i.e. without using the UserEnv methods.
 
    # View installed libraries. Note that 'anytime' and 'stringi' libraries are not visible as "libs" cache is not updated.
    # To refresh cache execute the 'refresh()' method.
    >>> env.libs
              name  version
    0   KernSmooth  2.23-20
    1         MASS   7.3-55
    2       Matrix    1.4-0
    3         base    4.1.3
    4         boot   1.3-28
    5        class   7.3-20
    6      cluster    2.1.2
    7    codetools   0.2-18
    8     compiler    4.1.3
    9     datasets    4.1.3
    10     foreign   0.8-82
    11   grDevices    4.1.3
    12    graphics    4.1.3
    13        grid    4.1.3
    14     lattice  0.20-45
    15     methods    4.1.3
    16        mgcv   1.8-39
    17        nlme  3.1-155
    18        nnet   7.3-17
    19    parallel    4.1.3
    20     remotes    2.4.2
    21       rpart   4.1.16
    22     spatial   7.3-15
    23     splines    4.1.3
    24       stats    4.1.3
    25      stats4    4.1.3
    26    survival   3.2-13
    27       tcltk    4.1.3
    28       tools    4.1.3
    29       utils    4.1.3
    30        glm2    1.2.1
 
    # Refresh the 'libs' and 'files' in the environment.
    >>> env.refresh()
 
    # View refreshed libraries.
    >>> env.libs
              name   version
    0   KernSmooth   2.23-20
    1         MASS    7.3-55
    2       Matrix     1.4-0
    3         base     4.1.3
    4         boot    1.3-28
    5        class    7.3-20
    6      cluster     2.1.2
    7    codetools    0.2-18
    8     compiler     4.1.3
    9     datasets     4.1.3
    10     foreign    0.8-82
    11   grDevices     4.1.3
    12    graphics     4.1.3
    13        grid     4.1.3
    14     lattice   0.20-45
    15     methods     4.1.3
    16        mgcv    1.8-39
    17        nlme   3.1-155
    18        nnet    7.3-17
    19    parallel     4.1.3
    20     remotes     2.4.2
    21       rpart    4.1.16
    22     spatial    7.3-15
    23     splines     4.1.3
    24       stats     4.1.3
    25      stats4     4.1.3
    26    survival    3.2-13
    27       tcltk     4.1.3
    28       tools     4.1.3
    29       utils     4.1.3
    30          BH  1.81.0-1
    31        Rcpp    1.0.11
    32     anytime     0.3.9
    33        glm2     1.2.1
    34     stringi    1.7.12
 
    # Example 2: Install the files in the R environment 'r_test_env'.
    # View existing files.
    >>> env.files
    No files found in remote user environment r_test_env.
 
    # Install the file temp_file.R in the 'r_test_env' environment using UserEnv method.
    >>> file_path = "temp_file.R"
    >>> with open(file_path, "w") as fp:
    ...     fp.write("print('HelloWorld')")
    >>> env.install_file(file_path = file_path)
    File 'temp_file.R' installed successfully in the remote user environment 'r_test_env'.
    True
 
    # View installed files.
    >>> env.files
              File  Size             Timestamp
    0  temp_file.R    19  2023-09-25T04:54:44Z
 
    # Install 'temp_file_1.R' file from outside, i.e. without using the UserEnv methods.
 
    # View installed files. Note that recently installed file using REST call
    # is not visible as "files" cache is not updated. To refresh cache execute the 'refresh()' method.
    >>> env.files
              File  Size             Timestamp
    0  temp_file.R    19  2023-09-25T04:54:44Z
 
    # Refresh the 'libs' and 'files' in the environment.
    >>> env.refresh()
 
    # View refreshed files.
    >>> env.files
                File  Size             Timestamp
    0  temp_file_1.R    20   2023-09-25T05:01:11Z
    1    temp_file.R    19   2023-09-25T04:54:44Z