-
Notifications
You must be signed in to change notification settings - Fork 0
/
query.go
32 lines (28 loc) · 1.04 KB
/
query.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package vertigo
import (
"fmt"
"cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb"
)
// Query represents a query to the Vertex AI Online Feature Store API for
// getting an Entity's Feature Values.
type Query struct {
EntityType string
EntityID string
Features []string
}
// BuildRequest translates the Query struct into an AI Platform ReadFeatureValuesRequest, which is submitted
// to the Vertex AI Online Feature Store API to retrieve the Feature Values for an entity.
func (q *Query) BuildRequest(cfg *Config) *aiplatformpb.ReadFeatureValuesRequest {
return &aiplatformpb.ReadFeatureValuesRequest{
EntityType: makeVertexEntityTypePath(cfg, q.EntityType),
EntityId: q.EntityID,
FeatureSelector: &aiplatformpb.FeatureSelector{IdMatcher: &aiplatformpb.IdMatcher{Ids: q.Features}},
}
}
// makeVertexEntityTypePath builds the resource name for the specific entity being queried.
func makeVertexEntityTypePath(cfg *Config, entityType string) string {
return fmt.Sprintf(
"%v/entityTypes/%v",
cfg.ParentPath(), entityType,
)
}