Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.3 backport: Fail Spotless check before tests #516

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package feast.core.config;

import com.google.common.base.Strings;
import feast.core.SourceProto.KafkaSourceConfig;
import feast.core.SourceProto.SourceType;
import feast.core.config.FeastProperties.StreamProperties;
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/feast/core/dao/FeatureSetRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public interface FeatureSetRepository extends JpaRepository<FeatureSet, String>
List<FeatureSet> findByName(String name);

// find all versions of featureSets with names matching the regex
@Query(nativeQuery = true, value = "SELECT * FROM feature_sets "
+ "WHERE name LIKE ?1 ORDER BY name ASC, version ASC")
@Query(
nativeQuery = true,
value = "SELECT * FROM feature_sets " + "WHERE name LIKE ?1 ORDER BY name ASC, version ASC")
List<FeatureSet> findByNameWithWildcardOrderByNameAscVersionAsc(String name);

// find all feature sets and order by name and version
List<FeatureSet> findAllByOrderByNameAscVersionAsc();

}
5 changes: 1 addition & 4 deletions core/src/main/java/feast/core/grpc/CoreServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@
import lombok.extern.slf4j.Slf4j;
import org.lognet.springboot.grpc.GRpcService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

/**
* Implementation of the feast core GRPC service.
*/
/** Implementation of the feast core GRPC service. */
@Slf4j
@GRpcService(interceptors = {MonitoringInterceptor.class})
public class CoreServiceImpl extends CoreServiceImplBase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import com.google.api.services.dataflow.Dataflow;
import com.google.api.services.dataflow.model.Job;
import com.google.common.base.Strings;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.util.JsonFormat;
import com.google.protobuf.util.JsonFormat.Printer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package feast.core.job.direct;

import com.google.common.base.Strings;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package feast.core.job.direct;

import com.google.common.base.Strings;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.util.JsonFormat;
import com.google.protobuf.util.JsonFormat.Printer;
Expand Down Expand Up @@ -148,8 +147,7 @@ public void abortJob(String extId) {
try {
job.abort();
} catch (IOException e) {
throw new RuntimeException(
String.format("Unable to abort DirectRunner job %s", extId), e);
throw new RuntimeException(String.format("Unable to abort DirectRunner job %s", extId), e);
}
jobs.remove(extId);
}
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/feast/core/log/AuditLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package feast.core.log;

