{"id":15914638,"url":"https://github.com/agnostiqhq/covalent-gcpbatch-plugin","last_synced_at":"2025-03-23T01:31:34.214Z","repository":{"id":166225015,"uuid":"607490883","full_name":"AgnostiqHQ/covalent-gcpbatch-plugin","owner":"AgnostiqHQ","description":"Executor plugin interfacing Covalent with GCP Batch","archived":false,"fork":false,"pushed_at":"2024-10-14T17:08:23.000Z","size":443,"stargazers_count":2,"open_issues_count":12,"forks_count":2,"subscribers_count":8,"default_branch":"develop","last_synced_at":"2024-10-23T02:52:02.420Z","etag":null,"topics":["covalent","docker","etl","gcp-batch","parallelization","pipelines","python","python3","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":"2023-02-28T04:17:33.000Z","updated_at":"2023-05-19T02:05:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"5fae38a9-74f5-4fd1-8347-3bcd2245ccbc","html_url":"https://github.com/AgnostiqHQ/covalent-gcpbatch-plugin","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":"AgnostiqHQ/covalent-executor-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgnostiqHQ%2Fcovalent-gcpbatch-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgnostiqHQ%2Fcovalent-gcpbatch-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgnostiqHQ%2Fcovalent-gcpbatch-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgnostiqHQ%2Fcovalent-gcpbatch-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AgnostiqHQ","download_url":"https://codeload.github.com/AgnostiqHQ/covalent-gcpbatch-plugin/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221841876,"owners_count":16890063,"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":["covalent","docker","etl","gcp-batch","parallelization","pipelines","python","python3","workflow"],"created_at":"2024-10-06T17:04:51.389Z","updated_at":"2024-10-28T14:41:32.106Z","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-gcpbatch-plugin/main/assets/gcp_batch_readme_banner.png\" width=150%\u003e\n\n\u003c/div\u003e\n\n\n## Covalent Google Cloud Platform (GCP) Batch Plugin\n\nCovalent is a Pythonic workflow tool used to execute tasks on advanced computing hardware. This executor plugin interfaces Covalent with [GCP Batch](https://cloud.google.com/batch).\n\n## 1. Installation\n\nTo use this plugin with Covalent, install it using `pip`:\n\n```sh\npip install covalent-gcpbatch-plugin\n```\n\n## 2. Usage Example\n\nThis is an example of how a workflow can be constructed to use the GCP 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](https://covalent.readthedocs.io/en/latest/concepts/concepts.html#depspip) which will be required to execute the electrons.\n\n\n```python\nfrom numpy.random import permutation\nfrom sklearn import svm, datasets\nimport covalent as ct\n\n\ndeps_pip = ct.DepsPip(\n    packages=[\"numpy==1.22.4\", \"scikit-learn==1.1.2\"]\n)\n\nexecutor = ct.executor.GCPBatchExecutor(\n    project_id='covalent_gcp_batch',\n    region='us-east1',\n    bucket_name='covalent-storage-bucket',\n    container_image_uri='us-east1-docker.pkg.dev/covalent_gcp_batch_/covalent/covalent-gcpbatch-executor',\n    service_account_email='covalentsaaccount@covalenttesting.iam.gserviceaccount.com',\n    vcpus = 2,  # Number of vCPUs to allocate\n    memory = 512,  # Memory in MB to allocate\n    time_limit = 300,  # Time limit of job in seconds\n    poll_freq = 3,  # Number of seconds to pause before polling for the job's status\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    return score_svm(\n    \tdata=data,\n\t    clf=clf\n    )\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 GCP Batch Resources](#-required-gcp-batch-resources).\n\n## 3. Configuration\n\nThere are many configuration options that can be passed in to the class `ct.executor.GCPBatchExecutor` or by modifying the [covalent config file](https://covalent.readthedocs.io/en/latest/how_to/config/customization.html) under the section `[executors.gcpbatch]`.\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/gcpbatch.html#overview-of-configuration) for this plugin.\n\n## 4. Required GCP Resources\n\nIn order to run your workflows with covalent there are a few notable GCP resources that need to be provisioned first. The required resources are Google storage bucket, docker artifact registry and service account.\n\nFor more information regarding which cloud resources need to be provisioned visit our [read the docs (RTD) guide](https://covalent.readthedocs.io/en/latest/api/executors/gcpbatch.html#required-cloud-resources) for 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-gcpbatch-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 License 2.0. See the [LICENSE](https://github.com/AgnostiqHQ/covalent-gcpbatch-plugin/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-gcpbatch-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagnostiqhq%2Fcovalent-gcpbatch-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagnostiqhq%2Fcovalent-gcpbatch-plugin/lists"}