Skip to content

Commit fca32f5

Browse files
authored
Merge pull request #65 from GoogleCloudPlatform/feature/github-default
Feature/GitHub default
2 parents 4f04d3f + 7ae461a commit fca32f5

27 files changed

+421
-110
lines changed

AutoMLOps_User_Guide.pdf

4.08 KB
Binary file not shown.

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [1.3.1] - 2024-10-30
5+
6+
### Added
7+
8+
- Guide explaining how to set up Workload Identity Federation for AutoMLOps
9+
- Created new docs/ directory
10+
- Check that prohibits using Github and Cloud Build (this is currently not supported)
11+
12+
### Changed
13+
14+
- Made `github` and `github-actions` the default options for `source_repo_type` and `deployment_framework` respectively
15+
- Updated example notebooks so that they are set to `use_ci=False` by default
16+
- Provided samples in the example notebooks that demonstrate how to use the `github` and `github_actions` setup
17+
- Added a guide for setting up Workload Identity Federation
18+
- Updated github actions op versions (checkout and auth)
19+
20+
### Fixed
21+
22+
- Fixed broken default of now deprecated Cloud Source Repositories
23+
- Updated sklearn version of training example00 to use v1.3
24+
- Removed `build_trigger_location` from resources manifest output
25+
426
## [1.3.0] - 2024-5-22
527

628
### Added

README.md

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ Inferencing
6464
- Artifact Registry
6565

6666
**Deployment Frameworks**: Builds component docker containers, compiles pipelines, and submits Pipeline Jobs
67-
- Cloud Build
6867
- Github Actions
68+
- Cloud Build
6969
- [coming soon] Gitlab CI
7070
- [coming soon] Bitbucket Pipelines
7171
- [coming soon] Jenkins
@@ -87,10 +87,10 @@ Inferencing
8787
- [coming soon] pulumi
8888

8989
**Source Code Repositories**: Repository for versioning generated MLOps code
90-
- [deprecating soon] Cloud Source Repositories
91-
- Bitbucket
9290
- Github
91+
- Bitbucket
9392
- Gitlab
93+
- [deprecated] Cloud Source Repositories
9494

