Skip to main content

Create Environment

cc.create_env

#

Sends the create request to the Covalent Cloud server with the environment dependency list.

Parameters

name (str)

Identifier/name for the software environment.

pip (Union[str, List[str]])

Python packages to be installed in the environment using pip. This value can be a string requirements.txt and/or a list of packages. Note, that if it's a list, it's possible that one of the values is the string requirements.txt. In case a requirements.txt is passed, it will be parsed into a list of packages and combined with the list of packages passed.

conda (Union[str, List[str], Dict[str, List[str]]])

List of packages to be installed in the environment using conda. This value can either be a list of packages, a filepath to environment.yml. It could also be a dictionary with channels, dependencies, and (optionally) variables as keys, and a list of strings as their values.

variables

Environment variables to be set during custom or Covalent build phase.

settings

Settings object with the dispatcher URI.

wait

If True, waits until the environment is ready before returning.

timeout

Timeout in seconds for the environment to be ready.

For example:

conda={
“channels”: [“conda-forge”, “defaults”],
“dependencies”: [“numpy=1.21.*”, “xarray=0.15.1”],
“variables”: [{‘name’: ‘mock-variable-1’, ‘value’: ‘1’, ‘sensitive’: True}]
}

Whatever is passed, it will be parsed into a dictionary as shown above and sent as JSON to the Covalent Cloud server. If a list of packages is provided, they will be installed using the default conda channel.

Return Type

None

Returns

None

Examples

Create an environment with a list of packages:
 create_env("test-env", ["typing"], ["numpy=1.21.*", "xarray=0.15.1"])
Create an environment with a filepath to *environment.yml*:
 create_env("test-env", "requirements.txt", "environment.yml")
Create an environment with a dictionary of channels, dependencies, and variables:
 create_env("test-env", "requirements.txt", {"channels": ["conda-forge", "defaults"], "dependencies": ["numpy=1.21.*", "xarray=0.15.1"], "variables": [{'name': 'mock-variable-1', 'value': '1', 'sensitive': True}]})

Note

In case of a conflict of package between pip and conda, pip will take precedence and the conda one will be ignored.