Teradata Package for Python Function Reference on VantageCloud Lake - uninstall_lib - 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.uninstall_lib = uninstall_lib(self, libs=None, libs_file_path=None, **kwargs)
- DESCRIPTION:
Function uninstalls libraries from corresponding Python or R
remote user environment.
PARAMETERS:
libs:
Optional Argument.
Specifies the library name(s).
Note:
Either "libs" or "libs_file_path" argument must be specified.
Types: str OR list of Strings(str)
libs_file_path:
Optional Argument.
Specifies the absolute/relative path of the file (including file name)
which supplies a list of libraries to be uninstalled from the remote user
environment. Path specified should include the filename with extension.
The file should contain library names and version number(optional) of libraries.
Notes:
* Either "libs" or "libs_file_path" argument must be specified.
* The file must have ".txt" extension for Python environment
and ".txt"/".json" extension for R environment.
* The file format should adhere to the specifications of the
requirements file used by underlying language's package
manager for uninstalling libraries.
Sample text file content for Python environment:
numpy
joblib==0.13.2
Sample json/txt file content for R environment:
{
"packages": ["anytime","glm2"]
}
Types: str
**kwargs:
asynchronous:
Optional Argument.
Specifies whether to uninstall the library in remote user environment
synchronously or asynchronously. When set to True, libraries are uninstalled
asynchronously. Otherwise, libraries are uninstalled synchronously.
Note:
One should not use remove_env() on the same environment till the
asynchronous call is complete.
Default Value: False
Types: bool
timeout:
Optional Argument.
Specifies the time to wait in seconds for uninstalling the libraries. If the library is
not uninstalled with in "timeout" seconds, the function returns a claim-id and one
can check the status using the claim-id. If "timeout" is not specified, then there
is no limit on the wait time.
Note:
Argument is ignored when "asynchronous" is True.
Types: int OR float
RETURNS:
Pandas DataFrame when libraries are uninstalled synchronously.
claim_id, to track status when libraries are uninstalled asynchronously.
RAISES:
TeradataMlException
EXAMPLES:
# Examples for Python environment.
# Create remote Python user environment.
>>> testenv = create_env('testenv', 'python_3.7.9', 'Test environment')
User environment testenv created.
# Example 1: Install and uninstall a single Python library.
>>> testenv.install_lib('numpy')
Claim Id File/Libs Method Name Stage Timestamp Additional Details
0 407e644d-3630-4085-8a0b-169406f52340 numpy install_lib Started 2022-07-13T11:32:32Z None
1 407e644d-3630-4085-8a0b-169406f52340 numpy install_lib Finished 2022-07-13T11:32:33Z None
>>>
# Verify installed library.
>>> testenv.libs
library version
0 numpy 1.21.6
1 pip 20.1.1
2 setuptools 47.1.0
# Uninstall single Python library asynchronously.
>>> testenv.uninstall_lib('numpy', asynchronous=True)
Request to uninstall libraries initiated successfully in the remote user environment testenv.
Check the status using status() with the claim id '16036846-b9d7-4c5b-be92-d7cf14aa2016'.
# Check the status.
>>> testenv.status('16036846-b9d7-4c5b-be92-d7cf14aa2016')
Claim Id File/Libs Method Name Stage Timestamp Additional Details
0 16036846-b9d7-4c5b-be92-d7cf14aa2016 numpy uninstall_lib Started 2022-07-13T11:33:42Z None
1 16036846-b9d7-4c5b-be92-d7cf14aa2016 numpy uninstall_lib Finished 2022-07-13T11:33:42Z None
>>>
# Verify library is uninstalled.
>>> testenv.libs
library version
0 pip 20.1.1
1 setuptools 47.1.0
# Example 2: Install list of Python libraries asynchronously and uninstall them synchronously.
>>> testenv.install_lib(["pandas", "scikit-learn"], asynchronous=True)
Request to install libraries initiated successfully in the remote user environment testenv.
Check the status using status() with the claim id 'a91af321-cf57-43cc-b864-a67fa374cb42'.
# Check the status
>>> testenv.status('a91af321-cf57-43cc-b864-a67fa374cb42')
Claim Id File/Libs Method Name Stage Timestamp Additional Details
0 a91af321-cf57-43cc-b864-a67fa374cb42 pandas, scikit-learn install_lib Started 2022-07-13T11:34:38Z None
1 a91af321-cf57-43cc-b864-a67fa374cb42 pandas, scikit-learn install_lib Finished 2022-07-13T11:36:40Z None
>>>
# Verify libraries are installed along with its dependant libraries.
>>> testenv.libs
library version
0 joblib 1.1.0
1 numpy 1.21.6
2 pandas 1.3.5
3 pip 20.1.1
4 python-dateutil 2.8.2
5 pytz 2022.1
6 scikit-learn 1.0.2
7 scipy 1.7.3
8 setuptools 47.1.0
9 six 1.16.0
10 threadpoolctl 3.1.0
# Uninstall libraries by passing them as a list of library names.
>>> testenv.uninstall_lib(["pandas", "scikit-learn"])
Claim Id File/Libs Method Name Stage Timestamp Additional Details
0 8d6bb524-c047-4aae-8597-b48ab467ef37 pandas, scikit-learn uninstall_lib Started 2022-07-13T11:46:55Z None
1 8d6bb524-c047-4aae-8597-b48ab467ef37 pandas, scikit-learn uninstall_lib Finished 2022-07-13T11:47:20Z None
>>>
# Verify if the specified libraries are uninstalled.
>>> testenv.libs
library version
0 joblib 1.1.0
1 numpy 1.21.6
2 pip 20.1.1
3 python-dateutil 2.8.2
4 pytz 2022.1
5 scipy 1.7.3
6 setuptools 47.1.0
7 six 1.16.0
8 threadpoolctl 3.1.0
# Example 3: Install and uninstall libraries specified in
# requirement text file asynchronously.
# Install libraries by creating requirement.txt file.
# Create a requirement.txt file with below contents.
-----------------------------------------------------------
pandas
joblib==0.13.2
scikit-learn
numpy>=1.17.1
nltk>=3.3,<3.5
-----------------------------------------------------------
# Install libraries specified in the file.
>>> testenv.install_lib(libs_file_path="requirements.txt", asynchronous=True)
Request to install libraries initiated successfully in the remote user environment testenv.
Check the status using status() with the claim id 'c3669eea-327c-453f-b068-6b5f3f4768a5'.
# Check the status.
>>> testenv.status('c3669eea-327c-453f-b068-6b5f3f4768a5')
Claim Id File/Libs Method Name Stage Timestamp Additional Details
0 c3669eea-327c-453f-b068-6b5f3f4768a5 requirements.txt install_lib Started 2022-07-13T11:48:46Z None
1 c3669eea-327c-453f-b068-6b5f3f4768a5 requirements.txt install_lib Finished 2022-07-13T11:50:09Z None
>>>
# Verify libraries are installed along with its dependant libraries.
library version
0 joblib 1.1.0
1 numpy 1.21.6
2 pandas 1.3.5
3 pip 20.1.1
4 python-dateutil 2.8.2
5 pytz 2022.1
6 scikit-learn 1.0.2
7 scipy 1.7.3
8 setuptools 47.1.0
9 six 1.16.0
10 threadpoolctl 3.1.0
# Uninstall libraries specified in the file.
>>> testenv.uninstall_lib(libs_file_path="requirements.txt", asynchronous=True)
Request to uninstall libraries initiated successfully in the remote user environment testenv.
Check the status using status() with the claim id '95ebfc7b-2910-4aab-be80-3e47f84737bd'.
# Check the status.
>>> testenv.status('95ebfc7b-2910-4aab-be80-3e47f84737bd')
Claim Id File/Libs Method Name Stage Timestamp Additional Details
0 95ebfc7b-2910-4aab-be80-3e47f84737bd requirements.txt uninstall_lib Started 2022-07-13T11:52:03Z None
1 95ebfc7b-2910-4aab-be80-3e47f84737bd requirements.txt uninstall_lib Finished 2022-07-13T11:52:39Z None
>>>
# Verify if the specified libraries are uninstalled.
>>> testenv.libs
library version
0 joblib 1.1.0
1 numpy 1.21.6
2 pip 20.1.1
3 python-dateutil 2.8.2
4 pytz 2022.1
5 scipy 1.7.3
6 setuptools 47.1.0
7 six 1.16.0
8 threadpoolctl 3.1.0
# Example 4: Install and uninstall libraries specified in requirement text file synchronously
# by specifying the timeout.
# Install libraries by creating requirement.txt file.
# Create a requirement.txt file with below contents.
-----------------------------------------------------------
matplotlib
-----------------------------------------------------------
# Install libraries specified in the file.
>>> testenv.install_lib(libs_file_path="requirements.txt")
Claim Id File/Libs Method Name Stage Timestamp Additional Details
0 d441bc45-6594-4244-ba26-de2ca3272d3f requirements.txt install_lib Started 2022-08-12T06:03:54Z
1 d441bc45-6594-4244-ba26-de2ca3272d3f requirements.txt install_lib Finished 2022-08-12T06:04:44Z
>>>
# Verify libraries are installed along with its dependant libraries.
>>> testenv.libs
name version
0 cycler 0.11.0
1 fonttools 4.34.4
2 kiwisolver 1.4.4
3 matplotlib 3.5.3
4 numpy 1.21.6
5 packaging 21.3
6 Pillow 9.2.0
7 pip 20.1.1
8 pyparsing 3.0.9
9 python-dateutil 2.8.2
10 setuptools 47.1.0
11 six 1.16.0
12 typing-extensions 4.3.0
>>>
# Uninstall libraries specified in the file.
>>> testenv.uninstall_lib(libs_file_path="requirements.txt", timeout=1)
Request to uninstall libraries initiated successfully in the remote user environment 'testenv' but unable to get the status. Check the status using status() with the claim id '3e811857-969d-418c-893d-29ec38f54020'.
'3e811857-969d-418c-893d-29ec38f54020'
>>>
# Check the status.
>>> testenv.status('3e811857-969d-418c-893d-29ec38f54020')
Claim Id File/Libs Method Name Stage Timestamp Additional Details
0 3e811857-969d-418c-893d-29ec38f54020 requirements.txt uninstall_lib Started 2022-08-12T06:05:51Z
1 3e811857-969d-418c-893d-29ec38f54020 requirements.txt uninstall_lib Finished 2022-08-12T06:05:57Z
>>>
# Verify if the specified libraries are uninstalled.
>>> testenv.libs
name version
0 cycler 0.11.0
1 fonttools 4.34.4
2 kiwisolver 1.4.4
3 numpy 1.21.6
4 packaging 21.3
5 Pillow 9.2.0
6 pip 20.1.1
7 pyparsing 3.0.9
8 python-dateutil 2.8.2
9 setuptools 47.1.0
10 six 1.16.0
11 typing-extensions 4.3.0
>>>
# Examples for R environment.
# Create remote R user environment.
>>> r_env = create_env('test_r_env', 'r_4.1', 'Test R environment')
User environment 'test_r_env' created.
>>>
# Install R libraries in environment.
>>> r_env.install_lib(['glm2', 'stringi', "lubridate", "zoo", "anytime", "plyr", "testthat", "dplyr"])
Claim Id File/Libs Method Name Stage Timestamp Additional Details
0 6c7d049e-bf80-49a3-bee3-e058f78655fd glm2, stringi, lubridate, zoo, anytime, plyr, ... install_lib Started 2023-09-12T09:30:14Z
1 6c7d049e-bf80-49a3-bee3-e058f78655fd glm2, stringi, lubridate, zoo, anytime, plyr, ... install_lib Finished 2023-09-12T09:42:48Z
>>>
# Verify installed libraries.
>>> r_env.libs
name version
0 KernSmooth 2.23-20
1 MASS 7.3-55
2 Matrix 1.4-0
3 base 4.1.3
.. ... ...
33 anytime 0.3.9
.. ... ...
42 dplyr 1.1.3
.. ... ...
48 glm2 1.2.1
.. ... ...
52 lubridate 1.9.2
.. ... ...
57 plyr 1.8.8
.. ... ...
64 stringi 1.7.12
65 testthat 3.1.10
.. ... ...
72 withr 2.5.0
73 zoo 1.8-12
>>>
# Example 5: Uninstall single R library synchronously.
>>> r_env.uninstall_lib('glm2')
Claim Id File/Libs Method Name Stage Timestamp Additional Details
0 f98cfbfd-8b1d-4ff8-8145-001a1e5b2009 glm2 uninstall_lib Started 2023-09-12T10:14:59Z
1 f98cfbfd-8b1d-4ff8-8145-001a1e5b2009 glm2 uninstall_lib Finished 2023-09-12T10:15:01Z
# Verify if library is uninstalled.
>>> r_env.libs
name version
0 KernSmooth 2.23-20
1 MASS 7.3-55
2 Matrix 1.4-0
3 base 4.1.3
.. ... ...
33 anytime 0.3.9
.. ... ...
42 dplyr 1.1.3
.. ... ...
51 lubridate 1.9.2
.. ... ...
56 plyr 1.8.8
.. ... ...
63 stringi 1.7.12
64 testthat 3.1.10
.. ... ...
71 withr 2.5.0
72 zoo 1.8-12
>>>
# Example 6: Uninstall multiple R libraries synchronously
# by passing them as a list of library names.
>>> r_env.uninstall_lib(['stringi', "lubridate"])
Claim Id File/Libs Method Name Stage Timestamp Additional Details
0 11103430-62fa-4983-ae52-fa176c5efa93 stringi, lubridate uninstall_lib Started 2023-09-12T10:21:21Z
1 11103430-62fa-4983-ae52-fa176c5efa93 stringi, lubridate uninstall_lib Finished 2023-09-12T10:21:23Z
>>>
# Verify if libraries are uninstalled.
>>> r_env.libs
name version
0 KernSmooth 2.23-20
1 MASS 7.3-55
2 Matrix 1.4-0
3 base 4.1.3
.. ... ...
33 anytime 0.3.9
.. ... ...
42 dplyr 1.1.3
.. ... ...
55 plyr 1.8.8
.. ... ...
62 testthat 3.1.10
.. ... ...
69 withr 2.5.0
70 zoo 1.8-12
>>>
# Example 7: Uninstall libraries synchronously by specifying
# them in a file.
# Create a requirement.json file with below contents.
-----------------------------------------------------------
{
"packages": ["zoo", "anytime"]
}
-----------------------------------------------------------
# Uninstall libraries specified in the file.
>>> r_env.uninstall_lib(libs_file_path="requirement.json")
Claim Id File/Libs Method Name Stage Timestamp Additional Details
0 7fbba8d7-7f16-47d1-b02d-b1df8a79ad6b requirement.json uninstall_lib Started 2023-09-12T12:14:31Z
1 7fbba8d7-7f16-47d1-b02d-b1df8a79ad6b requirement.json uninstall_lib Finished 2023-09-12T12:14:33Z
>>>
# Verify if libraries are uninstalled.
>>> r_env.libs
name version
0 KernSmooth 2.23-20
1 MASS 7.3-55
2 Matrix 1.4-0
3 base 4.1.3
.. ... ...
41 dplyr 1.1.3
.. ... ...
54 plyr 1.8.8
.. ... ...
61 testthat 3.1.10
.. ... ...
68 withr 2.5.0
# Example 8: Uninstall R libraries asynchronously.
>>> r_env.uninstall_lib(["plyr", "testthat"], asynchronous=True)
Request to uninstall libraries initiated successfully in the remote user environment test_r_env. Check the status using status() with the claim id 'e6f90aaf-ecf5-467d-95cb-8032444494d6'.
'e6f90aaf-ecf5-467d-95cb-8032444494d6'
>>>
# Check the status using claim id.
>>> r_env.status('e6f90aaf-ecf5-467d-95cb-8032444494d6')
Claim Id File/Libs Method Name Stage Timestamp Additional Details
0 e6f90aaf-ecf5-467d-95cb-8032444494d6 plyr, testthat uninstall_lib Started 2023-09-12T12:18:50Z
1 e6f90aaf-ecf5-467d-95cb-8032444494d6 plyr, testthat uninstall_lib Finished 2023-09-12T12:18:51Z
>>>
# Verify if libraries are uninstalled.
>>> r_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
.. ... ...
41 dplyr 1.1.3
.. ... ...
65 waldo 0.5.1
66 withr 2.5.0
>>>