Use the remove_all_env function to remove all user environments from Open Analytics Framework.
This function allows you to remove only Python user environments, or only R user environments, or all user environments, based on the value passed to the argument env_type.
Do not trigger remove_all_envs() if any of the library management functions (install_lib()/uninstall_lib()/update_lib()) is running on any environment.
Optional Arguments
- env_type
- Specifies the type of the user environment to be removed.
**kwargs: Specifies the keyword arguments.
- asynchronous
- Specifies whether to remove environment synchronously or asynchronously.
This function returns True when the following are true:
- Operation is synchronous.
- Operation is asynchronous with specific env_type.
Example 1: Remove all user environments synchronously
- Create user environments.
>>> create_env('Lie_Detection_ML', 'python_3.8.13', 'Detect lie through machine learning.')
>>> create_env('Customer_Trends', 'r_4.1.3', 'Analyse customer trends.')
- List user environments.
>>> list_user_envs()
env_name env_description base_env_name language 0 Customer_Trends Analyse customer trends r_4.1.3 R 1 Lie_Detection_ML Detect lie through machine learning. python_3.8.13 Python
- Remove all user environments.
>>> remove_all_envs()
All user environment(s) removed. True
- Verify all user environments are removed.
>>> list_user_envs()
No user environment(s) found.
Example 2: Remove all Python user environments synchronously
- Create user environments.
>>> create_env('Lie_Detection_ML', 'python_3.8.13', 'Detect lie through machine learning.')
>>> create_env('Customer_Trends', 'r_4.1.3', 'Analyse customer trends.')
- List user environments.
>>> list_user_envs()
env_name env_description base_env_name language 0 Customer_Trends Analyse customer trends r_4.1.3 R 1 Lie_Detection_ML Detect lie through machine learning. python_3.8.13 Python
- Remove all Python user environments.
>>> remove_all_envs(env_type="PY")
User environment 'Lie_Detection_ML' removed. All Python environment(s) removed. True
- Verify all Python user environments are removed.
>>> list_user_envs()
env_name env_description base_env_name language 0 Customer_Trends Analyse customer trends r_4.1.3 R
Example 3: Remove all R user environments synchronously
- Create user environments.
>>> create_env('Lie_Detection_ML', 'python_3.8.13', 'Detect lie through machine learning.')
>>> create_env('Customer_Trends', 'r_4.1.3', 'Analyse customer trends.')
- List user environments.
>>> list_user_envs()
env_name env_description base_env_name language 0 Customer_Trends Analyse customer trends r_4.1.3 R 1 Lie_Detection_ML Detect lie through machine learning. python_3.8.13 Python
- Remove all R user environments.
>>> remove_all_envs(env_type="R")
User environment 'Customer_Trends' removed. All R environment(s) removed. True
- Verify all R user environments are removed.
>>> list_user_envs()
env_name env_description base_env_name language 0 Lie_Detection_ML Detect lie through machine learning. python_3.8.13 Python
Example 4: Remove synchronously all R environments first and then all remaining Python environments
This example first removes all R environments synchronously, followed by Python environments.
- Create user environments.
>>> env1 = create_env("env1", "python_3.7.13", "Environment 1")
>>> env2 = create_env("env2", "python_3.7.13", "Environment 2")
>>> env3 = create_env("env3", "r_4.1", "Environment 3")
>>> env4 = create_env("env4", "r_4.1", "Environment 4")
- List user environments.
>>> list_user_envs()
env_name env_description base_env_name language 0 env1 Environment 1 python_3.7.13 Python 1 env2 Environment 2 python_3.7.13 Python 2 env3 Environment 3 r_4.1 R 3 env4 Environment 4 r_4.1 R
- Remove all R user environments.
>>> remove_all_envs(env_type="R")
User environment 'env3' removed. User environment 'env4' removed. All R environment(s) removed. True
- Verify all R user environments are removed.
>>> list_user_envs()
env_name env_description base_env_name language 0 env1 Environment 1 python_3.7.13 Python 1 env2 Environment 2 python_3.7.13 Python
- Try to remove R environments again.
>>> remove_all_envs(env_type="R")
No R user environment(s) found. True
- Remove all remaining Python environments.
>>> remove_all_envs()
All user environment(s) removed. True
Example 5: Remove asynchronously all R environments first and then all remaining Python environments
This example first removes all R environments asynchronously, followed by Python environments.
- Create user environments.
>>> env1 = create_env("env1", "python_3.7.13", "Environment 1")
>>> env2 = create_env("env2", "python_3.7.13", "Environment 2")
>>> env3 = create_env("env3", "r_4.1", "Environment 3")
>>> env4 = create_env("env4", "r_4.1", "Environment 4")
- List user environments.
>>> list_user_envs()
env_name env_description base_env_name language 0 env1 Environment 1 python_3.7.13 Python 1 env2 Environment 2 python_3.7.13 Python 2 env3 Environment 3 r_4.1 R 3 env4 Environment 4 r_4.1 R
- Remove all R environments asynchronously.
>>> remove_all_envs(env_type="R", asynchronous=True)
Request to remove environment initiated successfully. Check the status using async_run_status(['5c23f956-c89a-4d69-9f1e-6491bac9973f', '6ec9ecc9-9223-4d3f-92a0-9d1abc652aca']) True
- Verify all R user environments are removed.
>>> list_user_envs()
env_name env_description base_env_name language 0 env1 Environment 1 python_3.7.13 Python 1 env2 Environment 2 python_3.7.13 Python
- Remove all remaining Python environments asynchronously.
>>> remove_all_envs(asynchronous=True)
Request to remove environment initiated successfully. Check the status using async_run_status('7d86eb99-9ab3-4e0d-b4dd-8b5f1757b9c7') '7d86eb99-9ab3-4e0d-b4dd-8b5f1757b9c7'
Example 6: Remove all environments asynchronously
- Create user environments.
>>> env1 = create_env("env1", "python_3.7.13", "Environment 1")
>>> env2 = create_env("env2", "python_3.7.13", "Environment 2")
>>> env3 = create_env("env3", "r_4.1", "Environment 3")
>>> env4 = create_env("env4", "r_4.1", "Environment 4")
- List user environments.
>>> list_user_envs()
env_name env_description base_env_name language 0 env1 Environment 1 python_3.7.13 Python 1 env2 Environment 2 python_3.7.13 Python 2 env3 Environment 3 r_4.1 R 3 env4 Environment 4 r_4.1 R
- Remove all environments asynchronously.
>>> remove_all_envs(asynchronous=True)
Request to remove environment initiated successfully. Check the status using async_run_status('22f5d693-38d2-469e-b434-9f7246c7bbbb') '22f5d693-38d2-469e-b434-9f7246c7bbbb'