Skip to content

Commit 97a172b

Browse files
committed
v1.2.6
1 parent 0de011c commit 97a172b

File tree

18 files changed

+304
-210
lines changed

18 files changed

+304
-210
lines changed

CHANGELOG.md

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

4+
## [1.2.6] - 2023-10-05
5+
6+
### Added
7+
8+
### Changed
9+
10+
- Updated default to not disable api services
11+
- Changed required_permissions and recommend_roles from set to list
12+
- Updated required_permissions and recommend_roles lists to be dynamic based on user tooling selection
13+
- Changed google_project_iam_member block to use a local list for setting iam roles
14+
- Moved csr creation to only occur if use_ci=True
15+
- Updated github_actions config to use source_repo_branch parameter into of default `automlops` branch
16+
17+
### Fixed
18+
19+
- Fixed run local issue regarding dockerfile pathing
20+
- Fixed cloudbuild trigger terraform bug with ignored_files
21+
22+
423
## [1.2.5] - 2023-10-05
524

625
### Added
@@ -11,6 +30,7 @@ All notable changes to this project will be documented in this file.
1130

1231
- Fixed bug with generating .github/workflows directories
1332

33+
1434
## [1.2.4] - 2023-10-03
1535

1636
### Added
@@ -23,6 +43,7 @@ All notable changes to this project will be documented in this file.
2343

2444
- Pinned the python docker container step for the cloudbuild yaml to python:3.10, this address some dependency issues with the latest python docker image
2545

46+
2647
## [1.2.3] - 2023-09-29
2748

2849
### Added

examples/inferencing/00_batch_prediction_example.ipynb

Lines changed: 134 additions & 78 deletions
Large diffs are not rendered by default.

examples/training/00_introduction_training_example.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,8 @@
415415
" \"\"\"Generates BQ Query to read data.\n",
416416
"\n",
417417
" Args:\n",
418-
" bq_input_table: The full name of the bq input table to be read into\n",
419-
" the dataframe (e.g. <project>.<dataset>.<table>)\n",
418+
" bq_input_table: The full name of the bq input table to be read into\n",
419+
" the dataframe (e.g. <project>.<dataset>.<table>)\n",
420420
" Returns: A BQ query string.\n",
421421
" \"\"\"\n",
422422
" return f'''\n",
@@ -427,10 +427,10 @@
427427
" def load_bq_data(query: str, client: bigquery.Client) -> pd.DataFrame:\n",
428428
" \"\"\"Loads data from bq into a Pandas Dataframe for EDA.\n",
429429
" Args:\n",
430-
" query: BQ Query to generate data.\n",
431-
" client: BQ Client used to execute query.\n",
430+
" query: BQ Query to generate data.\n",
431+
" client: BQ Client used to execute query.\n",
432432
" Returns:\n",
433-
" pd.DataFrame: A dataframe with the requested data.\n",
433+
" pd.DataFrame: A dataframe with the requested data.\n",
434434
" \"\"\"\n",
435435
" df = client.query(query).to_dataframe()\n",
436436
" return df\n",

