4.2 Administrative Tasks for Creating and Saving a Conda Environment

In OML Notebooks, user ADMIN can manage the lifecycle of the OML user's conda environments, including creating and deleting environments and installing and deleting packages.

The conda environments created by user ADMIN are stored in an Object Storage bucket folder associated with the Autonomous Database instance. OML users can download these conda environments using enhanced conda commands. Conda environments are available after they are downloaded and activated using the download and activate functions in a %conda paragraph. An activated environment is available until it is deactivated.

Create a Conda enviroment

As an ADMIN user in an OML Notebook, specify a conda interpreter in a paragraph using %conda, then use the create command to create a conda environment named myrenv to install the the forecast and ggplot2 packages package. Specify the R base version using the r-base parameter. Here, R-4.0.5 is used for compatibility with OML4R.

Note:

When conda installs a package into an environment, it also installs any required dependencies. As a best practice, to avoid dependency conflicts, simultaneously install all the packages you need in a specific environment.
%conda

create -n myrenv -c conda-forge --override-channels --strict-channel-priority r-base=4 r-forecast r-ggplot2

Upload the environment to Object Storage

Upload the environment to the Object Storage associated with the Autonomous Database instance. Here you provide an environment description and a tag corresponding to an application name, OML4R.

%conda

upload myrenv --overwrite --description 'Install R forecast and ggplot2 packages' -t user 'OMLUSER' -t application 'OML4R'
Uploading conda environment myrenv
Upload successful for conda environment myrenv

The environment is now available for an OML user to download. The uploaded environment will persist in Object Storage until it is deleted. The application tag is required for use with embedded execution. For example, OML4Py embedded Python execution works with conda environments containing the OML4Py tag, and OML4R embedded R execution works with conda environments containing the OML4R tag.

There is one Object Storage bucket for each data center region. The conda environments are saved to a folder in Object Storage corresponding to the tenancy and database. The folder is managed by Autonomous Database and only available to users through OML Notebooks. There is an 8G maximum size for a single conda environment, and no size limit on Object Storage.

Logged in as a non-administrator user, specify the conda interpreter in a notebook paragraph using %conda. Get the list of environments saved in Object Storage using the list-saved-envs command.

%conda

list-saved-envs

Verify the environments are saved to Object storage using the list-saved-envs, passing the environment name to the -e flag.

%conda

list-saved-envs -e myrenv

The output is similar to the following:

{
  "name": "myrenv",
  "size": "850.4 MiB",
  "description": "Install R forecast and ggplot2 packages",
  "tags": {
    "application": "OML4R",
    "user": "OMLUSER"
  },
  "number_of_installed_packages": 153
}

Delete an environment saved in Object Storage

Use the delete command to delete an environment saved in an Object Storage.

Note:

Only user ADMIN can delete an environment saved in an Object Storage.
%conda

delete myrenv
Deleting conda environment myrenv
Deletion successful for conda environment myrenv