Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/src/main/java/feast/core/model/Feature.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public void archive() {
}

/**
* Update the feature object with a valid feature spec. Only schema changes are allowed.
* Update the feature object with a valid feature spec.
*
* @param featureSpec {@link FeatureSpec} containing schema changes.
*/
Expand All @@ -252,6 +252,7 @@ public void updateFromProto(FeatureSpec featureSpec) {
"You are attempting to change the type of feature %s from %s to %s. This isn't allowed. Please create a new feature.",
featureSpec.getName(), type, featureSpec.getValueType()));
}
this.setLabels(TypeConversion.convertMapToJsonString(featureSpec.getLabelsMap()));
updateSchema(featureSpec);
}

Expand Down
7 changes: 4 additions & 3 deletions core/src/main/java/feast/core/model/FeatureSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,10 @@ public void updateFromProto(FeatureSetProto.FeatureSet featureSetProto)
spec.getEntitiesList(), existingEntities));
}

// 4. Update max age and source.
maxAgeSeconds = spec.getMaxAge().getSeconds();
source = Source.fromProto(spec.getSource());
// 2. Update max age, source and labels.
this.maxAgeSeconds = spec.getMaxAge().getSeconds();
this.source = Source.fromProto(spec.getSource());
this.setLabels(TypeConversion.convertMapToJsonString(spec.getLabelsMap()));

Map<String, FeatureSpec> updatedFeatures =
spec.getFeaturesList().stream().collect(Collectors.toMap(FeatureSpec::getName, fs -> fs));
Expand Down
36 changes: 36 additions & 0 deletions core/src/test/java/feast/core/service/SpecServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,42 @@ public void applyFeatureSetShouldAcceptFeatureLabels() throws InvalidProtocolBuf
assertEquals(appliedFeatureSpecsLabels, featureLabels);
}

@Test
public void applyFeatureSetShouldUpdateLabels() throws InvalidProtocolBufferException {
FeatureSpec updatedFeature =
FeatureSpec.newBuilder().setName("feature").setValueType(Enum.STRING).build();

FeatureSet featureSet = featureSets.get(0);
FeatureSetSpec featureSetSpec = featureSet.toProto().getSpec().toBuilder().build();
Map<String, String> featureSetLabels =
new HashMap<>() {
{
put("fsLabel1", "fsValue1");
}
};

FeatureSetProto.FeatureSet incomingFeatureSet =
FeatureSetProto.FeatureSet.newBuilder()
.setSpec(
featureSetSpec
.toBuilder()
.setFeatures(0, updatedFeature)
.putAllLabels(featureSetLabels)
.build())
.build();

ApplyFeatureSetResponse applyFeatureSetResponse =
specService.applyFeatureSet(incomingFeatureSet);
FeatureSetProto.FeatureSet updatedFs = applyFeatureSetResponse.getFeatureSet();
Map<String, String> updatedFsLabels = updatedFs.getSpec().getLabelsMap();

Map<String, String> updatedFeatureLabels = updatedFs.getSpec().getFeatures(0).getLabelsMap();
Map<String, String> emptyFeatureLabels = new HashMap<>();

assertEquals(featureSetLabels, updatedFsLabels);
assertEquals(emptyFeatureLabels, updatedFeatureLabels);
}

@Test
public void applyFeatureSetShouldAcceptFeatureSetLabels() throws InvalidProtocolBufferException {
Map<String, String> featureSetLabels =
Expand Down