Use the refresh() function to refresh the UserEnv properties "files" and "libs".
'files' and 'libs' properties cache user environment file and library information respectively when invoked.
- install_lib
- uninstall_lib
- update_lib
- install_file
- remove_file
- refresh
This function does not have parameter and returns None.
Examples for Python environment
Example Prerequisite
Create remote Python user environment for the following examples 1-2.
>>> env = create_env('test_env', 'python_3.7.9', 'Test environment')
User environment test_env created.
Example 1: Refresh cache to see Python library installed without using UserEnv methods
- 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
The newly installed library 'joblib' is visible.
- Install additional 'numpy' Python libraries from outside, that is, without using the UserEnv methods.
- View installed libraries.
>>> env.libs
name version 0 joblib 1.3.2 1 pip 22.0.4 2 setuptools 47.1.0
The newly installed library 'numpy' is not visible as "libs" cache is not updated.
- Refresh the "lib" and "files" cache in the environment.
>>> env.refresh()
- View installed libraries in the refreshed cache.
>>> env.libs
name version 0 joblib 1.3.2 1 numpy 1.21.6 2 pip 22.0.4 3 setuptools 47.1.0
The newly installed 'numpy' library is visible now.
Example 2: Refresh cache to see file installed without using UserEnv methods
- View existing files.
>>> env.files
No files found in remote user environment test_env.
- Install the file mapper.py in the 'testenv' 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 'dt_testenv'. True
- View installed files.
>>> env.files
name size last_updated_dttm 0 mapper.py 532 2023-09-22T11:28:02Z
The newly installed file 'mapper.py' is visible.
- Install 'mapper_replace.py' from outside, that is, without using the UserEnv methods.
- View installed files.
>>> env.files
name size last_updated_dttm 0 mapper.py 532 2023-09-22T11:28:02Z
The newly installed file 'mapper_replace.py' is not visible as "files" cache is not updated.
- Refresh the "libs" and "files" cache in the environment.
>>> env.refresh()
- View refreshed files.
>>> env.files
name size last_updated_dttm 0 mapper.py 532 2023-09-22T11:28:02Z 1 mapper_replace.py 537 2023-09-22T11:30:11Z
The newly installed file 'mapper_replace.py' is visible now.
Examples for R environment
Example Prerequisite
Create remote R user environment for the following examples 3-4.
>>> env = create_env('r_test_env', 'r_4.1', 'R Test environment')
User environment 'test_env' created.
Example 3: Refresh cache to see R libraries installed without using UserEnv methods
- 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
The newly installed library 'glm2' is visible.
- Install additional 'anytime' and 'stringi' R libraries from outside, that is, without using the UserEnv methods.
- 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
The newly installed libraries 'anytime' and 'stringi' are not visible as "libs" cache is not updated.
- Refresh the "libs" and "files" cache in the environment.
>>> env.refresh()
- View installed libraries in the refreshed cache.
>>> 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
The newly installed libraries 'anytime' and 'stringi' are visible now.
Example 4: Refresh cache to see file installed without using UserEnv methods
- 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
name size last_updated_dttm 0 temp_file.R 19 2023-09-25T04:54:44Z
The newly installed file 'temp_file.R' is visible.
- Install 'temp_file_1.R' from outside, that is, without using the UserEnv methods.
- View installed files.
>>> env.files
name size last_updated_dttm 0 temp_file.R 19 2023-09-25T04:54:44Z
The newly installed file 'temp_file_1.R' is not visible as "files" cache is not updated.
- Refresh the "libs" and "files" in the environment.
>>> env.refresh()
- View refreshed files.
>>> env.files
name size last_updated_dttm 0 temp_file_1.R 20 2023-09-25T05:01:11Z 1 temp_file.R 19 2023-09-25T04:54:44Z
The newly installed file 'r_temp_file.R' is visible now.