{"id":20749291,"url":"https://github.com/agnostiqhq/covalent-awslambda-plugin","last_synced_at":"2025-04-28T12:44:13.718Z","repository":{"id":56794922,"uuid":"516588105","full_name":"AgnostiqHQ/covalent-awslambda-plugin","owner":"AgnostiqHQ","description":"Executor plugin interfacing Covalent with AWS Lambda","archived":false,"fork":false,"pushed_at":"2025-03-31T16:52:39.000Z","size":470,"stargazers_count":8,"open_issues_count":10,"forks_count":1,"subscribers_count":10,"default_branch":"develop","last_synced_at":"2025-04-14T00:11:57.391Z","etag":null,"topics":["aws-lambda","covalent","parallelization","pipelines","python","serverless-functions","workflow"],"latest_commit_sha":null,"homepage":"https://covalent.xyz","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AgnostiqHQ.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-22T02:49:40.000Z","updated_at":"2023-08-20T03:15:58.000Z","dependencies_parsed_at":"2024-02-19T18:31:33.336Z","dependency_job_id":"7ea3e94b-df76-48a2-a6bf-ad90f2dfc0d4","html_url":"https://github.com/AgnostiqHQ/covalent-awslambda-plugin","commit_stats":{"total_commits":91,"total_committers":13,"mean_commits":7.0,"dds":0.5714285714285714,"last_synced_commit":"16a6491ff991e0c60bdcfc4d90a406bdad54f7d9"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":"AgnostiqHQ/covalent-executor-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgnostiqHQ%2Fcovalent-awslambda-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgnostiqHQ%2Fcovalent-awslambda-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgnostiqHQ%2Fcovalent-awslambda-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgnostiqHQ%2Fcovalent-awslambda-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AgnostiqHQ","download_url":"https://codeload.github.com/AgnostiqHQ/covalent-awslambda-plugin/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251315684,"owners_count":21569848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","covalent","parallelization","pipelines","python","serverless-functions","workflow"],"created_at":"2024-11-17T08:22:06.024Z","updated_at":"2025-04-28T12:44:13.679Z","avatar_url":"https://github.com/AgnostiqHQ.png","language":"Python","readme":"\u0026nbsp;\n\n\u003cdiv align=\"center\"\u003e\n\n\u003cimg src=\"./assets/aws_lambda_readme_banner.jpg\" width=150%\u003e\n\n[![covalent](https://img.shields.io/badge/covalent-0.177.0-purple)](https://github.com/AgnostiqHQ/covalent)\n[![python](https://img.shields.io/pypi/pyversions/covalent-awslambda-plugin)](https://github.com/AgnostiqHQ/covalent-awslambda-plugin)\n[![tests](https://github.com/AgnostiqHQ/covalent-awslambda-plugin/actions/workflows/tests.yml/badge.svg)](https://github.com/AgnostiqHQ/covalent-awslambda-plugin/actions/workflows/tests.yml)\n[![codecov](https://codecov.io/gh/AgnostiqHQ/covalent-awslambda-plugin/branch/main/graph/badge.svg?token=QNTR18SR5H)](https://codecov.io/gh/AgnostiqHQ/covalent-awslambda-plugin)\n[![apache](https://img.shields.io/badge/License-Apache_License_2.0-blue)](https://www.apache.org/licenses/LICENSE-2.0)\n\n\u003c/div\u003e\n\n## Covalent AWS Lambda Plugin\n\nCovalent is a Pythonic workflow tool used to execute tasks on advanced computing hardware. This executor plugin interfaces Covalent with [AWS Lambda](https://aws.amazon.com/lambda/) for dispatching computational tasks.\n\n## 1. Installation\n\nTo use this plugin with Covalent, install it using `pip`:\n\n```sh\npip install covalent-awslambda-plugin\n```\n\n## 2. Usage Example\n\nThis is an example of how a workflow can be constructed to use the AWS Lambda executor.\nIn the example, we train a Support Vector Machine (SVM) and use an instance of the executor\nto execute the `train_svm` electron. Note that we also require [DepsPip](https://covalent.readthedocs.io/en/latest/concepts/concepts.html#depspip) which will be required to execute the electrons.\n\nThe `AWSLambdaExecutor` requires a container based AWS lambda function to already have been created in the user's AWS account with its `Container image URI` configured properly. Users can use Covalent's public Lambda executor registry i.e. `public.ecr.aws/covalent/covalent-lambda-executor:stable` when creating their Lambda functions.\nThis public ECR registry holds the base container image the lambda function can use to execute tasks from a workflow.\n\nUser's can pass in the name of their Lambda function to the constructor using the `function_name` argument. See our [documentation](https://covalent.readthedocs.io/en/latest/api/executors/awslambda.html) for more details.\n\n```python\nfrom numpy.random import permutation\nfrom sklearn import svm, datasets\nimport covalent as ct\n\ndeps_pip = ct.DepsPip(\n        packages=[\"numpy==1.23.2\", \"scikit-learn==1.1.2\"]\n)\n\nexecutor = ct.executor.AWSLambdaExecutor(\n        function_name=\"my-lambda-function\",\n        s3_bucket_name=\"covalent-lambda-job-resources\",\n)\n\n# Use executor plugin to train our SVM model.\n@ct.electron(\n    executor=executor,\n    deps_pip=deps_pip\n)\ndef train_svm(data, C, gamma):\n    X, y = data\n    clf = svm.SVC(C=C, gamma=gamma)\n    clf.fit(X[90:], y[90:])\n    return clf\n\n@ct.electron\ndef load_data():\n    iris = datasets.load_iris()\n    perm = permutation(iris.target.size)\n    iris.data = iris.data[perm]\n    iris.target = iris.target[perm]\n    return iris.data, iris.target\n\n@ct.electron\ndef score_svm(data, clf):\n    X_test, y_test = data\n    return clf.score(\n        X_test[:90], y_test[:90]\n    )\n\n@ct.lattice\ndef run_experiment(C=1.0, gamma=0.7):\n    data = load_data()\n    clf = train_svm(\n        data=data,\n        C=C,\n        gamma=gamma\n    )\n    score = score_svm(\n        data=data,\n        clf=clf\n    )\n    return score\n\n# Dispatch the workflow.\ndispatch_id = ct.dispatch(run_experiment)(\n        C=1.0,\n        gamma=0.7\n)\n\n# Wait for our result and get result value\nresult = ct.get_result(dispatch_id, wait=True).result\n\nprint(result)\n```\n\nDuring 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.\n\n```sh\n0.8666666666666667\n```\nIn order for the above workflow to run successfully, one has to provision the required cloud resources as mentioned in the section [Required AWS Resources](#-required-aws-resources).\n\n## 3. Configuration\n\nThere are many configuration options that can be passed into the `ct.executor.AWSLambdaExecutor` class or by modifying the [covalent config file](https://covalent.readthedocs.io/en/latest/how_to/config/customization.html) under the section `[executors.awslambda]`\n\nFor more information about all of the possible configuration values, visit our [read the docs (RTD) guide](https://covalent.readthedocs.io/en/latest/api/executors/awslambda.html)\nfor this plugin.\n\n## 4. Required AWS Resources\n\nIn order for workflows to leverage this executor, users must ensure that all the necessary IAM permissions are properly setup and configured. This executor uses the [S3](https://aws.amazon.com/s3/) and [AWS Lambda](https://aws.amazon.com/lambda/) services to execute an electron, thus the required IAM roles and policies must be configured correctly. Precisely, the following resources are needed for the executor to run any dispatched electrons properly.\n\n| Resource     | Config Name      | Description |\n| ------------ | ---------------- | ----------- |\n| IAM Role     | lambda_role_name | The IAM role this lambda will assume during execution of your tasks |\n| S3 Bucket    | s3_bucket_name   | The name of the S3 bucket that the executor can use to store temporary files |\n| AWS Lambda   | function_name     | Name of the pre-configured AWS Lambda function use to run tasks\n\nFor exact details on how the above resources can be provisioned, visit our [read the docs (RTD) guide](https://covalent.readthedocs.io/en/latest/api/executors/awslambda.html)\nfor this plugin.\n\n## Getting Started with Covalent\n\nFor more information on how to get started with Covalent, check out the project [homepage](https://github.com/AgnostiqHQ/covalent) and the official [documentation](https://covalent.readthedocs.io/en/latest/).\n\n## Release Notes\n\nRelease notes are available in the [Changelog](https://github.com/AgnostiqHQ/covalent-awslambda-plugin/blob/main/CHANGELOG.md).\n\n## Citation\n\nPlease use the following citation in any publications:\n\n\u003e W. J. Cunningham, S. K. Radha, F. Hasan, J. Kanem, S. W. Neagle, and S. Sanand.\n\u003e *Covalent.* Zenodo, 2022. https://doi.org/10.5281/zenodo.5903364\n\n## License\n\nCovalent is licensed under the Apache 2.0 License. See the [LICENSE](https://github.com/AgnostiqHQ/covalent-awslambda-plugin/blob/main/LICENSE) file or contact the [support team](mailto:support@agnostiq.ai) for more details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagnostiqhq%2Fcovalent-awslambda-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagnostiqhq%2Fcovalent-awslambda-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagnostiqhq%2Fcovalent-awslambda-plugin/lists"}