import com.google.common.base.Strings;
import java.util.Date;
import java.util.Map;
import java.util.TreeMap;
Expand Down
25 changes: 12 additions & 13 deletions core/src/main/java/feast/core/model/FeatureSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,50 +155,49 @@ public FeatureSetSpec toProto() throws InvalidProtocolBufferException {
* @return boolean denoting if the source or schema have changed.
*/
public boolean equalTo(FeatureSet other) {
if(!name.equals(other.getName())){
if (!name.equals(other.getName())) {
return false;
}

if (!source.equalTo(other.getSource())){
if (!source.equalTo(other.getSource())) {
return false;
}

if (maxAgeSeconds != other.maxAgeSeconds){
if (maxAgeSeconds != other.maxAgeSeconds) {
return false;
}

// Create a map of all fields in this feature set
Map<String, Field> fields = new HashMap<>();

for (Field e : entities){
for (Field e : entities) {
fields.putIfAbsent(e.getName(), e);
}

for (Field f : features){
for (Field f : features) {
fields.putIfAbsent(f.getName(), f);
}

// Ensure map size is consistent with existing fields
if (fields.size() != other.features.size() + other.entities.size())
{
if (fields.size() != other.features.size() + other.entities.size()) {
return false;
}

// Ensure the other entities and fields exist in the field map
for (Field e : other.entities){
if(!fields.containsKey(e.getName())){
for (Field e : other.entities) {
if (!fields.containsKey(e.getName())) {
return false;
}
if (!e.equals(fields.get(e.getName()))){
if (!e.equals(fields.get(e.getName()))) {
return false;
}
}

for (Field f : features){
if(!fields.containsKey(f.getName())){
for (Field f : features) {
if (!fields.containsKey(f.getName())) {
return false;
}
if (!f.equals(fields.get(f.getName()))){
if (!f.equals(fields.get(f.getName()))) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package feast.core.service;

import com.google.common.base.Strings;
import feast.core.FeatureSetProto.FeatureSetSpec;
import feast.core.SourceProto;
import feast.core.StoreProto;
Expand Down
16 changes: 10 additions & 6 deletions core/src/main/java/feast/core/service/SpecService.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ public GetFeatureSetResponse getFeatureSet(GetFeatureSetRequest request)

if (featureSet == null) {
throw io.grpc.Status.NOT_FOUND
.withDescription(String.format("Feature set with name \"%s\" could not be found.",
request.getName()))
.withDescription(
String.format(
"Feature set with name \"%s\" could not be found.", request.getName()))
.asRuntimeException();
}
} else {
Expand All @@ -121,13 +122,14 @@ public GetFeatureSetResponse getFeatureSet(GetFeatureSetRequest request)

if (featureSet == null) {
throw io.grpc.Status.NOT_FOUND
.withDescription(String.format("Feature set with name \"%s\" and version \"%s\" could "
+ "not be found.", request.getName(), request.getVersion()))
.withDescription(
String.format(
"Feature set with name \"%s\" and version \"%s\" could " + "not be found.",
request.getName(), request.getVersion()))
.asRuntimeException();
}
}


// Only a single item in list, return successfully
return GetFeatureSetResponse.newBuilder().setFeatureSet(featureSet.toProto()).build();
}
Expand All @@ -154,7 +156,9 @@ public ListFeatureSetsResponse listFeatureSets(ListFeatureSetsRequest.Filter fil
if (name.equals("")) {
featureSets = featureSetRepository.findAllByOrderByNameAscVersionAsc();
} else {
featureSets = featureSetRepository.findByNameWithWildcardOrderByNameAscVersionAsc(name.replace('*', '%'));
featureSets =
featureSetRepository.findByNameWithWildcardOrderByNameAscVersionAsc(
name.replace('*', '%'));
featureSets =
featureSets.stream()
.filter(getVersionFilter(filter.getFeatureSetVersion()))
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/feast/core/util/PackageUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public class PackageUtil {
* points to the resource location. Note that the extraction process can take several minutes to
* complete.
*
* <p>One use case of this function is to detect the class path of resources to stage when
* using Dataflow runner. The resource URL however is in "jar:file:" format, which cannot be
* handled by default in Apache Beam.
* <p>One use case of this function is to detect the class path of resources to stage when using
* Dataflow runner. The resource URL however is in "jar:file:" format, which cannot be handled by
* default in Apache Beam.
*
* <pre>
* <code>
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/feast/core/util/TypeConversion.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package feast.core.util;

import com.google.common.base.Strings;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
Expand Down
30 changes: 14 additions & 16 deletions core/src/test/java/feast/core/service/SpecServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,11 @@

public class SpecServiceTest {

@Mock
private FeatureSetRepository featureSetRepository;
@Mock private FeatureSetRepository featureSetRepository;

@Mock
private StoreRepository storeRepository;
@Mock private StoreRepository storeRepository;

@Rule
public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ExpectedException expectedException = ExpectedException.none();

private SpecService specService;
private List<FeatureSet> featureSets;
Expand All @@ -102,11 +99,12 @@ public void setUp() {
Field f3f1 = new Field("f3", "f3f1", Enum.INT64);
Field f3f2 = new Field("f3", "f3f2", Enum.INT64);
Field f3e1 = new Field("f3", "f3e1", Enum.STRING);
FeatureSet featureSet3v1 = new FeatureSet(
"f3", 1, 100L, Arrays.asList(f3e1), Arrays.asList(f3f2, f3f1), defaultSource);
FeatureSet featureSet3v1 =
new FeatureSet(
"f3", 1, 100L, Arrays.asList(f3e1), Arrays.asList(f3f2, f3f1), defaultSource);

featureSets = Arrays
.asList(featureSet1v1, featureSet1v2, featureSet1v3, featureSet2v1, featureSet3v1);
featureSets =
Arrays.asList(featureSet1v1, featureSet1v2, featureSet1v3, featureSet2v1, featureSet3v1);
when(featureSetRepository.findAll()).thenReturn(featureSets);
when(featureSetRepository.findAllByOrderByNameAscVersionAsc()).thenReturn(featureSets);
when(featureSetRepository.findByName("f1")).thenReturn(featureSets.subList(0, 3));
Expand Down Expand Up @@ -347,28 +345,28 @@ public void applyFeatureSetShouldIncrementFeatureSetVersionIfAlreadyExists()
assertThat(applyFeatureSetResponse.getFeatureSet(), equalTo(expected));
}


@Test
public void applyFeatureSetShouldNotCreateFeatureSetIfFieldsUnordered()
throws InvalidProtocolBufferException {

Field f3f1 = new Field("f3", "f3f1", Enum.INT64);
Field f3f2 = new Field("f3", "f3f2", Enum.INT64);
Field f3e1 = new Field("f3", "f3e1", Enum.STRING);
FeatureSetProto.FeatureSetSpec incomingFeatureSet = (new FeatureSet(
"f3", 5, 100L, Arrays.asList(f3e1), Arrays.asList(f3f2, f3f1), defaultSource)).toProto();
FeatureSetProto.FeatureSetSpec incomingFeatureSet =
(new FeatureSet(
"f3", 5, 100L, Arrays.asList(f3e1), Arrays.asList(f3f2, f3f1), defaultSource))
.toProto();

FeatureSetSpec expected = incomingFeatureSet;
ApplyFeatureSetResponse applyFeatureSetResponse =
specService.applyFeatureSet(incomingFeatureSet);
assertThat(applyFeatureSetResponse.getStatus(), equalTo(Status.NO_CHANGE));
assertThat(applyFeatureSetResponse.getFeatureSet().getMaxAge(), equalTo(expected.getMaxAge()));
assertThat(applyFeatureSetResponse.getFeatureSet().getEntities(0),
equalTo(expected.getEntities(0)));
assertThat(
applyFeatureSetResponse.getFeatureSet().getEntities(0), equalTo(expected.getEntities(0)));
assertThat(applyFeatureSetResponse.getFeatureSet().getName(), equalTo(expected.getName()));
}


@Test
public void shouldUpdateStoreIfConfigChanges() throws InvalidProtocolBufferException {
when(storeRepository.findById("SERVING")).thenReturn(Optional.of(stores.get(0)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static feast.core.validators.Matchers.checkLowerSnakeCase;
import static feast.core.validators.Matchers.checkUpperSnakeCase;

import com.google.common.base.Strings;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
import feast.store.serving.redis.RedisCustomIO.RedisMutation;
import feast.types.FeatureRowProto.FeatureRow;
import feast.types.FieldProto.Field;
import feast.types.ValueProto.Value;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.beam.sdk.transforms.DoFn;
import org.slf4j.Logger;
Expand All @@ -55,12 +53,9 @@ private RedisKey getKey(FeatureRow featureRow) {
Builder redisKeyBuilder = RedisKey.newBuilder().setFeatureSet(featureRow.getFeatureSet());
for (Field field : featureRow.getFieldsList()) {
if (entityNames.contains(field.getName())) {
entityFields.putIfAbsent(field.getName(),
Field.newBuilder()
.setName(field.getName())
.setValue(field.getValue())
.build()
);
entityFields.putIfAbsent(
field.getName(),
Field.newBuilder().setName(field.getName()).setValue(field.getValue()).build());
}
}
for (String entityName : entityNames) {
Expand Down
Loading