Skip to content

Commit c4adf80

Browse files
chore: Rename inputs parameter to sources for on demand feature views (feast-dev#2442)
* Rename `inputs` parameter to `sources` for odfv Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Address CR comments Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fix Go references to ODFV proto Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fix tests Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fix Java Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fix Java again Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fix Python integration tests Signed-off-by: Felix Wang <wangfelix98@gmail.com>
1 parent 6c55e49 commit c4adf80

File tree

11 files changed

+161
-122
lines changed

11 files changed

+161
-122
lines changed

go/internal/feast/ondemandfeatureview.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@ import (
77

88
type OnDemandFeatureView struct {
99
base *BaseFeatureView
10-
inputFeatureViewProjections map[string]*FeatureViewProjection
11-
inputRequestDataSources map[string]*core.DataSource_RequestDataOptions
10+
sourceFeatureViewProjections map[string]*FeatureViewProjection
11+
sourceRequestDataSources map[string]*core.DataSource_RequestDataOptions
1212
}
1313

1414
func NewOnDemandFeatureViewFromProto(proto *core.OnDemandFeatureView) *OnDemandFeatureView {
1515
onDemandFeatureView := &OnDemandFeatureView{base: NewBaseFeatureView(proto.Spec.Name, proto.Spec.Features),
16-
inputFeatureViewProjections: make(map[string]*FeatureViewProjection),
17-
inputRequestDataSources: make(map[string]*core.DataSource_RequestDataOptions),
16+
sourceFeatureViewProjections: make(map[string]*FeatureViewProjection),
17+
sourceRequestDataSources: make(map[string]*core.DataSource_RequestDataOptions),
1818
}
19-
for inputName, onDemandInput := range proto.Spec.Inputs {
20-
if onDemandInputFeatureView, ok := onDemandInput.Input.(*core.OnDemandInput_FeatureView); ok {
21-
featureViewProto := onDemandInputFeatureView.FeatureView
19+
for sourceName, onDemandSource := range proto.Spec.Sources {
20+
if onDemandSourceFeatureView, ok := onDemandSource.Source.(*core.OnDemandSource_FeatureView); ok {
21+
featureViewProto := onDemandSourceFeatureView.FeatureView
2222
featureView := NewFeatureViewFromProto(featureViewProto)
23-
onDemandFeatureView.inputFeatureViewProjections[inputName] = featureView.base.projection
24-
} else if onDemandInputFeatureViewProjection, ok := onDemandInput.Input.(*core.OnDemandInput_FeatureViewProjection); ok {
25-
featureProjectionProto := onDemandInputFeatureViewProjection.FeatureViewProjection
26-
onDemandFeatureView.inputFeatureViewProjections[inputName] = NewFeatureViewProjectionFromProto(featureProjectionProto)
27-
} else if onDemandInputRequestFeatureView, ok := onDemandInput.Input.(*core.OnDemandInput_RequestDataSource); ok {
28-
29-
if dataSourceRequestOptions, ok := onDemandInputRequestFeatureView.RequestDataSource.Options.(*core.DataSource_RequestDataOptions_); ok {
30-
onDemandFeatureView.inputRequestDataSources[inputName] = dataSourceRequestOptions.RequestDataOptions
23+
onDemandFeatureView.sourceFeatureViewProjections[sourceName] = featureView.base.projection
24+
} else if onDemandSourceFeatureViewProjection, ok := onDemandSource.Source.(*core.OnDemandSource_FeatureViewProjection); ok {
25+
featureProjectionProto := onDemandSourceFeatureViewProjection.FeatureViewProjection
26+
onDemandFeatureView.sourceFeatureViewProjections[sourceName] = NewFeatureViewProjectionFromProto(featureProjectionProto)
27+
} else if onDemandSourceRequestFeatureView, ok := onDemandSource.Source.(*core.OnDemandSource_RequestDataSource); ok {
28+
29+
if dataSourceRequestOptions, ok := onDemandSourceRequestFeatureView.RequestDataSource.Options.(*core.DataSource_RequestDataOptions_); ok {
30+
onDemandFeatureView.sourceRequestDataSources[sourceName] = dataSourceRequestOptions.RequestDataOptions
3131
}
3232
}
3333
}
@@ -43,7 +43,7 @@ func (fs *OnDemandFeatureView) NewOnDemandFeatureViewFromBase(base *BaseFeatureV
4343

4444
func (fs *OnDemandFeatureView) getRequestDataSchema() map[string]types.ValueType_Enum {
4545
schema := make(map[string]types.ValueType_Enum)
46-
for _, requestDataSource := range fs.inputRequestDataSources {
46+
for _, requestDataSource := range fs.sourceRequestDataSources {
4747
for fieldName, fieldValueType := range requestDataSource.Schema {
4848
schema[fieldName] = fieldValueType
4949
}

java/serving/src/main/java/feast/serving/service/OnlineServingServiceV2.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,16 @@ public ServingAPIProto.GetOnlineFeaturesResponse getOnlineFeatures(
8888
.collect(Collectors.toList());
8989

9090
// ToDo (pyalex): refactor transformation service to delete unused left part of the returned
91-
// Pair from extractRequestDataFeatureNamesAndOnDemandFeatureInputs.
91+
// Pair from extractRequestDataFeatureNamesAndOnDemandFeatureSources.
9292
// Currently, we can retrieve context variables directly from GetOnlineFeaturesRequest.
93-
List<FeatureReferenceV2> onDemandFeatureInputs =
93+
List<FeatureReferenceV2> onDemandFeatureSources =
9494
this.onlineTransformationService.extractOnDemandFeaturesDependencies(
9595
onDemandFeatureReferences);
9696

97-
// Add on demand feature inputs to list of feature references to retrieve.
98-
for (FeatureReferenceV2 onDemandFeatureInput : onDemandFeatureInputs) {
99-
if (!retrievedFeatureReferences.contains(onDemandFeatureInput)) {
100-
retrievedFeatureReferences.add(onDemandFeatureInput);
97+
// Add on demand feature sources to list of feature references to retrieve.
98+
for (FeatureReferenceV2 onDemandFeatureSource : onDemandFeatureSources) {
99+
if (!retrievedFeatureReferences.contains(onDemandFeatureSource)) {
100+
retrievedFeatureReferences.add(onDemandFeatureSource);
101101
}
102102
}
103103

@@ -194,7 +194,7 @@ public ServingAPIProto.GetOnlineFeaturesResponse getOnlineFeatures(
194194
// data.
195195
this.populateOnDemandFeatures(
196196
onDemandFeatureReferences,
197-
onDemandFeatureInputs,
197+
onDemandFeatureSources,
198198
retrievedFeatureReferences,
199199
request,
200200
features,
@@ -257,7 +257,7 @@ private List<Map<String, ValueProto.Value>> getEntityRows(
257257

258258
private void populateOnDemandFeatures(
259259
List<FeatureReferenceV2> onDemandFeatureReferences,
260-
List<FeatureReferenceV2> onDemandFeatureInputs,
260+
List<FeatureReferenceV2> onDemandFeatureSources,
261261
List<FeatureReferenceV2> retrievedFeatureReferences,
262262
ServingAPIProto.GetOnlineFeaturesRequest request,
263263
List<List<feast.storage.api.retriever.Feature>> features,
@@ -271,7 +271,7 @@ private void populateOnDemandFeatures(
271271
for (int featureIdx = 0; featureIdx < retrievedFeatureReferences.size(); featureIdx++) {
272272
FeatureReferenceV2 featureReference = retrievedFeatureReferences.get(featureIdx);
273273

274-
if (!onDemandFeatureInputs.contains(featureReference)) {
274+
if (!onDemandFeatureSources.contains(featureReference)) {
275275
continue;
276276
}
277277

java/serving/src/main/java/feast/serving/service/OnlineTransformationService.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,55 +83,55 @@ public TransformFeaturesResponse transformFeatures(
8383
@Override
8484
public List<ServingAPIProto.FeatureReferenceV2> extractOnDemandFeaturesDependencies(
8585
List<ServingAPIProto.FeatureReferenceV2> onDemandFeatureReferences) {
86-
List<ServingAPIProto.FeatureReferenceV2> onDemandFeatureInputs = new ArrayList<>();
86+
List<ServingAPIProto.FeatureReferenceV2> onDemandFeatureSources = new ArrayList<>();
8787
for (ServingAPIProto.FeatureReferenceV2 featureReference : onDemandFeatureReferences) {
8888
OnDemandFeatureViewProto.OnDemandFeatureViewSpec onDemandFeatureViewSpec =
8989
this.registryRepository.getOnDemandFeatureViewSpec(featureReference);
90-
Map<String, OnDemandFeatureViewProto.OnDemandInput> inputs =
91-
onDemandFeatureViewSpec.getInputsMap();
90+
Map<String, OnDemandFeatureViewProto.OnDemandSource> sources =
91+
onDemandFeatureViewSpec.getSourcesMap();
9292

93-
for (OnDemandFeatureViewProto.OnDemandInput input : inputs.values()) {
94-
OnDemandFeatureViewProto.OnDemandInput.InputCase inputCase = input.getInputCase();
95-
switch (inputCase) {
93+
for (OnDemandFeatureViewProto.OnDemandSource source : sources.values()) {
94+
OnDemandFeatureViewProto.OnDemandSource.SourceCase sourceCase = source.getSourceCase();
95+
switch (sourceCase) {
9696
case REQUEST_DATA_SOURCE:
9797
// Do nothing. The value should be provided as dedicated request parameter
9898
break;
9999
case FEATURE_VIEW_PROJECTION:
100100
FeatureReferenceProto.FeatureViewProjection projection =
101-
input.getFeatureViewProjection();
101+
source.getFeatureViewProjection();
102102
for (FeatureProto.FeatureSpecV2 featureSpec : projection.getFeatureColumnsList()) {
103103
String featureName = featureSpec.getName();
104-
ServingAPIProto.FeatureReferenceV2 onDemandFeatureInput =
104+
ServingAPIProto.FeatureReferenceV2 onDemandFeatureSource =
105105
ServingAPIProto.FeatureReferenceV2.newBuilder()
106106
.setFeatureViewName(projection.getFeatureViewName())
107107
.setFeatureName(featureName)
108108
.build();
109-
onDemandFeatureInputs.add(onDemandFeatureInput);
109+
onDemandFeatureSources.add(onDemandFeatureSource);
110110
}
111111
break;
112112
case FEATURE_VIEW:
113-
FeatureViewProto.FeatureView featureView = input.getFeatureView();
113+
FeatureViewProto.FeatureView featureView = source.getFeatureView();
114114
FeatureViewProto.FeatureViewSpec featureViewSpec = featureView.getSpec();
115115
String featureViewName = featureViewSpec.getName();
116116
for (FeatureProto.FeatureSpecV2 featureSpec : featureViewSpec.getFeaturesList()) {
117117
String featureName = featureSpec.getName();
118-
ServingAPIProto.FeatureReferenceV2 onDemandFeatureInput =
118+
ServingAPIProto.FeatureReferenceV2 onDemandFeatureSource =
119119
ServingAPIProto.FeatureReferenceV2.newBuilder()
120120
.setFeatureViewName(featureViewName)
121121
.setFeatureName(featureName)
122122
.build();
123-
onDemandFeatureInputs.add(onDemandFeatureInput);
123+
onDemandFeatureSources.add(onDemandFeatureSource);
124124
}
125125
break;
126126
default:
127127
throw Status.INTERNAL
128128
.withDescription(
129-
"OnDemandInput proto input field has an unexpected type: " + inputCase)
129+
"OnDemandSource proto source field has an unexpected type: " + sourceCase)
130130
.asRuntimeException();
131131
}
132132
}
133133
}
134-
return onDemandFeatureInputs;
134+
return onDemandFeatureSources;
135135
}
136136

137137
/** {@inheritDoc} */
@@ -321,8 +321,8 @@ public ValueType serializeValuesIntoArrowIPC(List<Pair<String, List<ValueProto.V
321321
.asRuntimeException();
322322
}
323323
byte[] byteData = out.toByteArray();
324-
ByteString inputData = ByteString.copyFrom(byteData);
325-
ValueType transformationInput = ValueType.newBuilder().setArrowValue(inputData).build();
324+
ByteString sourceData = ByteString.copyFrom(byteData);
325+
ValueType transformationInput = ValueType.newBuilder().setArrowValue(sourceData).build();
326326
return transformationInput;
327327
}
328328
}

java/serving/src/main/java/feast/serving/service/TransformationService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ public interface TransformationService {
3535
TransformFeaturesResponse transformFeatures(TransformFeaturesRequest transformFeaturesRequest);
3636

3737
/**
38-
* Extract the list of on demand feature inputs from a list of ODFV references.
38+
* Extract the list of on demand feature sources from a list of ODFV references.
3939
*
4040
* @param onDemandFeatureReferences list of ODFV references to be parsed
41-
* @return list of on demand feature inputs
41+
* @return list of on demand feature sources
4242
*/
4343
List<ServingAPIProto.FeatureReferenceV2> extractOnDemandFeaturesDependencies(
4444
List<ServingAPIProto.FeatureReferenceV2> onDemandFeatureReferences);

protos/feast/core/OnDemandFeatureView.proto

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ message OnDemandFeatureViewSpec {
4545
// List of features specifications for each feature defined with this feature view.
4646
repeated FeatureSpecV2 features = 3;
4747

48-
// Map of inputs for this feature view.
49-
map<string, OnDemandInput> inputs = 4;
48+
// Map of sources for this feature view.
49+
map<string, OnDemandSource> sources = 4;
5050

5151
UserDefinedFunction user_defined_function = 5;
5252

@@ -68,8 +68,8 @@ message OnDemandFeatureViewMeta {
6868
google.protobuf.Timestamp last_updated_timestamp = 2;
6969
}
7070

71-
message OnDemandInput {
72-
oneof input {
71+
message OnDemandSource {
72+
oneof source {
7373
FeatureView feature_view = 1;
7474
FeatureViewProjection feature_view_projection = 3;
7575
DataSource request_data_source = 2;

sdk/python/feast/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def feature_view_list(ctx: click.Context):
345345
if isinstance(feature_view, FeatureView):
346346
entities.update(feature_view.entities)
347347
elif isinstance(feature_view, OnDemandFeatureView):
348-
for backing_fv in feature_view.input_feature_view_projections.values():
348+
for backing_fv in feature_view.source_feature_view_projections.values():
349349
entities.update(store.get_feature_view(backing_fv.name).entities)
350350
table.append(
351351
[

sdk/python/feast/feature_store.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ def apply(
672672
data_sources_set_to_update.add(rfv.request_data_source)
673673

674674
for odfv in odfvs_to_update:
675-
for v in odfv.input_request_data_sources.values():
675+
for v in odfv.source_request_data_sources.values():
676676
data_sources_set_to_update.add(v)
677677

678678
data_sources_to_update = list(data_sources_set_to_update)
@@ -1878,7 +1878,7 @@ def _get_feature_views_to_use(
18781878
odfv = od_fvs[fv_name].with_projection(copy.copy(projection))
18791879
od_fvs_to_use.append(odfv)
18801880
# Let's make sure to include an FVs which the ODFV requires Features from.
1881-
for projection in odfv.input_feature_view_projections.values():
1881+
for projection in odfv.source_feature_view_projections.values():
18821882
fv = fvs[projection.name].with_projection(copy.copy(projection))
18831883
if fv not in fvs_to_use:
18841884
fvs_to_use.append(fv)
@@ -2005,7 +2005,7 @@ def _group_feature_refs(
20052005
# Let's also add in any FV Feature dependencies here.
20062006
for input_fv_projection in on_demand_view_index[
20072007
view_name
2008-
].input_feature_view_projections.values():
2008+
].source_feature_view_projections.values():
20092009
for input_feat in input_fv_projection.features:
20102010
views_features[input_fv_projection.name].add(input_feat.name)
20112011
elif view_name in request_view_index:

0 commit comments

Comments
 (0)