Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make it possible to deifine a feature in Vertex AI FeatureStore #6568

75 changes: 75 additions & 0 deletions mmv1/products/vertexai/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,81 @@ objects:
Configuration of the snapshot analysis based monitoring pipeline running interval. The value is rolled up to full day.

A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".

# Vertex AI Featurestore Entity Type Feature
- !ruby/object:Api::Resource
name: FeaturestoreEntitytypeFeature
base_url: '{{entitytype}}/features'
create_url: '{{entitytype}}/features?featureId={{name}}'
self_link: '{{entitytype}}/features/{{name}}'
min_version: beta
update_verb: :PATCH
update_mask: true
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Official Documentation':
'https://cloud.google.com/vertex-ai/docs'
api: 'https://cloud.google.com/vertex-ai/docs/reference/rest/v1beta1/projects.locations.featurestores.entityTypes.features'
async: !ruby/object:Api::OpAsync
operation: !ruby/object:Api::OpAsync::Operation
path: 'name'
base_url: '{{op_id}}'
wait_ms: 1000
result: !ruby/object:Api::OpAsync::Result
path: 'response'
resource_inside_response: true
status: !ruby/object:Api::OpAsync::Status
path: 'done'
complete: True
allowed:
- True
- False
error: !ruby/object:Api::OpAsync::Error
path: 'error'
message: 'message'
include_project: true
description: |-
Feature Metadata information that describes an attribute of an entity type. For example, apple is an entity type, and color is a feature that describes apple.
parameters:
- !ruby/object:Api::Type::String
name: entitytype
description: The name of the Featurestore to use, in the format projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entitytype}.
url_param_only: true
input: true
required: true
properties:
- !ruby/object:Api::Type::String
name: 'name'
description: The name of the feature. The feature can be up to 64 characters long and can consist only of ASCII Latin letters A-Z and a-z, underscore(_), and ASCII digits 0-9 starting with a letter. The value will be unique given an entity type.
input: true
url_param_only: true
pattern: '{{entitytype}}/features/{{name}}'
- !ruby/object:Api::Type::String
name: 'etag'
description: Used to perform consistent read-modify-write updates.
output: true
- !ruby/object:Api::Type::String
name: 'createTime'
output: true
description: |
The timestamp of when the entity type was created in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.
- !ruby/object:Api::Type::String
name: 'updateTime'
output: true
description: |
The timestamp when the entity type was most recently updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.
- !ruby/object:Api::Type::KeyValuePairs
name: 'labels'
description: |
A set of key/value label pairs to assign to the feature.
- !ruby/object:Api::Type::String
name: 'description'
description: Description of the feature.
- !ruby/object:Api::Type::String
name: 'valueType'
description: |
Type of Feature value. Immutable. https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.featurestores.entityTypes.features#ValueType
required: true
# Vertex ML Metadata
- !ruby/object:Api::Resource
name: MetadataStore
Expand Down
25 changes: 24 additions & 1 deletion mmv1/products/vertexai/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides
billing_account: :BILLING_ACCT
test_vars_overrides:
kms_key_name: 'BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name'

