{"id":20749295,"url":"https://github.com/agnostiqhq/covalent-ecs-plugin","last_synced_at":"2025-04-28T12:43:56.250Z","repository":{"id":56728782,"uuid":"466653000","full_name":"AgnostiqHQ/covalent-ecs-plugin","owner":"AgnostiqHQ","description":"Executor plugin interfacing Covalent with Amazon ECS Fargate","archived":false,"fork":false,"pushed_at":"2025-03-03T16:59:23.000Z","size":481,"stargazers_count":7,"open_issues_count":9,"forks_count":1,"subscribers_count":9,"default_branch":"develop","last_synced_at":"2025-03-25T07:01:49.721Z","etag":null,"topics":["cloud-computing","covalent","docker","elastic-container-registry","elastic-container-service","etl","fargate","parallelization","pipelines","python","python3","quantum-computing","workflow"],"latest_commit_sha":null,"homepage":"https://agnostiq.ai/covalent","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-03-06T06:13:40.000Z","updated_at":"2023-08-20T03:15:56.000Z","dependencies_parsed_at":"2023-02-19T10:45:35.334Z","dependency_job_id":"363f8fe2-7134-4328-a35f-0f8c38aa8152","html_url":"https://github.com/AgnostiqHQ/covalent-ecs-plugin","commit_stats":{"total_commits":88,"total_committers":13,"mean_commits":6.769230769230769,"dds":0.625,"last_synced_commit":"cd8a6b83f4743482a8001b35c75dc0b081a85ea0"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":"AgnostiqHQ/covalent-executor-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgnostiqHQ%2Fcovalent-ecs-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgnostiqHQ%2Fcovalent-ecs-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgnostiqHQ%2Fcovalent-ecs-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgnostiqHQ%2Fcovalent-ecs-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AgnostiqHQ","download_url":"https://codeload.github.com/AgnostiqHQ/covalent-ecs-plugin/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251315681,"owners_count":21569846,"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":["cloud-computing","covalent","docker","elastic-container-registry","elastic-container-service","etl","fargate","parallelization","pipelines","python","python3","quantum-computing","workflow"],"created_at":"2024-11-17T08:22:08.902Z","updated_at":"2025-04-28T12:43:56.215Z","avatar_url":"https://github.com/AgnostiqHQ.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u0026nbsp;\n\n\u003cdiv align=\"center\"\u003e\n\n\u003cimg src=\"https://raw.githubusercontent.com/AgnostiqHQ/covalent-ecs-plugin/main/assets/aws_ecs_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-ecs-plugin)](https://github.com/AgnostiqHQ/covalent-ecs-plugin)\n[![tests](https://github.com/AgnostiqHQ/covalent-ecs-plugin/actions/workflows/tests.yml/badge.svg)](https://github.com/AgnostiqHQ/covalent-ecs-plugin/actions/workflows/tests.yml)\n[![codecov](https://codecov.io/gh/AgnostiqHQ/covalent-ecs-plugin/branch/main/graph/badge.svg?token=QNTR18SR5H)](https://codecov.io/gh/AgnostiqHQ/covalent-ecs-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 ECS Plugin\n\nCovalent is a Pythonic workflow tool used to execute tasks on advanced computing hardware. This executor plugin interfaces Covalent with AWS [Elastic Container Service (ECS)](https://docs.aws.amazon.com/ecs/index.html) where the tasks are run using Fargate.\n\n## 1. Installation\n\nTo use this plugin with Covalent, install it using `pip`:\n\n```sh\npip install covalent-ecs-plugin\n```\n\n## 2. Usage Example\n\nThis is an example of how a workflow can be constructed to use the AWS ECS 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](https://covalent.readthedocs.io/en/latest/concepts/concepts.html#depspip) which will be required to execute the electrons.\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.22.4\", \"scikit-learn==1.1.2\"]\n)\n\nexecutor = ct.executor.ECSExecutor(\n    s3_bucket_name=\"covalent-fargate-task-resources\",\n    ecs_cluster_name=\"covalent-fargate-cluster\",\n    ecs_task_execution_role_name=\"ecsTaskExecutionRole\",\n    ecs_task_role_name=\"CovalentFargateTaskRole\",\n    ecs_task_subnet_id=\"subnet-871545e1\",\n    ecs_task_security_group_id=\"sg-0043541a\",\n    ecs_task_log_group_name=\"covalent-fargate-task-logs\",\n    vcpu=1,\n    memory=2,\n    poll_freq=10,\n)\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    \tX_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    \tdata=data,\n\t    C=C,\n\t    gamma=gamma\n    )\n    score = score_svm(\n    \tdata=data,\n\t    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```\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```\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.ECSExecutor` class or by modifying the [covalent config file](https://covalent.readthedocs.io/en/latest/how_to/config/customization.html) under the section `[executors.ecs]`\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/awsecs.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/), [ECR](https://aws.amazon.com/ecr/), and [ECS](https://aws.amazon.com/ecs/) 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     | ecs_task_execution_role_name | The IAM role used by the ECS agent |\n| IAM Role     | ecs_task_role_name | The IAM role used by the container during runtime |\n| S3 Bucket     | s3_bucket_name | The name of the S3 bucket where objects are stored |\n| ECR repository     | ecr_repo_name | The name of the ECR repository where task images are stored  |\n| ECS Cluster     | ecs_cluster_name   | The name of the ECS cluster on which your tasks are executed  |\n| VPC Subnet    | ecs_task_subnet_id   | The ID of the subnet where instances are created |\n| Security group     | ecs_task_security_group_id   | The ID of the security group for task instances |\n| Cloudwatch log group     | ecs_task_log_group_name   | The name of the CloudWatch log group where container logs are stored |\n| CPU     | vCPU   | The number of vCPUs available to a task |\n| Memory     | memory   | The memory (in GB) available to a task |\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-ecs-executor/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 License 2.0. See the [LICENSE](https://github.com/AgnostiqHQ/covalent-ecs-executor/blob/main/LICENSE) file or contact the [support team](mailto:support@agnostiq.ai) for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagnostiqhq%2Fcovalent-ecs-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagnostiqhq%2Fcovalent-ecs-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagnostiqhq%2Fcovalent-ecs-plugin/lists"}