From a9dea00212d1d71620eaa18ae2acbec7219efc95 Mon Sep 17 00:00:00 2001 From: omiranda Date: Mon, 25 Sep 2023 12:12:34 -0500 Subject: [PATCH 1/2] Adding option to omit status response from go feature server response --- go/internal/feast/server/http_server.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/go/internal/feast/server/http_server.go b/go/internal/feast/server/http_server.go index 80a0a346d1..256bba9669 100644 --- a/go/internal/feast/server/http_server.go +++ b/go/internal/feast/server/http_server.go @@ -136,6 +136,7 @@ type getOnlineFeaturesRequest struct { Entities map[string]repeatedValue `json:"entities"` FullFeatureNames bool `json:"full_feature_names"` RequestContext map[string]repeatedValue `json:"request_context"` + Status bool `json:"status"` } func NewHttpServer(fs *feast.FeatureStore, loggingService *logging.LoggingService) *httpServer { @@ -190,17 +191,19 @@ func (s *httpServer) getOnlineFeatures(w http.ResponseWriter, r *http.Request) { for _, vector := range featureVectors { featureNames = append(featureNames, vector.Name) result := make(map[string]interface{}) - var statuses []string - for _, status := range vector.Statuses { - statuses = append(statuses, status.String()) - } - var timestamps []string - for _, timestamp := range vector.Timestamps { - timestamps = append(timestamps, timestamp.AsTime().Format(time.RFC3339)) - } + if request.Status { + var statuses []string + for _, status := range vector.Statuses { + statuses = append(statuses, status.String()) + } + var timestamps []string + for _, timestamp := range vector.Timestamps { + timestamps = append(timestamps, timestamp.AsTime().Format(time.RFC3339)) + } - result["statuses"] = statuses - result["event_timestamps"] = timestamps + result["statuses"] = statuses + result["event_timestamps"] = timestamps + } // Note, that vector.Values is an Arrow Array, but this type implements JSON Marshaller. // So, it's not necessary to pre-process it in any way. result["values"] = vector.Values From 91f8be2bc36c6ef09bc790d2a98bc7726309b900 Mon Sep 17 00:00:00 2001 From: omiranda Date: Mon, 25 Sep 2023 22:40:58 -0500 Subject: [PATCH 2/2] Make status a query parameter --- go/internal/feast/server/http_server.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/go/internal/feast/server/http_server.go b/go/internal/feast/server/http_server.go index 256bba9669..b25eaa8f09 100644 --- a/go/internal/feast/server/http_server.go +++ b/go/internal/feast/server/http_server.go @@ -6,6 +6,7 @@ import ( "fmt" "net/http" "os" + "strconv" "strings" "time" @@ -136,7 +137,6 @@ type getOnlineFeaturesRequest struct { Entities map[string]repeatedValue `json:"entities"` FullFeatureNames bool `json:"full_feature_names"` RequestContext map[string]repeatedValue `json:"request_context"` - Status bool `json:"status"` } func NewHttpServer(fs *feast.FeatureStore, loggingService *logging.LoggingService) *httpServer { @@ -149,6 +149,17 @@ func (s *httpServer) getOnlineFeatures(w http.ResponseWriter, r *http.Request) { return } + statusQuery := r.URL.Query().Get("status") + status := false + if statusQuery != "" { + var err error + status, err = strconv.ParseBool(statusQuery) + if err != nil { + http.Error(w, fmt.Sprintf("Error parsing status query parameter: %+v", err), http.StatusBadRequest) + return + } + } + decoder := json.NewDecoder(r.Body) var request getOnlineFeaturesRequest err := decoder.Decode(&request) @@ -191,7 +202,7 @@ func (s *httpServer) getOnlineFeatures(w http.ResponseWriter, r *http.Request) { for _, vector := range featureVectors { featureNames = append(featureNames, vector.Name) result := make(map[string]interface{}) - if request.Status { + if status { var statuses []string for _, status := range vector.Statuses { statuses = append(statuses, status.String())