Skip to contents

Creates and configures a Conda environment specifically designed for screening workflows. This function provides multiple methods for environment creation and package installation, including support for environment files, with comprehensive verification and error handling.

Usage

# S3 method for class 'conda'
SetupPyEnv(
  env_type = "conda",
  env_name = "r-reticulate-degas",
  method = c("reticulate", "system", "environment"),
  env_file = NULL,
  python_version = "3.9.15",
  packages = c(tensorflow = "2.4.1", protobuf = "3.20.3"),
  recreate = FALSE,
  use_conda_forge = TRUE,
  verbose = TRUE,
  timeout = 1800000,
  ...
)

Arguments

env_type

Character string specifying the environment type. For this method, must be "conda".

env_name

Character string specifying the Conda environment name. Default: "r-reticulate-degas".

method

Character string specifying the method for environment creation and package installation. One of: "reticulate" (uses reticulate package), "system" (uses system conda commands), or "environment" (uses YAML environment file). Default: "reticulate".

env_file

Character string specifying the path to a Conda environment YAML file. Used when method = "environment". Default: NULL

python_version

Character string specifying the Python version to install. Default: "3.9.15".

packages

Named character vector of Python packages to install. Package names as names, versions as values. Use "any" for version to install latest available. Default includes tensorflow, protobuf, and numpy.

recreate

Logical indicating whether to force recreation of the environment if it already exists. Default: FALSE.

use_conda_forge

Logical indicating whether to use the conda-forge channel for package installation. Default: TRUE.

verbose

Logical indicating whether to display detailed progress messages and command output. Default: TRUE.

timeout

The maximum timeout time when using system commands, default: 30 miniutes

...

For future compatibility.

Value

Invisibly returns NULL.

Note

The function requires Conda to be installed and accessible on the system PATH or through reticulate. For method = "environment", the specified YAML file must exist and be properly formatted. The function includes extensive error handling but may fail if Conda is not properly configured.

See also

reticulate::conda_create(), reticulate::py_install() for the underlying functions used in reticulate method.

Examples

if (FALSE) { # \dontrun{
# Setup using reticulate method (default)
SetupPyEnv.conda(
  env_name = "my-degas-env",
  python_version = "3.9.15"
)

# Setup using environment file
SetupPyEnv.conda(
  method = "environment",
  env_file = "path/to/environment.yml"
)

# Setup with custom packages
SetupPyEnv.conda(
  packages = c(
    "tensorflow" = "2.4.1",
    "scikit-learn" = "1.0.2",
    "pandas" = "any"
  )
)
} # }