9595
# Prerequisites
9696
### Generate
@@ -122,11 +122,6 @@ In order to use `AutoMLOps.deploy(...)` with `use_ci=True`, the following are re
122122
git config --global user.name "Your Name"
123123
```
124124
- Registered and setup your SSH key if you are using Github, Gitlab, or Bitbucket
125-
- [Application Default Credentials (ADC)](https://cloud.google.com/docs/authentication/provide-credentials-adc) are set up if you are using Cloud Source Repositories. This can be done through the following commands:
126-
```
127-
gcloud auth application-default login
128-
gcloud config set account <account@example.com>
129-
```
130125

131126
### Monitor
132127
In order to use `AutoMLOps.monitor(...)`, the following are required:
@@ -170,10 +165,7 @@ AutoMLOps will makes use of the following products based on user selected option
170165
6. if `use_ci=True` and `schedule_pattern` is specified, AutoMLOps will use:
171166
- [Cloud Scheduler](https://cloud.google.com/scheduler/docs/overview)
172167

173-
7. if `use_ci=True` and `source_repo_type='cloud-source-repositories'`, AutoMLOps will use:
174-
- [Cloud Source Repositories](https://cloud.google.com/source-repositories/docs)
175-
176-
8. if `use_ci=True` and `setup_model_monitoring=True`, AutoMLOps will use:
168+
7. if `use_ci=True` and `setup_model_monitoring=True`, AutoMLOps will use:
177169
- [Vertex AI Model Monitoring](https://cloud.google.com/vertex-ai/docs/model-monitoring/overview)
178170
- [Cloud Logging](https://cloud.google.com/logging/docs/overview)
179171

@@ -193,7 +185,6 @@ Based on the above user selection, AutoMLOps will enable up to the following API
193185
- [pubsub.googleapis.com](https://cloud.google.com/pubsub/docs/reference/rest)
194186
- [run.googleapis.com](https://cloud.google.com/run/docs/reference/rest)
195187
- [storage.googleapis.com](https://cloud.google.com/storage/docs/apis)
196-
- [sourcerepo.googleapis.com](https://cloud.google.com/source-repositories/docs/reference/rest)
197188

198189

199190
AutoMLOps will create the following service account and update [IAM permissions](https://cloud.google.com/iam/docs/understanding-roles) during the provision step:
@@ -232,7 +223,7 @@ Optional parameters (defaults shown):
232223
5. `build_trigger_location: str = 'us-central1'`
233224
6. `build_trigger_name: str = f'{naming_prefix}-build-trigger'`
234225
7. `custom_training_job_specs: list[dict] = None`
235-
8. `deployment_framework: str = 'cloud-build'`
226+
8. `deployment_framework: str = 'github-actions'`
236227
9. `naming_prefix: str = 'automlops-default-prefix'`
237228
10. `orchestration_framework: str = 'kfp'`
238229
11. `pipeline_job_runner_service_account: str = f'vertex-pipelines@{project_id}.iam.gserviceaccount.com'`
@@ -249,7 +240,7 @@ Optional parameters (defaults shown):
249240
22. `setup_model_monitoring: Optional[bool] = False`
250241
23. `source_repo_branch: str = 'automlops'`
251242
24. `source_repo_name: str = f'{naming_prefix}-repository'`
252-
25. `source_repo_type: str = 'cloud-source-repositories'`
243+
25. `source_repo_type: str = 'github'`
253244
26. `storage_bucket_location: str = 'us-central1'`
254245
27. `storage_bucket_name: str = f'{project_id}-{naming_prefix}-bucket'`
255246
28. `use_ci: bool = False`
@@ -262,8 +253,8 @@ Parameter Options:
262253
- `artifact_repo_type=`:
263254
- 'artifact-registry' (default)
264255
- `deployment_framework=`:
265-
- 'cloud-build' (default)
266-
- 'github-actions'
256+
- 'github-actions' (default)
257+
- 'cloud-build'
267258
- [coming soon] 'gitlab-ci'
268259
- [coming soon] 'bitbucket-pipelines'
269260
- [coming soon] 'jenkins'
@@ -281,8 +272,7 @@ Parameter Options:
281272
- 'terraform'
282273
- [coming soon] 'pulumi'
283274
- `source_repo_type=`:
284-
- 'cloud-source-repositories' (default)
285-
- 'github'
275+
- 'github' (default)
286276
- 'gitlab'
287277
- 'bitbucket'
288278

@@ -324,7 +314,7 @@ A description of the parameters is below:
324314
- `workload_identity_provider`: Provider for workload identity federation.
325315
- `workload_identity_service_account`: Service account for workload identity federation (specify the full string).
326316

327-
AutoMLOps will generate the resources specified by these parameters (e.g. Artifact Registry, Cloud Source Repo, etc.). If use_ci is set to True, AutoMLOps will turn the outputted AutoMLOps/ directory into a Git repo and use it for the source repo. If a cron formatted str is given as an arg for `schedule_pattern` then it will set up a Cloud Schedule to run accordingly. If `setup_model_monitoring` is set to true, a model_monitoring/ directory will be created and a monitoring section will be added to config/defaults.yaml with empty values. These values are then set by running `AutoMLOps.monitor()`.
317+
AutoMLOps will generate the resources specified by these parameters (e.g. Artifact Registry, GCS bucket, etc.). If use_ci is set to True, AutoMLOps will turn the outputted AutoMLOps/ directory into a Git repo and use it for the source repo. If a cron formatted str is given as an arg for `schedule_pattern` then it will set up a Cloud Schedule to run accordingly. If `setup_model_monitoring` is set to true, a model_monitoring/ directory will be created and a monitoring section will be added to config/defaults.yaml with empty values. These values are then set by running `AutoMLOps.monitor()`.
328318

329319
# Generating Code
330320

@@ -385,11 +375,6 @@ AutoMLOps currently provides 2 primary options for provisioning infrastructure:
385375
### Cloud Continuous Integration and Continuous Deployment Workflow
386376
If `use_ci=True`, AutoMLOps will generate and use a fully featured CI/CD environment for the pipeline. Otherwise, it will use the local scripts to build and run the pipeline. In the diagrams below dashed boxes show areas users can select and customize their tooling.
387377

388-
**<center>Cloud Build option:</center>**
389-
<p align="center">
390-
<img src="https://raw.githubusercontent.com/GoogleCloudPlatform/automlops/main/assets/deploy/CICD-default.png" alt="CICD" width="1000"/>
391-
</p>
392-
393378
**<center>Github Actions option:</center>**
394379
<p align="center">
395380
<img src="https://raw.githubusercontent.com/GoogleCloudPlatform/automlops/main/assets/deploy/CICD-github.png" alt="CICD" width="1000"/>
@@ -478,6 +463,8 @@ AutoMLOps.generate(project_id=PROJECT_ID,
478463
workload_identity_service_account='workload_identity_sa')
479464
```
480465