google_cloud_automlops/AutoMLOps.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ def generate(
327327
logging.info(f'Writing README.md to {BASE_DIR}README.md')
328328
logging.info(f'Writing kubeflow pipelines code to {BASE_DIR}pipelines, {BASE_DIR}components')
329329
logging.info(f'Writing scripts to {BASE_DIR}scripts')
330-
logging.info(f'Writing submission service code to {BASE_DIR}services')
330+
if use_ci:
331+
logging.info(f'Writing submission service code to {BASE_DIR}services')
331332
KfpBuilder.build(KfpConfig(
332333
base_image=base_image,
333334
custom_training_job_specs=derived_custom_training_job_specs,
@@ -414,6 +415,7 @@ def generate(
414415
project_id=project_id,
415416
project_number=project_number,
416417
pubsub_topic_name=derived_pubsub_topic_name,
418+
source_repo_branch=source_repo_branch,
417419
use_ci=use_ci,
418420
workload_identity_pool=workload_identity_pool,
419421
workload_identity_provider=workload_identity_provider,

google_cloud_automlops/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
series of directories to support the creation of Vertex Pipelines.
2424
"""
2525
# pylint: disable=invalid-name
26-
__version__ = '1.2.5'
26+
__version__ = '1.2.6'
2727
__author__ = 'Sean Rastatter'
2828
__credits__ = 'Google'

google_cloud_automlops/deployments/cloudbuild/builder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
from google_cloud_automlops.utils.utils import write_file
2828
from google_cloud_automlops.utils.constants import (
29+
BASE_DIR,
2930
CLOUDBUILD_TEMPLATES_PATH,
3031
GENERATED_CLOUDBUILD_FILE,
3132
COMPONENT_BASE_RELATIVE_PATH,
@@ -76,13 +77,14 @@ def create_cloudbuild_jinja(
7677
Returns:
7778
str: Contents of cloudbuild.yaml.
7879
"""
80+
component_base_relative_path = COMPONENT_BASE_RELATIVE_PATH if use_ci else f'{BASE_DIR}{COMPONENT_BASE_RELATIVE_PATH}'
7981
template_file = import_files(CLOUDBUILD_TEMPLATES_PATH) / 'cloudbuild.yaml.j2'
8082
with template_file.open('r', encoding='utf-8') as f:
8183
template = Template(f.read())
8284
return template.render(
8385
artifact_repo_location=artifact_repo_location,
8486
artifact_repo_name=artifact_repo_name,
85-
component_base_relative_path=COMPONENT_BASE_RELATIVE_PATH,
87+
component_base_relative_path=component_base_relative_path,
8688
generated_license=GENERATED_LICENSE,
8789
generated_parameter_values_path=GENERATED_PARAMETER_VALUES_PATH,
8890
naming_prefix=naming_prefix,

google_cloud_automlops/deployments/configs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class GitHubActionsConfig(BaseModel):
4848
project_id: The project ID.
4949
project_number: The project number.
5050
pubsub_topic_name: The name of the pubsub topic to publish to.
51+
source_repo_branch: The branch to use in the source repository.
5152
use_ci: Flag that determines whether to use Cloud CI/CD.
5253
workload_identity_pool: Pool for workload identity federation.
5354
workload_identity_provider: Provider for workload identity federation.
@@ -59,6 +60,7 @@ class GitHubActionsConfig(BaseModel):
5960
project_id: str
6061
project_number: str #TODO: Check if there's any other way to pass this, could use a util with the GCP client library. See https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/content-warehouse/src/main/java/contentwarehouse/v1/CreateDocument.java#L125-L135
6162
pubsub_topic_name: str
63+
source_repo_branch: str
6264
use_ci: bool
6365
workload_identity_pool: str
6466
workload_identity_provider: str

google_cloud_automlops/deployments/github_actions/builder.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
from google_cloud_automlops.utils.utils import write_file
2828
from google_cloud_automlops.utils.constants import (
29-
DEFAULT_SOURCE_REPO_BRANCH,
3029
GENERATED_GITHUB_ACTIONS_FILE,
3130
COMPONENT_BASE_RELATIVE_PATH,
3231
GENERATED_LICENSE,
@@ -46,6 +45,7 @@ def build(config: GitHubActionsConfig):
4645
config.project_id: The project ID.
4746
config.project_number: The project number.
4847
config.pubsub_topic_name: The name of the pubsub topic to publish to.
48+
config.source_repo_branch: The branch to use in the source repository.
4949
config.use_ci: Flag that determines whether to use Cloud CI/CD.
5050
config.workload_identity_pool: Pool for workload identity federation.
5151
config.workload_identity_provider: Provider for workload identity federation.
@@ -59,6 +59,7 @@ def build(config: GitHubActionsConfig):
5959
config.project_id,
6060
config.project_number,
6161
config.pubsub_topic_name,
62+
config.source_repo_branch,
6263
config.use_ci,
6364
config.workload_identity_pool,
6465
config.workload_identity_provider,
@@ -71,6 +72,7 @@ def create_github_actions_jinja(
7172
project_id: str,
7273
project_number: str,
7374
pubsub_topic_name: str,
75+
source_repo_branch: str,
7476
use_ci: bool,
7577
workload_identity_pool: str,
7678
workload_identity_provider: str,
@@ -85,6 +87,7 @@ def create_github_actions_jinja(
8587
project_id: The project ID.
8688
project_number: The project number.
8789
pubsub_topic_name: The name of the pubsub topic to publish to.
90+
source_repo_branch: The branch to use in the source repository.
8891
use_ci: Flag that determines whether to use Cloud CI/CD.
8992
workload_identity_pool: Pool for workload identity federation.
9093
workload_identity_provider: Provider for workload identity federation.
@@ -106,7 +109,7 @@ def create_github_actions_jinja(
106109
project_id=project_id,
107110
project_number=project_number,
108111
pubsub_topic_name=pubsub_topic_name,
109-
source_repo_branch=DEFAULT_SOURCE_REPO_BRANCH,
112+
source_repo_branch=source_repo_branch,
110113
use_ci=use_ci,
111114
workload_identity_pool=workload_identity_pool,
112115
workload_identity_provider=workload_identity_provider,

google_cloud_automlops/provisioning/gcloud/builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def build(
7373
config.vpc_connector: The name of the vpc connector to use.
7474
"""
7575
defaults = read_yaml_file(GENERATED_DEFAULTS_FILE)
76-
required_apis = list(get_required_apis(defaults))
76+
required_apis = get_required_apis(defaults)
7777
# create provision_resources.sh
7878
write_and_chmod(GENERATED_RESOURCES_SH_FILE, provision_resources_script_jinja(
7979
artifact_repo_location=config.artifact_repo_location,

google_cloud_automlops/provisioning/gcloud/templates/provision_resources.sh.j2

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ gcloud projects add-iam-policy-binding $PROJECT_ID \
7474
--member="serviceAccount:$PIPELINE_JOB_RUNNER_SERVICE_ACCOUNT_LONG" \
7575
--role="{{role}}" \
7676
--no-user-output-enabled{% endfor %}
77+
{% if use_ci %}
7778
{% if source_repo_type == 'cloud-source-repositories' %}
7879
echo -e "$GREEN Setting up Cloud Source Repository in project $PROJECT_ID $NC"
7980
if ! (gcloud source repos list --project="$PROJECT_ID" | grep -E "(^|[[:blank:]])$SOURCE_REPO_NAME($|[[:blank:]])"); then
@@ -85,8 +86,8 @@ else
8586

8687
echo "Cloud Source Repository: ${SOURCE_REPO_NAME} already exists in project $PROJECT_ID"
8788

88-
fi{% endif %}
89-
{% if use_ci %}
89+
fi
90+
{% endif %}
9091
# Create Pub/Sub Topic
9192
echo -e "$GREEN Setting up Queueing Service in project $PROJECT_ID $NC"
9293
if ! (gcloud pubsub topics list | grep -E "(^|[[:blank:]])projects/${PROJECT_ID}/topics/${PUBSUB_TOPIC_NAME}($|[[:blank:]])"); then

google_cloud_automlops/provisioning/terraform/builder.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def build(
8080
config.vpc_connector: The name of the vpc connector to use.
8181
"""
8282
defaults = read_yaml_file(GENERATED_DEFAULTS_FILE)
83-
required_apis = list(get_required_apis(defaults))
83+
required_apis = get_required_apis(defaults)
8484
# create environment/data.tf
8585
write_file(f'{BASE_DIR}provision/environment/data.tf', create_environment_data_tf_jinja(
8686
required_apis=required_apis,
@@ -184,6 +184,7 @@ def create_environment_data_tf_jinja(
184184
return template.render(
185185
generated_license=GENERATED_LICENSE,
186186
required_apis=required_apis,
187+
required_iam_roles=IAM_ROLES_RUNNER_SA,
187188
use_ci=use_ci)
188189

189190

@@ -196,9 +197,7 @@ def create_environment_iam_tf_jinja() -> str:
196197
template_file = import_files(TERRAFORM_TEMPLATES_PATH + '.environment') / 'iam.tf.j2'
197198
with template_file.open('r', encoding='utf-8') as f:
198199
template = Template(f.read())
199-
return template.render(
200-
generated_license=GENERATED_LICENSE,
201-
required_iam_roles=IAM_ROLES_RUNNER_SA)
200+
return template.render(generated_license=GENERATED_LICENSE)
202201

203202

204203
def create_environment_main_tf_jinja(

google_cloud_automlops/provisioning/terraform/templates/environment/data.tf.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,9 @@ locals {
2525
enable_apis = [{% for api in required_apis %}
2626
"{{api}}",{% endfor %}
2727
]
28+
29+
pipeline_runner_service_account_iam_list = [{% for role in required_iam_roles %}
30+
"{{role}}",{% endfor %}
31+
]
2832
}
2933
}

google_cloud_automlops/provisioning/terraform/templates/environment/iam.tf.j2

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ resource "google_service_account" "pipeline_job_runner_service_account" {
1212
depends_on = [module.google_project_service,time_sleep.wait_60_seconds]
1313
}
1414

15-
{% for role in required_iam_roles %}resource "google_project_iam_member" "pipeline_job_runner_service_account_{{role.replace('/', '_').replace('.', '_')}}" {
15+
resource "google_project_iam_member" "pipeline_job_runner_service_account_iam" {
16+
for_each = toset(local.org_project.pipeline_runner_service_account_iam_list)
1617
project = var.project_id
17-
role = "{{role}}"
18+
role = each.key
1819
member = "serviceAccount:${google_service_account.pipeline_job_runner_service_account.email}"
1920

2021
depends_on = [google_service_account.pipeline_job_runner_service_account]
2122
}
22-
23-
{% endfor %}

google_cloud_automlops/provisioning/terraform/templates/environment/main.tf.j2

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{{generated_license}}
22
# Enable Google Cloud APIs
33
module "google_project_service" {
4-
source = "terraform-google-modules/project-factory/google//modules/project_services"
5-
version = "14.1.0"
6-
project_id = var.project_id
7-
activate_apis = local.org_project.enable_apis
4+
source = "terraform-google-modules/project-factory/google//modules/project_services"
5+
version = "14.1.0"
6+
project_id = var.project_id
7+
activate_apis = local.org_project.enable_apis
8+
disable_services_on_destroy = false
89
}
910
resource "time_sleep" "wait_60_seconds" {
1011
depends_on = [module.google_project_service]
@@ -34,6 +35,7 @@ resource "google_storage_bucket" "storage_bucket" {
3435
}
3536
depends_on = [module.google_project_service,time_sleep.wait_60_seconds]
3637
}
38+
{% if use_ci %}
3739
{% if source_repo_type == 'cloud-source-repositories' %}
3840
# Create cloud source repository
3941
resource "google_sourcerepo_repository" "source_repo" {
@@ -42,7 +44,7 @@ resource "google_sourcerepo_repository" "source_repo" {
4244

4345
depends_on = [module.google_project_service,time_sleep.wait_60_seconds]
4446
}{% endif %}
45-
{% if use_ci %}{% if pipeline_job_submission_service_type == 'cloud-run' %}
47+
{% if pipeline_job_submission_service_type == 'cloud-run' %}
4648
# Build and Push Submission Service image
4749
resource "null_resource" "build_and_push_submission_service" {
4850
provisioner "local-exec" {
@@ -132,7 +134,7 @@ resource "google_cloudbuild_trigger" "cloudbuild_trigger" {
132134
project = var.project_id
133135
name = var.build_trigger_name
134136
location = var.build_trigger_location
135-
ignored-files = [".gitignore"]
137+
ignored_files = [".gitignore"]
136138
trigger_template {
137139
branch_name = var.source_repo_branch
138140
project_id = var.project_id

google_cloud_automlops/utils/constants.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@
127127
GITOPS_TEMPLATES_PATH = 'google_cloud_automlops.deployments.gitops.templates'
128128

129129
# Required IAM Roles for pipeline runner service account
130-
IAM_ROLES_RUNNER_SA = set([
130+
IAM_ROLES_RUNNER_SA = [
131131
'roles/aiplatform.user',
132132
'roles/artifactregistry.reader',
133+
'roles/cloudfunctions.admin',
133134
'roles/bigquery.user',
134135
'roles/bigquery.dataEditor',
135136
'roles/iam.serviceAccountUser',
136-
'roles/storage.admin',
137-
'roles/cloudfunctions.admin'
138-
])
137+
'roles/storage.admin'
138+
]

0 commit comments

Comments
 (0)