Skip to main content

 

Covalent Azure Batch Plugin

Covalent is a Pythonic workflow tool used to execute tasks on advanced computing hardware. This executor plugin interfaces Covalent with Microsoft Azure Batch.

1. Installation

To use this plugin with Covalent, install it using pip:

pip install covalent-azurebatch-plugin

2. Usage Example

This is an example of how a workflow can be constructed to use the Azure Batch executor. In the example, we train a Support Vector Machine (SVM) and use an instance of the executor to execute the train_svm electron. Note that we also require DepsPip which will be required to execute the electrons.

from numpy.random import permutation
from sklearn import svm, datasets
import covalent as ct

from covalent.executor import AzureBatchExecutor

deps_pip = ct.DepsPip(
    packages=["numpy==1.22.4", "scikit-learn==1.1.2"]
)

executor = AzureBatchExecutor(
    tenant_id="tenant-id",
    client_id="client-id",
    client_secret="client-secret",
    batch_account_url="https://covalent.eastus.batch.azure.com",
    batch_account_domain="batch.core.windows.net",
    storage_account_name="covalentbatch",
    storage_account_domain="blob.core.windows.net",
    base_image_uri="covalent.azurecr.io/covalent-executor-base:latest",
    pool_id="covalent-pool",
    retries=3,
    time_limit=300,
    cache_dir="/tmp/covalent",
    poll_freq=10
)


# Use executor plugin to train our SVM model
@ct.electron(
    executor=executor,
    deps_pip=deps_pip
)
def train_svm(data, C, gamma):
    X, y = data
    clf = svm.SVC(C=C, gamma=gamma)
    clf.fit(X[90:], y[90:])
    return clf

@ct.electron
def load_data():
    iris = datasets.load_iris()
    perm = permutation(iris.target.size)
    iris.data = iris.data[perm]
    iris.target = iris.target[perm]
    return iris.data, iris.target

@ct.electron
def score_svm(data, clf):
    X_test, y_test = data
    return clf.score(
    	X_test[:90],y_test[:90]
    )

@ct.lattice
def run_experiment(C=1.0, gamma=0.7):
    data = load_data()
    clf = train_svm(
    	data=data,
	    C=C,
	    gamma=gamma
    )
    score = score_svm(
    	data=data,
	    clf=clf
    )
    return score

# Dispatch the workflow.
dispatch_id = ct.dispatch(run_experiment)(
        C=1.0,
        gamma=0.7
)

# Wait for our result and get result value
result = ct.get_result(dispatch_id, wait=True).result

print(result)

During the execution of the workflow, one can navigate to the UI to see the status of the workflow. Once completed, the above script should also output a value with the score of our model.

0.8666666666666667

In order for the above workflow to run successfully, one has to provision the required cloud resources as mentioned in the section Required Microsoft Azure Batch Resources.

3. Configuration

There are many configuration options that can be passed in to the class ct.executor.AzureBatchExecutor or by modifying the covalent config file under the section [executors.azurebatch].

For more information about all of the possible configuration values visit our read the docs (RTD) guide for this plugin.

4. Required Microsoft Azure Resources

In order to run your workflows with covalent there are a few notable Microsoft Azure resources that need to be provisioned first.

The required Azure resources are:

1. Batch account

2. Storage account

3. Resource group

4. Container registry (custom images only)

5. Pool of compute nodes

For more information regarding which cloud resources need to be provisioned visit our read the docs (RTD) guide for this plugin.

Getting Started with Covalent

For more information on how to get started with Covalent, check out the project homepage and the official documentation.

Release Notes

Release notes are available in the Changelog.

Citation

Please use the following citation in any publications:

W. J. Cunningham, S. K. Radha, F. Hasan, J. Kanem, S. W. Neagle, and S. Sanand. Covalent. Zenodo, 2022. https://doi.org/10.5281/zenodo.5903364

License

Covalent is licensed under the Apache License 2.0. See the LICENSE file or contact the support team for more details.

Metadata

Release files for covalent-azurebatch-plugin 0.17.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for covalent-azurebatch-plugin 0.17.0
File Size Uploaded
covalent-azurebatch-plugin-0.17.0.tar.gz 19.3 kB Details

Release files / covalent-azurebatch-plugin-0.17.0.tar.gz

Download URL covalent-azurebatch-plugin-0.17.0.tar.gz
Size 19.3 kB
Tags Source
SHA-256 checksum
How to use checksums
92ff8922be87dc3a11f26c5dacc7ea4333897f8746eeff835362931509e04e86
BLAKE2b-256 checksum
How to use checksums
d58a49ce6016557e207f7833be16d38b91ab7ca918f56a684ea11c5b374a06a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

Release history Release notifications | RSS feed

This release

0.17.0 This release

1 release file

0.14.0

1 release file

0.12.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page