466+
More specific details for setting up AutoMLOps to use Github and Github Actions can be found in [this doc](docs/Using%20Github%20With%20AMO.md).
467+
481468
**Set scheduled run:**
482469

483470
Use the `schedule_pattern` parameter to specify a cron job schedule to run the pipeline job on a recurring basis.
76.5 KB
Loading
51.8 KB
Loading
272 KB
Loading
297 KB
Loading
208 KB
Loading
277 KB
Loading

docs/Using Github With AMO.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
**Using Github With AMO**
2+
3+
The steps below are required in order to deploy a model using the AutoMLOps package. The process below assumes that the [AutoMLOps](https://github.com/GoogleCloudPlatform/automlops) package is already installed in the environment where the AutoMLOps execution cells are being run.
4+
5+
## **Create a Repository**
6+
7+
Go to Github, and create a new repository leaving fields as default. Let’s call it automlops-test.
8+
9+
<p align="left">
10+
<img src="../assets/deploy/github_actions/image1.png" alt="image1" width="600"/>
11+
</p>
12+
13+
\[Optional\] Create repository via Terraform
14+
15+
```
16+
resource "github_repository" "my_repo" {
17+
name = "my_cool_repo"
18+
description = "My awesome codebase"
19+
visibility = "private"
20+
}
21+
```
22+
23+
## **Set up SSH connection**
24+
25+
Follow [this guide](https://docs.github.com/en/authentication/connecting-to-github-with-ssh) on how to add your SSH keys to the environment from where you are running the AutoMLOps commands.
26+
27+
## **Pre-requisites**
28+
29+
Ensure that you have the following IAM Roles to provision an Identity Pool:
30+
31+
* roles/iam.workloadIdentityPoolAdmin
32+
33+
**Set up [Workload Identity Federation](https://cloud.google.com/iam/docs/workload-identity-federation) (WIF) for GitHub Actions**
34+
35+
1. Create an Identity Pool in GCP
36+
<p align="left">
37+
<img src="../assets/deploy/github_actions/image2.png" alt="image2" width="600"/>
38+
</p>
39+
- Enter a pool name and click ‘Continue’. Example details:
40+
- Name: automlops-1-github-pool
41+
- Pool ID: automlops-1-github-pool
42+
- \<check Enabled pool\>
43+
44+
2. Create an Identity Provider and add it to the pool:
45+
46+
<p align="left">
47+
<img src="../assets/deploy/github_actions/image3.png" alt="image3" width="600"/>
48+
</p>
49+
50+
<p align="left">
51+
<img src="../assets/deploy/github_actions/image4.png" alt="image4" width="600"/>
52+
</p>
53+
54+
- Fill in the attributes and conditions for the provider with the following details:
55+
56+
- #### Provider type: OpenID Connect (OIDC)
57+
58+
- Provider Name: automlops-github-provider
59+
- Provider ID: automlops-github-provider
60+
- Issuer (URL): https://token.actions.githubusercontent.com/
61+
- JWK file (JSON): \<leave empty\>
62+
- Audiences: \<select Default audience\>
63+
- Attribute Mappings:
64+
- Google 1: google.subject
65+
- OIDC 1: assertion.sub
66+
- Google 2: attribute.actor
67+
- OIDC 2: assertion.actor
68+
- Google 3: attribute.repository
69+
- OIDC 3: assertion.repository
70+
- Attribute Conditions: google.subject.contains("\<my\_repo\_name\>")
71+
- i.e. google.subject.contains("Akhan221/automlops-test")
72+
73+
74+
3. Create a service account
75+
Go to the service accounts tab and click on new service account in the top right. Provide a unique name for the service account (SA).
76+
77+
<p align="left">
78+
<img src="../assets/deploy/github_actions/image5.png" alt="image5" width="600"/>
79+
</p>
80+
81+
\[Optional\] Create the Service Account using Terraform
82+
83+
84+
85+
```
86+
resource "google_service_account" "service_account" {
87+
account_id = "service-account-id"
88+
display_name = "Service Account"
89+
}
90+
```
91+
92+
4. Grant necessary permission to the Service Account
93+
1. *roles/artifactregistry.writer*
94+
2. *roles/pubsub.publisher*
95+
3. *roles/iam.workloadIdentityUser*
96+
4. *roles/storage.admin*
97+
98+
<p align="left">
99+
<img src="../assets/deploy/github_actions/image6.png" alt="image6" width="600"/>
100+
</p>
101+
102+
5. Grant identity pool access to the SA, following the instructions at [this link](https://cloud.google.com/iam/docs/workload-download-cred-and-grant-access?_gl=1*1qn8wpp*_ga*MTU3MjE2NjAzMy4xNzA2NzI1NDU0*_ga_WH2QY8WWF5*MTczMDM4MzY1MC41OS4xLjE3MzAzODQ2NTUuNjAuMC4w#service-account-in-the-same-project).
103+
1. Option 1
104+
1. Select “+ Grant Access” at the top of the Identity Pool view
105+
2. Check “Grant access using Service Account impersonation”
106+
3. Select the service account you just created
107+
4. For the attribute name, select “repository”
108+
5. For the attribute value, write full name of your repo e.g. “Akhan221/automlops-test”
109+
6. Click Save
110+
2. Option 2
111+
1. Navigate to IAM \-\> Service Accounts, select the desired service account from the list
112+
2. Select “Permissions” from the top menu
113+
3. Select “+ Grant Access”
114+
4. Add the principal that aligns to the Identity Pool
115+
1. principalSet://iam.googleapis.com/projects/PROJECT\_NUMBER/locations/global/workloadIdentityPools/POOL\_ID/attribute.repository/FULL\_REPO\_STRING
116+
3. Option 3 (grant full access to the pool)
117+
1. Run the following command:
118+
119+
gcloud iam service-accounts add-iam-policy-binding "FULL\_SERVICE\_ACCOUNT\_STRING" \\
120+
121+
\--project="PROJECT\_ID" \\
122+
123+
\--role="roles/iam.workloadIdentityUser" \\
124+
125+
\--member=principalSet://iam.googleapis.com/projects/PROJECT\_NUMBER/locations/global/workloadIdentityPools/POOL\_ID/\*
126+
127+
## **Run the Generate Step with the WIF Details**
128+
129+
When going through the AutoMLOps example notebook, on the generate step make sure to include these fields along with the other required parameters:
130+
131+
```py
132+
AutoMLOps.generate(
133+
...
134+
use_ci=True,
135+
deployment_framework='github-actions',
136+
project_number='<project_number>', # ie. 99800000432
137+
source_repo_type='github',
138+
source_repo_name='source/repo/string', # ie. Akhan221/automlops-test
139+
workload_identity_pool='identity_pool_string', # ID string
140+
workload_identity_provider='identity_provider_string', # ID string
141+
workload_identity_service_account='workload_identity_sa' # full SA string
142+
)
143+
```
144+
145+
For the source\_repo\_name, note that this is referring to the full name of the repo including the owner prefix. For example, Akhan221/my-test-repo.
146+
147+
## **Run the provision and deploy steps**
148+
149+
Finish running the remainder of the commands and verify that the pipeline actually gets created in Vertex AI.

examples/inferencing/00_batch_prediction_example.ipynb

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@
107107
"- [pubsub.googleapis.com](https://cloud.google.com/pubsub/docs/reference/rest)\n",
108108
"- [run.googleapis.com](https://cloud.google.com/run/docs/reference/rest)\n",
109109
"- [storage.googleapis.com](https://cloud.google.com/storage/docs/apis)\n",
110-
"- [sourcerepo.googleapis.com](https://cloud.google.com/source-repositories/docs/reference/rest)\n",
111110
"\n",
112111
"\n",
113112
"AutoMLOps will create the following service account and update [IAM permissions](https://cloud.google.com/iam/docs/understanding-roles) during the provision step:\n",
@@ -130,7 +129,6 @@
130129
"- Vertex AI\n",
131130
"- Artifact Registry\n",
132131
"- Cloud Storage\n",
133-
"- Cloud Source Repository\n",
134132
"- Cloud Build\n",
135133
"- Cloud Run\n",
136134
"- Cloud Scheduler\n",
@@ -562,7 +560,7 @@
562560
"metadata": {},
563561
"source": [
564562
"## Generate and Run the pipeline\n",
565-
"`AutoMLOps.generate(...)` generates the MLOps codebase. Users can specify the tooling and technologies they would like to use in their MLOps pipeline."
563+
"`AutoMLOps.generate(...)` generates the MLOps codebase. Users can specify the tooling and technologies they would like to use in their MLOps pipeline. If you are interested in integrating with Github and Github Actions, please follow the setup steps in [this doc](../../docs/Using%20Github%20With%20AMO.md) and uncomment the relevant code block below."
566564
]
567565
},
568566
{
@@ -588,12 +586,29 @@
588586
}
589587
],
590588
"source": [
589+
"# Setup using local scripts and cloudbuild:\n",
591590
"AutoMLOps.generate(project_id=PROJECT_ID,\n",
592591
" pipeline_params=pipeline_params,\n",
593-
" use_ci=True,\n",
592+
" use_ci=False,\n",
594593
" naming_prefix=MODEL_ID,\n",
595-
" schedule_pattern='59 11 * * 0' # rerun every Sunday at Midnight\n",
596-
")"
594+
" deployment_framework='cloud-build',\n",
595+
")\n",
596+
"\n",
597+
"# # Setup using Github, Github Actions, and Terraform:\n",
598+
"# AutoMLOps.generate(project_id=PROJECT_ID,\n",
599+
"# pipeline_params=pipeline_params,\n",
600+
"# naming_prefix=MODEL_ID,\n",
601+
"# schedule_pattern='59 11 * * 0', # retrain every Sunday at Midnight\n",
602+
"# use_ci=True,\n",
603+
"# deployment_framework='github-actions',\n",
604+
"# provisioning_framework='terraform', \n",
605+
"# source_repo_type='github',\n",
606+
"# project_number='<project_number>',\n",
607+
"# source_repo_name='<source/repo/string>',\n",
608+
"# workload_identity_pool='<identity_pool_string>',\n",
609+
"# workload_identity_provider='<identity_provider_string>',\n",
610+
"# workload_identity_service_account='<workload_identity_sa>'\n",
611+
"# )"
597612
]
598613
},
599614
{

0 commit comments

Comments
 (0)