Skip to content

Commit

Permalink
tmpl fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
BBBmau committed Oct 29, 2024
1 parent b6c68f0 commit 5a0506a
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 86 deletions.
83 changes: 38 additions & 45 deletions mmv1/products/vertexai/Models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ async:
result:
path: 'response'
resource_inside_response: true
status:
path: 'done'
complete: true
allowed:
- true
- false
error:
path: 'error'
message: 'message'
Expand Down Expand Up @@ -138,6 +132,7 @@ properties:
The ID of the export format.
- type: Enum
name: exportableContent
default_from_api: true
immutable: true
description: |
The content of this Model that may be exported.
Expand Down Expand Up @@ -290,8 +285,10 @@ properties:
description: |
The timestamp of when the MetadataStore was last updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.
- type: String
name: 'displayName'
default_from_api: true
name: 'modelName'
at_least_one_of:
- modelName
- sourceModel
description:
The display name of the Model. The name can be up to 128 characters long
and can consist of any UTF-8 characters.
Expand All @@ -302,7 +299,7 @@ properties:
ignore_read: true
- type: Array
name: 'versionAliases'
default_from_api: true
ignore_read: true
description:
user provided version aliases so that a model version can be referenced via alias.
item_type:
Expand All @@ -324,6 +321,7 @@ properties:
immutable: true
- type: NestedObject
name: 'metadata'
ignore_read: true
description: An additional information about the Index
properties:
- type: NestedObject
Expand Down Expand Up @@ -411,20 +409,15 @@ properties:
name: 'sourceModel'
default_from_api: true
at_least_one_of:
- model
- modelName
- sourceModel
description: |
The resource name of the Model to copy. That Model must be in the same Project
- type: ResourceRef
name: 'model'
resource: 'Model'
imports: 'displayName'
at_least_one_of:
- sourceModel
- model
- type: String
name: 'modelId'
default_from_api: true
description: |
The Model to create.
custom_expand: 'templates/terraform/custom_expand/resourceref_with_validation.go.erb'
Copy sourceModel into a new Model with this ID. The ID will become the final component of the model resource name.
- type: NestedObject
name: 'explanationSpec'
description: The pointers to DeployedModels created from this Model. Note that Model could have been deployed to Endpoints in different Locations.
Expand All @@ -443,7 +436,8 @@ properties:
name: 'outputIndices'
description: If populated, only returns attributions that have outputIndex contained in outputIndices.
immutable: true
item_type: Api::Type::Double
item_type:
type: Double
## Union field method can be only one of the following
- type: NestedObject
name: 'sampledShapleyAttribution'
Expand Down Expand Up @@ -486,16 +480,16 @@ properties:
- type: Array
name: 'noiseSigma'
description: The number of gradient samples to use for approximation.
item_type:
item_type:
type: NestedObject
properties:
- type: String
name: 'name'
description: The name of the input feature for which noise sigma is provided.
- type: Double
name: 'sigma'
description: This represents the standard deviation of the Gaussian kernel that will be used to add noise to the feature prior to computing gradients.
default_value: 0.1
# - type: Double
# name: 'sigma'
# description: This represents the standard deviation of the Gaussian kernel that will be used to add noise to the feature prior to computing gradients.
# default_value: 0.1
- type: NestedObject
name: 'blurBaselineConfig'
description: Config for IG with blur baseline.
Expand Down Expand Up @@ -531,7 +525,7 @@ properties:
- type: Array
name: 'noiseSigma'
description: The number of gradient samples to use for approximation.
item_type:
item_type:
type: NestedObject
properties:
- type: String
Expand Down Expand Up @@ -564,7 +558,7 @@ properties:
- type: Enum
name: 'dataFormat'
description: 'The format in which instances are given, if not specified, assume its JSONL format. Currently only JSONL format is supported.'
values:
enum_values:
- :JSONL
- type: NestedObject
name: 'gcsSource'
Expand All @@ -574,7 +568,8 @@ properties:
name: 'uris'
required: true
description: 'Google Cloud Storage URI(-s) to the input file(s). May contain wildcards.'
item_type: Api::Type::String
item_type:
type: String
- type: NestedObject
name: 'nearestNeighborSearchConfig'
description: The number of neighbors to return when querying for examples.
Expand Down Expand Up @@ -691,14 +686,14 @@ properties:
- type: Enum
name: 'modality'
description: The modality of the uploaded model, which automatically configures the distance measurement and feature normalization for the underlying example index and queries
values:
enum_values:
- :IMAGE
- :TEXT
- :TABULAR
- type: Enum
name: 'query'
description: Preset option controlling parameters for speed-precision trade-off when querying for examples. If omitted, defaults to PRECISE.
values:
enum_values:
- :PRECISE
- :FAST
- type: NestedObject
Expand All @@ -710,7 +705,7 @@ properties:
key_name: 'name'
description: The resource name of the Artifact that was created in MetadataStore when creating the Model.
required: true
value_type:
value_type:
type: NestedObject
properties:
- type: String
Expand All @@ -721,7 +716,7 @@ properties:
name: 'encoding'
description: |
Defines how the feature is encoded into the input tensor. Defaults to IDENTITY.
values:
enum_values:
- IDENTITY
- BAG_OF_FEATURES
- BAG_OF_FEATURES_SPARSE
Expand Down Expand Up @@ -768,7 +763,8 @@ properties:
required: true
description: |
A list of feature names for each index in the input tensor.
item_type: Api::Type::String
item_type:
type: String
- type: String
name: 'encodedTensorName'
description: |
Expand All @@ -777,7 +773,8 @@ properties:
name: 'encodedBaselines'
description: |
A list of baselines for the encoded tensor.
item_type: Api::Type::Double
item_type:
type: Double
- type: NestedObject
name: 'visualization'
required: true
Expand All @@ -788,23 +785,23 @@ properties:
name: 'type'
description: |
type of the image visualization. Only applicable to Integrated Gradients attribution.
values:
enum_values:
- :PIXELS
- :OUTLINES
- type: Enum
name: 'polarity'
description: |
Whether to only highlight pixels with positive contributions, negative or both. Defaults to POSITIVE.
default_value: :BOTH
values:
enum_values:
- :POSITIVE
- :NEGATIVE
- :BOTH
- type: Enum
name: 'colorMap'
description: |
The color scheme used for highlighting areas.
values:
enum_values:
- :PINK_GREEN
- :VIRIDIS
- :RED
Expand All @@ -825,7 +822,7 @@ properties:
name: 'overlayType'
description: |
How the original image is displayed in the visualization.
values:
enum_values:
- :NONE
- :ORIGINAL
- :GRAYSCALE
Expand All @@ -840,7 +837,7 @@ properties:
key_name: 'name'
description: The resource name of the Artifact that was created in MetadataStore when creating the Model.
required: true
value_type:
value_type:
type: NestedObject
properties:
- type: String
Expand All @@ -852,7 +849,8 @@ properties:
name: 'indexDisplayNameMapping'
description: |
Static mapping between the index and display name.
item_type: Api::Type::String
item_type:
type: String
- type: String
name: 'displayNameMappingKey'
description: |
Expand All @@ -864,8 +862,3 @@ properties:
- type: String
name: 'latentSpaceSource'
description: name of the source to generate embeddings for example based explanations.
- type: String
name: 'modelId'
default_from_api: true
description: |
Copy sourceModel into a new Model with this ID. The ID will become the final component of the model resource name.
23 changes: 22 additions & 1 deletion mmv1/templates/terraform/decoders/vertex_ai_models.go.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
if res["model"] != "" {
res["name"] = res["model"]
res["name"] = res["model"]
}
if _, ok := d.GetOk("source_model"); ok {
res["sourceModel"] = d.Get("source_model").(string)
}
if _, ok := d.GetOk("model_id"); ok {
res["modelId"] = d.Get("model_id").(string)
}

