list_user_envs | Manage User Environments | Open Analytics Framework - list_user_envs - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Use the list_user_envs function to list the Python or R environments created by the session user in Open Analytics Framework.

This function helps user find environments created, version of Python or R language used in the environment, and description of each environment if provided at the time of environment creation.

Optional Arguments

env_name
Specifies a string or regular expression to filter name of the environment.
base_env
Specifies a string or regular expression to filter the base Python environment.
desc
Specifies a string or regular expression to filter the description about the environment.
case
Specifies whether filtering operation is case sensitive.
Default value is False.
conda_env
Specifies the boolean value to filter the conda environments.
  • When set to True, all conda environments are listed.
  • When set to False, all non-conda environments are listed.
  • If not specified, all user environments are listed.
regex
Specifies whether string passed to env_name, base_env, and desc is to be treated as regular expression or a literal.
  • When set to True, string is considered as a regular expression pattern.
  • When set to False, function treats the string as literal string.
Default value is True.
flags
Specifies flags to pass for regular expressions in filtering.
For example: re.IGNORECASE.
Default value is 0.

This function returns remote user environments and their details in a pandas DataFrame.

Example Prerequisite: Create example environments

  • >> create_env('Fraud_Detection',
                   'python_3.7.13',
                   'Fraud detection through time matching')
    User environment 'Fraud_detection' created.
  • >>> create_env('Lie_Detection',
                   'python_3.7.13',
                   'Lie detection through time matching')
    User environment 'Lie_Detection' created.
  • >>> create_env('Lie_Detection_ML',
                   'python_3.8.13',
                   'Detect lie through machine learning.')
    User environment 'Lie_Detection_ML' created.
  • >>> create_env('Sales_env',
                   'python_3.9.13',
                   'Sales team environment.')
    User environment 'Sales_env' created.
  • >>> create_env('Customer_Trends',
                   'r_4.1.3',
                   'Analyse customer trends.')
    User environment 'Customer_Trends' created.
  • >>> create_env('Carbon_Credits',
                   'r_3.6.3',
                   'Prediction of carbon credits consumption.')
    User environment 'Carbon_Credits' created.
  • >>> create_env('Sales_cond_env',
                   'python_3.9',
                   'Sales team environment.',
                   conda_env=True)
    Conda environment creation initiated
    User environment 'Sales_cond_env' created.

Example 1: List all available user environments

>>> list_user_envs()
           env_name                           env_description  base_env_name language  conda
0    Carbon_Credits  Prediction of carbon credits consumption        r_3.6.3        R  False
1   Customer_Trends                   Analyse customer trends        r_4.1.3        R  False
2   Fraud_Detection     Fraud detection through time matching  python_3.7.13   Python  False
3     Lie_Detection       Lie detection through time matching  python_3.7.13   Python  False
4  Lie_Detection_ML      Detect lie through machine learning.  python_3.8.13   Python  False
5         Sales_env                   Sales team environment.  python_3.9.13   Python  False
6    Sales_cond_env                   Sales team environment.     python_3.9   Python  True

Example 2: List all user environments with specific environment name and description

This function lists all user environments with environment name containing string "Detection" and description that contains string "."(period).

>>> list_user_envs(env_name="Detection", desc=".", regex=False)
           env_name                       env_description  base_env_name language  conda
4  Lie_Detection_ML  Detect lie through machine learning.  python_3.8.13   Python  False

Example 3: List all user environments with specific description and is case sensitive

This function lists all user environments with description that contains string "lie" and is case sensitive.

>>> list_user_envs(desc="lie", case=True)
           env_name                       env_description  base_env_name language  conda
4  Lie_Detection_ML  Detect lie through machine learning.  python_3.8.13   Python  False

Example 4: List all user environments with base environment version containing string "3."

>>> list_user_envs(base_env="3.")
           env_name                           env_description  base_env_name language  conda
0    Carbon_Credits  Prediction of carbon credits consumption        r_3.6.3        R  False
2   Fraud_Detection     Fraud detection through time matching  python_3.7.13   Python  False
3     Lie_Detection       Lie detection through time matching  python_3.7.13   Python  False
4  Lie_Detection_ML      Detect lie through machine learning.  python_3.8.13   Python  False
5         Sales_env                   Sales team environment.  python_3.9.13   Python  False
6   Sales_conda_env                   Sales team environment.     python_3.9   Python  True

Example 5: List all user environments with specific environment name, description and base environment

This function lists all user environments with environment name contains string "detection", description containing string "fraud" and base environment containing string "3.7".

>>> list_user_envs("detection", desc="fraud", base_env="3.7")
          env_name                        env_description  base_env_name language  conda
2  Fraud_Detection  Fraud detection through time matching  python_3.7.13   Python  False

Example 6: List all user environments with environment name that ends with "detection"

>>> list_user_envs("detection$")
          env_name                        env_description  base_env_name language  conda
2  Fraud_Detection  Fraud detection through time matching  python_3.7.13   Python  False
3    Lie_Detection    Lie detection through time matching  python_3.7.13   Python  False

Example 7: List all user environments with description that has either "lie" or "sale"

Use re.VERBOSE flag to add inline comment.
>>> list_user_envs(desc="lie|sale # Search for lie or sale.", flags=re.VERBOSE)
           env_name                       env_description  base_env_name language  conda
3     Lie_Detection   Lie detection through time matching  python_3.7.13   Python  False
4  Lie_Detection_ML  Detect lie through machine learning.  python_3.8.13   Python  False
5         Sales_env               Sales team environment.  python_3.9.13   Python  False
6   Sales_conda_env               Sales team environment.     python_3.9   Python  True

Example 8: List all user environments where environment language release version has odd number

This example lists all user environments where environment language release version has odd number, for example, python_3.7.x.

>>> list_user_envs(base_env="\.\d*[13579]\.")
          env_name                        env_description  base_env_name language  conda
1  Customer_Trends                Analyse customer trends        r_4.1.3        R  False
2  Fraud_Detection  Fraud detection through time matching  python_3.7.13   Python  False
3    Lie_Detection    Lie detection through time matching  python_3.7.13   Python  False
5        Sales_env                Sales team environment.  python_3.9.13   Python  False

Example 9: List all conda environment

>>> list_user_envs(conda_env=True)
          env_name                       env_description  base_env_name language  conda
6   Sales_conda_env                   Sales team environment.     python_3.9   Python  True

Examples Clean Up: Remove example environments

remove_env("Fraud_Detection")
remove_env("Lie_Detection")
remove_env("Lie_Detection_ML")
remove_env("Sales_env")
remove_env("Carbon_Credits")
remove_env("Customer_Trends")
remove_env("Sales_conda_env")