Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e2d731c
Add labels column to feature field
imjuanleonard Mar 22, 2020
0cdb63b
Add labels to feature spec proto
imjuanleonard Mar 22, 2020
6802e0a
Implement labels on feature model
imjuanleonard Mar 22, 2020
60e4cc8
Implement list labels
imjuanleonard Mar 22, 2020
b597799
Implement set_label and remove_label from feature client
imjuanleonard Mar 22, 2020
4e69b2e
Refactor ingest to only accept featureset and dtype
imjuanleonard Mar 22, 2020
258560c
Add equality on labels field
imjuanleonard Mar 24, 2020
ced6609
Add tests for labels apply
imjuanleonard Mar 24, 2020
1a06833
Add Optional type hint to labels
imjuanleonard Mar 30, 2020
9e768a1
Add empty labels key validation
imjuanleonard Mar 30, 2020
108de14
Add label when generating feature spec for specServiceTest to test eq…
imjuanleonard Apr 1, 2020
c6cf42c
corrected convention (push test)
Apr 24, 2020
b9fd9af
corrected review comments
Apr 26, 2020
f241a4f
Merge branch 'master' into python-sdk-for-labels
Apr 27, 2020
dd88b6c
corrected lint-python check
Apr 27, 2020
2f7c86a
corrected lint-python 2
Apr 27, 2020
30d63fa
back out python SDK changes
Apr 28, 2020
4b7ec66
Implemented labels on a feature set level
Apr 28, 2020
b3a6317
added empty keys validation
Apr 28, 2020
de1153e
corrected review comments (storing empty json for features if labels …
Apr 29, 2020
a756929
Updated the comment to match the logic
suwik Apr 29, 2020
18edc12
added e2e tests for feature and feature set labels
Apr 30, 2020
5e10c94
Merge branch 'python-sdk-for-labels' of https://github.com/imjuanleon…
Apr 30, 2020
02197f8
moved e2e tests for feature and feature set labels
Apr 30, 2020
8d6d4f4
changed tests ordering
Apr 30, 2020
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
Prev Previous commit
Next Next commit
Add tests for labels apply
  • Loading branch information
imjuanleonard committed Mar 30, 2020
commit ced6609d9b2de6b49a730e08394d057b5eaef7c4
76 changes: 75 additions & 1 deletion core/src/test/java/feast/core/service/SpecServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ public void setUp() {
Arrays.asList(featureSet1v1, featureSet1v2, featureSet1v3, featureSet2v1, featureSet3v1);
when(featureSetRepository.findAll()).thenReturn(featureSets);
when(featureSetRepository.findAllByOrderByNameAscVersionAsc()).thenReturn(featureSets);

when(featureSetRepository.findFeatureSetByNameAndProject_NameAndVersion("f1", "project1", 1))
.thenReturn(featureSets.get(0));
when(featureSetRepository.findAllByNameLikeAndProject_NameOrderByNameAscVersionAsc(
Expand Down Expand Up @@ -706,6 +705,81 @@ public void applyFeatureSetShouldUpdateFeatureSetWhenConstraintsAreUpdated()
}
}

@Test
public void applyFeatureSetShouldAcceptLabels() throws InvalidProtocolBufferException {
List<EntitySpec> entitySpecs = new ArrayList<>();
entitySpecs.add(EntitySpec.newBuilder().setName("entity1").setValueType(Enum.INT64).build());

Map<String, String> featureLabels0 =
new HashMap<>() {
{
put("label1", "feast1");
}
};

Map<String, String> featureLabels1 =
new HashMap<>() {
{
put("label1", "feast1");
put("label2", "feast2");
}
};

List<Map<String, String>> featureLabels = new ArrayList<>();
featureLabels.add(featureLabels0);
featureLabels.add(featureLabels1);

List<FeatureSpec> featureSpecs = new ArrayList<>();
featureSpecs.add(
FeatureSpec.newBuilder()
.setName("feature1")
.setValueType(Enum.INT64)
.putAllLabels(featureLabels.get(0))
.build());
featureSpecs.add(
FeatureSpec.newBuilder()
.setName("feature2")
.setValueType(Enum.INT64)
.putAllLabels(featureLabels.get(1))
.build());

FeatureSetSpec featureSetSpec =
FeatureSetSpec.newBuilder()
.setProject("project1")
.setName("featureSetWithConstraints")
Comment thread
suwik marked this conversation as resolved.
.addAllEntities(entitySpecs)
.addAllFeatures(featureSpecs)
.build();
FeatureSetProto.FeatureSet featureSet =
FeatureSetProto.FeatureSet.newBuilder().setSpec(featureSetSpec).build();

ApplyFeatureSetResponse applyFeatureSetResponse = specService.applyFeatureSet(featureSet);
FeatureSetSpec appliedFeatureSetSpec = applyFeatureSetResponse.getFeatureSet().getSpec();

// appliedEntitySpecs needs to be sorted because the list returned by specService may not
// follow the order in the request
List<EntitySpec> appliedEntitySpecs = new ArrayList<>(appliedFeatureSetSpec.getEntitiesList());
appliedEntitySpecs.sort(Comparator.comparing(EntitySpec::getName));

// appliedFeatureSpecs needs to be sorted because the list returned by specService may not
// follow the order in the request
List<FeatureSpec> appliedFeatureSpecs =
new ArrayList<>(appliedFeatureSetSpec.getFeaturesList());
appliedFeatureSpecs.sort(Comparator.comparing(FeatureSpec::getName));

assertEquals(appliedEntitySpecs.size(), entitySpecs.size());
assertEquals(appliedFeatureSpecs.size(), featureSpecs.size());

for (int i = 0; i < appliedEntitySpecs.size(); i++) {
assertEquals(entitySpecs.get(i), appliedEntitySpecs.get(i));
}

for (int i = 0; i < appliedFeatureSpecs.size(); i++) {
Comment thread
suwik marked this conversation as resolved.
Outdated
assertEquals(featureSpecs.get(i), appliedFeatureSpecs.get(i));
assertEquals(featureSpecs.get(i).getLabelsMap(), featureLabels.get(i));
}
}

@Test
public void shouldUpdateStoreIfConfigChanges() throws InvalidProtocolBufferException {
when(storeRepository.findById("SERVING")).thenReturn(Optional.of(stores.get(0)));
Expand Down