// Create a new map with the default label
res["labels"] = map[string]interface{}{
"goog-terraform-provisioned": "true",
}

// Merge user-defined labels
if v, ok := d.GetOk("labels"); ok {
userLabels := v.(map[string]interface{})
for k, v := range userLabels {
res["labels"].(map[string]interface{})[k] = v
}
}

res["modelName"] = d.Get("model_name").(string)

return res, nil
13 changes: 0 additions & 13 deletions mmv1/templates/terraform/decoders/vertex_ai_models.tmpl

This file was deleted.

17 changes: 16 additions & 1 deletion mmv1/templates/terraform/encoders/vertex_ai_models.go.tmpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
if obj["modelName"] != nil {
newObj := make(map[string]interface{})
obj["displayName"] = obj["modelName"]
delete(obj, "modelName")
newObj["model"] = obj
newObj["modelId"] = obj["modelId"]
delete(obj, "modelId")
return newObj, nil
} else if obj["sourceModel"] != nil {
delete(obj, "labels")
delete(obj, "metadata")
}

newObj := make(map[string]interface{})
name := ""
if v, ok := d.GetOk("model_id"); ok {
Expand All @@ -12,4 +25,6 @@ if v, ok := d.GetOk("parent_model"); ok {
delete(obj,"parentModel")
}
newObj["model"] = obj
return newObj, nil
return newObj, nil

return obj, nil
22 changes: 0 additions & 22 deletions mmv1/templates/terraform/encoders/vertex_ai_models.tmpl

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
resource "google_vertex_ai_models" "<%= ctx[:primary_resource_id] %>" {
display_name = "<%= ctx[:vars]['display_name'] %>"
model_name = "<%= ctx[:vars]['display_name'] %>"
description = "basic upload model"

metadata_schema_uri = "gs://cloud-ai-platform-d357fffa-aab0-409b-8e4e-3af03de82d76/instance_schemas/job-5547038670390820864/analysis"

version_aliases = ["v2beta1"]
model_id = "id_upload_test"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var postRequestType string
if _, ok := d.GetOk("model"); ok {
if _, ok := d.GetOk("model_name"); ok {
postRequestType = ":upload"
}

Expand Down

0 comments on commit 5a0506a

Please sign in to comment.