Skip to content

Commit

Permalink
add project_number field to featureview (#10857)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkram01 authored Jul 2, 2024
1 parent 621ab00 commit baa5714
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 0 deletions.
16 changes: 16 additions & 0 deletions mmv1/products/vertexai/FeatureOnlineStoreFeatureview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ examples:
primary_resource_id: 'featureview_featureregistry'
vars:
name: 'example_feature_view_feature_registry'
- !ruby/object:Provider::Terraform::Examples
name: 'vertex_ai_featureonlinestore_featureview_cross_project'
external_providers: ["time"]
primary_resource_id: 'cross_project_featureview'
ignore_read_extra:
- feature_registry_source.0.project_number
test_env_vars:
org_id: :ORG_ID
billing_account: :BILLING_ACCT
vars:
name: 'example_cross_project_featureview'
- !ruby/object:Provider::Terraform::Examples
name: 'vertex_ai_featureonlinestore_featureview_with_vector_search'
primary_resource_id: 'featureview_vector_search'
Expand Down Expand Up @@ -160,6 +171,11 @@ properties:
description: |
Identifiers of features under the feature group.
item_type: Api::Type::String
- !ruby/object:Api::Type::String
name: 'projectNumber'
description: |
The project number of the parent project of the feature Groups.
custom_flatten: templates/terraform/custom_flatten/vertex_ai_feature_view_ignore_project_number.go.erb
- !ruby/object:Api::Type::NestedObject
name: 'vectorSearchConfig'
description: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<%# The license inside this block applies to this file.
# Copyright 2023 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-%>
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return d.Get("feature_registry_source.0.project_number")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
data "google_project" "test_project" {
}

resource "google_project" "project" {
project_id = "tf-test%{random_suffix}"
name = "tf-test%{random_suffix}"
org_id = "<%= ctx[:test_env_vars]['org_id'] %>"
billing_account = "<%= ctx[:test_env_vars]['billing_account'] %>"
}

resource "time_sleep" "wait_60_seconds" {
depends_on = [google_project.project]

create_duration = "60s"
}

resource "time_sleep" "wait_30_seconds" {
depends_on = [google_bigquery_dataset_iam_member.viewer]

create_duration = "30s"
}

resource "google_project_service" "vertexai" {
service = "aiplatform.googleapis.com"
project = google_project.project.project_id
timeouts {
create = "30m"
update = "40m"
}
disable_on_destroy = false
# Needed for CI tests for permissions to propagate, should not be needed for actual usage
depends_on = [time_sleep.wait_60_seconds]
}

resource "google_bigquery_dataset_iam_member" "viewer" {
project = data.google_project.test_project.project_id
dataset_id = google_bigquery_dataset.sample_dataset.dataset_id
role = "roles/bigquery.dataViewer"
member = "serviceAccount:service-${google_project.project.number}@gcp-sa-aiplatform.iam.gserviceaccount.com"
depends_on = [google_vertex_ai_feature_online_store.featureonlinestore]
}

resource "google_vertex_ai_feature_online_store" "featureonlinestore" {
name = "<%= ctx[:vars]['name'] %>"
project = google_project.project.project_id
labels = {
foo = "bar"
}
region = "us-central1"
bigtable {
auto_scaling {
min_node_count = 1
max_node_count = 2
cpu_utilization_target = 80
}
}
depends_on = [google_project_service.vertexai]
}

resource "google_bigquery_dataset" "sample_dataset" {
dataset_id = "<%= ctx[:vars]['name'] %>"
friendly_name = "test"
description = "This is a test description"
location = "US"
}

resource "google_bigquery_table" "sample_table" {
deletion_protection = false
dataset_id = google_bigquery_dataset.sample_dataset.dataset_id
table_id = "<%= ctx[:vars]['name'] %>"

schema = <<EOF
[
{
"name": "feature_id",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "<%= ctx[:vars]['name'] %>",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "feature_timestamp",
"type": "TIMESTAMP",
"mode": "NULLABLE"
}
]
EOF
}

resource "google_vertex_ai_feature_group" "sample_feature_group" {
name = "<%= ctx[:vars]['name'] %>"
description = "A sample feature group"
region = "us-central1"
labels = {
label-one = "value-one"
}
big_query {
big_query_source {
# The source table must have a column named 'feature_timestamp' of type TIMESTAMP.
input_uri = "bq://${google_bigquery_table.sample_table.project}.${google_bigquery_table.sample_table.dataset_id}.${google_bigquery_table.sample_table.table_id}"
}
entity_id_columns = ["feature_id"]
}
}



resource "google_vertex_ai_feature_group_feature" "sample_feature" {
name = "<%= ctx[:vars]['name'] %>"
region = "us-central1"
feature_group = google_vertex_ai_feature_group.sample_feature_group.name
description = "A sample feature"
labels = {
label-one = "value-one"
}
}


resource "google_vertex_ai_feature_online_store_featureview" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]['name'] %>"
project = google_project.project.project_id
region = "us-central1"
feature_online_store = google_vertex_ai_feature_online_store.featureonlinestore.name
sync_config {
cron = "0 0 * * *"
}
feature_registry_source {

feature_groups {
feature_group_id = google_vertex_ai_feature_group.sample_feature_group.name
feature_ids = [google_vertex_ai_feature_group_feature.sample_feature.name]
}
project_number = data.google_project.test_project.number

}
depends_on = [google_project_service.vertexai, time_sleep.wait_30_seconds]
}

0 comments on commit baa5714

Please sign in to comment.