properties:
etag: !ruby/object:Overrides::Terraform::PropertyOverride
ignore_read: true
Expand All @@ -89,6 +88,30 @@ overrides: !ruby/object:Overrides::ResourceOverrides
pre_create: templates/terraform/constants/vertex_ai_featurestore_entitytype.go.erb
pre_update: templates/terraform/constants/vertex_ai_featurestore_entitytype.go.erb
pre_delete: templates/terraform/constants/vertex_ai_featurestore_entitytype.go.erb
FeaturestoreEntitytypeFeature: !ruby/object:Overrides::Terraform::ResourceOverride
import_format: ["{{%entitytype}}/features/{{name}}"]
autogen_async: false
examples:
- !ruby/object:Provider::Terraform::Examples
name: "vertex_ai_featurestore_entitytype_feature"
primary_resource_id: "feature"
vars:
name: "terraform"
project: "vertex-ai"
kms_key_name: "kms-name"
test_env_vars:
org_id: :ORG_ID
billing_account: :BILLING_ACCT
test_vars_overrides:
properties:
etag: !ruby/object:Overrides::Terraform::PropertyOverride
ignore_read: true
name: !ruby/object:Overrides::Terraform::PropertyOverride
custom_flatten: templates/terraform/custom_flatten/name_from_self_link.erb
custom_code: !ruby/object:Provider::Terraform::CustomCode
pre_create: templates/terraform/constants/vertex_ai_featurestore_entitytype_feature.go.erb
pre_update: templates/terraform/constants/vertex_ai_featurestore_entitytype_feature.go.erb
pre_delete: templates/terraform/constants/vertex_ai_featurestore_entitytype_feature.go.erb
MetadataStore: !ruby/object:Overrides::Terraform::ResourceOverride
autogen_async: false
id_format: '{{name}}'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
if v, ok := d.GetOk("entitytype"); ok {
re := regexp.MustCompile("projects/([a-zA-Z0-9-]*)/(?:locations|regions)/([a-zA-Z0-9-]*)")
switch {
case re.MatchString(v.(string)):
if res := re.FindStringSubmatch(v.(string)); len(res) == 3 && res[1] != "" {
project = res[1]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
resource "google_vertex_ai_featurestore" "featurestore" {
provider = google-beta
name = "<%= ctx[:vars]['name'] %>"
labels = {
foo = "bar"
}
region = "us-central1"
online_serving_config {
fixed_node_count = 2
}
}

resource "google_vertex_ai_featurestore_entitytype" "entity" {
provider = google-beta
name = "<%= ctx[:vars]['name'] %>"
labels = {
foo = "bar"
}
featurestore = google_vertex_ai_featurestore.featurestore.id
monitoring_config {
snapshot_analysis {
disabled = false
monitoring_interval = "86400s"
}
}
}

resource "google_vertex_ai_featurestore_entitytype_feature" "feature" {
provider = google-beta
name = "<%= ctx[:vars]['name'] %>"
labels = {
foo = "bar"
}
entitytype = google_vertex_ai_featurestore_entitytype.entity.id

value_type = "INT64_ARRAY"
}
15 changes: 9 additions & 6 deletions mmv1/templates/terraform/resource.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ import (
timeouts ||= Api::Timeouts.new
-%>

<% if object.async&.is_a? Api::OpAsync -%>
<% if object.async.include_project -%>
var project string
<% end -%>
<% end -%>

func resource<%= resource_name -%>() *schema.Resource {
return &schema.Resource{
Create: resource<%= resource_name -%>Create,
Expand Down Expand Up @@ -166,6 +160,9 @@ func resource<%= resource_name -%><%= prop.name.camelize(:upper) -%>SetStyleDiff
<% end -%>

func resource<%= resource_name -%>Create(d *schema.ResourceData, meta interface{}) error {
<% if object.async&.is_a?(Api::OpAsync) && object.async.include_project -%>
var project string
<% end -%>
config := meta.(*Config)
<% if object.custom_code.custom_create -%>
<%= lines(compile(pwd + '/' + object.custom_code.custom_create)) -%>
Expand Down Expand Up @@ -576,6 +573,9 @@ func resource<%= resource_name -%>Read(d *schema.ResourceData, meta interface{})

<% if updatable?(object, object.root_properties) -%>
func resource<%= resource_name -%>Update(d *schema.ResourceData, meta interface{}) error {
<% if object.async&.is_a?(Api::OpAsync) && object.async.include_project -%>
var project string
<% end -%>
config := meta.(*Config)
userAgent, err := generateUserAgentString(d, config.userAgent)
if err != nil {
Expand Down Expand Up @@ -835,6 +835,9 @@ if <%= props.map { |prop| "d.HasChange(\"#{prop.name.underscore}\")" }.join ' ||
<% end # if updatable? -%>

func resource<%= resource_name -%>Delete(d *schema.ResourceData, meta interface{}) error {
<% if object.async&.is_a?(Api::OpAsync) && object.async.include_project -%>
var project string
<% end -%>
<% if object.skip_delete -%>
log.Printf("[WARNING] <%= object.__product.name + " " + object.name %> resources" +
" cannot be deleted from Google Cloud. The resource %s will be removed from Terraform" +
Expand Down