View source: R/22_SetupPyEnv.R
| SetupPyEnv.conda | R Documentation |
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.
## 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,
...
)
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. |
... |
Additional arguments. Currently supports:
|
Invisibly returns NULL.
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.
reticulate::conda_create(), reticulate::py_install() for the underlying
functions used in reticulate method.
## Not run:
# 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"
)
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.