Skip to main content

Cloud Executor

cc.CloudExecutor

#

CloudExecutor represents a configuration for executing a Covalent workflow on the Covalent Cloud. This class allows users to configure the resources (such as the number of CPUs, memory, GPUs, and GPU type) and the software environment for a Covalent workflow that will be executed on the Covalent Cloud. The time limit for the workflow execution can also be set.

num_cpus

#

Number of CPUs to be used for the workflow. Defaults to 1.

Type

int, optional

memory

#

Amount of memory (in MB) to be used for the workflow. Defaults to 1024.

Type

int, optional

num_gpus

#

Number of GPUs to be used for the workflow. Defaults to 0.

Type

int, optional

gpu_type

#

Type of GPU to be used for the workflow. Defaults to an empty string.

Type

str, optional

env

#

Name of the software environment to be used for the workflow. Defaults to “default”.

Type

str, optional

time_limit

#

Time limit for the workflow execution, in seconds or as a timedelta. Defaults to 1800s (30 mins). Alternatively can take human readable string in format 'in <number> <unit(s)>'

Type

Union[int, timedelta], optional

volume_id

#

ID of the volume to be used for the workflow. Defaults to None.

Type

int, optional

settings

#

Settings object to be used for the workflow. Defaults to the global settings object.

Type

Settings, optional

validate_environment

#

Whether to validate the environment before dispatching the workflow. Defaults to True.

Type

bool, optional

Examples

# create a CloudExecutor with default resource configuration
# executor = CloudExecutor()

# create a custom CloudExecutor with specified resources and environment
# executor = CloudExecutor(
# num_cpus=4,
# memory=2048,
# num_gpus=1,
# gpu_type="NVIDIA-Tesla-V100",
# env="my_custom_env",
# time_limit="in 30 minutes" # 30 minutes
# )

import covalent as ct
from covalent_cloud import CloudExecutor

cloud_executor1 = CloudExecutor(num_cpus=1, memory=1024)
cloud_executor2 = CloudExecutor(num_cpus=2, memory=2048)
cloud_executor3 = CloudExecutor(num_cpus=1, memory=512)

# Define manageable tasks as electrons with different cloud executors
@ct.electron(executor=cloud_executor1)
def add(x, y):
return x + y

@ct.electron(executor=cloud_executor2)
def multiply(x, y):
return x * y

@ct.electron(executor=cloud_executor3)
def divide(x, y):
return x / y

# Define the workflow as a lattice
@ct.lattice
def workflow(x, y):
r1 = add(x, y)
r2 = [multiply(r1, y) for _ in range(4)]
r3 = [divide(x, value) for value in r2]
return r3

# Import the Covalent Cloud module
import covalent_cloud as cc

# Dispatch the workflow to the Covalent Cloud
dispatch_id = cc.dispatch(workflow)(1, 2)
result = cc.get_result(dispatch_id, wait=True)
print(result)