Skip to content

Commit 578003f

Browse files
author
zhilingc
committed
Rebase with master
2 parents def65b0 + 9c0ef21 commit 578003f

15 files changed

Lines changed: 457 additions & 89 deletions

‎CONTRIBUTING.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Contributing Guide
2+
3+
## Code reviews
4+
5+
All submissions, including submissions by project members, require review. We use GitHub pull
6+
requests for this purpose. Consult GitHub Help for more information on using pull requests.
7+
8+
## Code conventions
9+
10+
### Java
11+
12+
We conform to the [java google style guide](https://google.github.io/styleguide/javaguide.html)
13+
14+
If using intellij please import the code styles:
15+
https://github.com/google/styleguide/blob/gh-pages/intellij-java-google-style.xml
16+
17+
### Go
18+
19+
Make sure you apply `go fmt`.
20+
21+
### JavaScript

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ VERSION_FILE=VERSION
22
FEAST_VERSION=`cat $(VERSION_FILE)`
33

44
test:
5-
echo testing not implemented
5+
mvn test
66

77
build-deps:
88
$(MAKE) -C protos gen-go

‎ingestion/pom.xml‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@
3030

3131
<properties>
3232
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
33-
<org.apache.beam.version>2.5.0</org.apache.beam.version>
33+
<org.apache.beam.version>2.9.0</org.apache.beam.version>
3434
<com.google.cloud.version>1.35.0</com.google.cloud.version>
35-
<grpcVersion>1.2.0</grpcVersion>
35+
<com.google.httpclient.version>1.27.0</com.google.httpclient.version>
36+
<grpcVersion>1.13.1</grpcVersion>
3637
<guice.version>4.1.0</guice.version>
3738
<spring.kafka.version>2.2.2.RELEASE</spring.kafka.version>
3839
</properties>
@@ -173,19 +174,19 @@
173174
<dependency>
174175
<groupId>com.google.http-client</groupId>
175176
<artifactId>google-http-client</artifactId>
176-
<version>1.23.0</version>
177+
<version>${com.google.httpclient.version}</version>
177178
</dependency>
178179
<dependency>
179180
<groupId>com.google.http-client</groupId>
180181
<artifactId>google-http-client-gson</artifactId>
181-
<version>1.23.0</version>
182+
<version>${com.google.httpclient.version}</version>
182183
</dependency>
183184

184185

185186
<dependency>
186187
<groupId>com.google.protobuf</groupId>
187188
<artifactId>protobuf-java</artifactId>
188-
<version>3.4.0</version>
189+
<version>${protobufVersion}</version>
189190
</dependency>
190191

191192

@@ -204,7 +205,7 @@
204205
<dependency>
205206
<groupId>com.google.cloud.bigtable</groupId>
206207
<artifactId>bigtable-hbase-beam</artifactId>
207-
<version>1.6.0</version>
208+
<version>1.8.0</version>
208209
<exclusions>
209210
<exclusion>
210211
<groupId>org.slf4j</groupId>

‎ingestion/src/main/java/feast/ingestion/deserializer/FeatureRowDeserializer.java‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Copyright 2018 The Feast Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
118
package feast.ingestion.deserializer;
219

320
import com.google.protobuf.InvalidProtocolBufferException;

‎ingestion/src/main/java/feast/ingestion/deserializer/FeatureRowKeyDeserializer.java‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Copyright 2018 The Feast Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
118
package feast.ingestion.deserializer;
219

320
import com.google.protobuf.InvalidProtocolBufferException;

‎ingestion/src/main/java/feast/ingestion/transform/SplitOutputByStore.java‎

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@
1919

2020
import com.google.common.base.Preconditions;
2121
import com.google.common.collect.Lists;
22+
import feast.ingestion.exceptions.ErrorsHandler;
23+
import feast.ingestion.model.Specs;
24+
import feast.ingestion.transform.FeatureIO.Write;
25+
import feast.ingestion.transform.SplitFeatures.MultiOutputSplit;
26+
import feast.ingestion.values.PFeatureRows;
27+
import feast.specs.FeatureSpecProto.FeatureSpec;
28+
import feast.specs.StorageSpecProto.StorageSpec;
29+
import feast.storage.FeatureStore;
30+
import feast.storage.noop.NoOpIO;
31+
import feast.types.FeatureRowExtendedProto.Attempt;
32+
import feast.types.FeatureRowExtendedProto.Error;
33+
import feast.types.FeatureRowExtendedProto.FeatureRowExtended;
2234
import java.util.Collection;
2335
import java.util.HashMap;
2436
import java.util.List;
@@ -35,29 +47,19 @@
3547
import org.apache.beam.sdk.values.PCollectionList;
3648
import org.apache.beam.sdk.values.PCollectionTuple;
3749
import org.apache.beam.sdk.values.TupleTag;
38-
import feast.ingestion.exceptions.ErrorsHandler;
39-
import feast.ingestion.model.Specs;
40-
import feast.ingestion.transform.FeatureIO.Write;
41-
import feast.ingestion.transform.SplitFeatures.MultiOutputSplit;
42-
import feast.ingestion.values.PFeatureRows;
43-
import feast.specs.FeatureSpecProto.FeatureSpec;
44-
import feast.specs.StorageSpecProto.StorageSpec;
45-
import feast.storage.FeatureStore;
46-
import feast.storage.noop.NoOpIO;
47-
import feast.types.FeatureRowExtendedProto.Attempt;
48-
import feast.types.FeatureRowExtendedProto.Error;
49-
import feast.types.FeatureRowExtendedProto.FeatureRowExtended;
5050

5151
@AllArgsConstructor
5252
@Slf4j
5353
public class SplitOutputByStore extends PTransform<PFeatureRows, PFeatureRows> {
54+
5455
private Collection<? extends FeatureStore> stores;
5556
private SerializableFunction<FeatureSpec, String> selector;
5657
private Specs specs;
5758

5859
@Override
5960
public PFeatureRows expand(PFeatureRows input) {
6061
Map<String, Write> transforms = getFeatureStoreTransforms();
62+
transforms.put("", new NoOpIO.Write());
6163
Set<String> keys = transforms.keySet();
6264
Preconditions.checkArgument(transforms.size() > 0, "no write transforms found");
6365

@@ -102,6 +104,7 @@ private Map<String, Write> getFeatureStoreTransforms() {
102104

103105
@AllArgsConstructor
104106
public static class WriteTags extends PTransform<PCollectionTuple, PFeatureRows> {
107+
105108
private Map<TupleTag<FeatureRowExtended>, Write> transforms;
106109
private TupleTag<FeatureRowExtended> mainTag;
107110

@@ -120,9 +123,7 @@ public PFeatureRows expand(PCollectionTuple input) {
120123
}
121124

122125
String message =
123-
"FeatureRow with output tag.no matching storage, these feature's "
124-
+ "specs may be specifying a store which was unknown when "
125-
+ "ingestion started as they somehow passed validation. ";
126+
"FeatureRows have no matching write transform, these rows should not have passed validation.";
126127
PCollection<FeatureRowExtended> errors =
127128
input.get(mainTag).apply(ParDo.of(new WithErrors(getName(), message)));
128129

@@ -131,8 +132,11 @@ public PFeatureRows expand(PCollectionTuple input) {
131132
}
132133
}
133134

134-
/** Sets the last attempt error for all rows with a given exception */
135+
/**
136+
* Sets the last attempt error for all rows with a given exception
137+
*/
135138
public static class WithErrors extends DoFn<FeatureRowExtended, FeatureRowExtended> {
139+
136140
private Error error;
137141

138142
public WithErrors(Error error) {

‎ingestion/src/test/java/feast/ingestion/ImportJobCSVTest.java‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@
6767
@Slf4j
6868
public class ImportJobCSVTest {
6969

70-
@Rule public TemporaryFolder folder = new TemporaryFolder();
70+
@Rule
71+
public TemporaryFolder folder = new TemporaryFolder();
7172

72-
@Rule public TestPipeline testPipeline = TestPipeline.create();
73+
@Rule
74+
public TestPipeline testPipeline = TestPipeline.create();
7375

7476
public ImportSpec initImportSpec(ImportSpec importSpec, String dataFile) {
7577
return importSpec.toBuilder().putOptions("path", dataFile).build();
@@ -125,7 +127,7 @@ public void testImportCSV() throws IOException {
125127

126128
PCollection<FeatureRowExtended> writtenToWarehouse =
127129
PCollectionList.of(
128-
WarehouseStoreService.get(MockWarehouseStore.class).getWrite().getInputs())
130+
WarehouseStoreService.get(MockWarehouseStore.class).getWrite().getInputs())
129131
.apply("flatten warehouse input", Flatten.pCollections());
130132

131133
PCollection<FeatureRowExtended> writtenToErrors =

‎ingestion/src/test/java/feast/ingestion/deserializer/KafkaFeatureRowDeserializerTest.java‎

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1+
/*
2+
* Copyright 2018 The Feast Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
118
package feast.ingestion.deserializer;
219

320
import com.google.protobuf.MessageLite;
421
import feast.types.FeatureRowProto.FeatureRow;
522
import java.util.Map;
6-
import java.util.UUID;
723
import java.util.concurrent.BlockingQueue;
824
import java.util.concurrent.ExecutionException;
925
import java.util.concurrent.LinkedBlockingQueue;
@@ -13,9 +29,11 @@
1329
import org.apache.kafka.common.serialization.ByteArraySerializer;
1430
import org.apache.kafka.common.serialization.Deserializer;
1531
import org.junit.Assert;
32+
import org.junit.ClassRule;
1633
import org.junit.Test;
1734
import org.junit.runner.RunWith;
1835
import org.springframework.beans.factory.annotation.Autowired;
36+
import org.springframework.boot.test.context.SpringBootTest;
1937
import org.springframework.context.annotation.Bean;
2038
import org.springframework.context.annotation.Configuration;
2139
import org.springframework.kafka.core.ConsumerFactory;
@@ -28,31 +46,29 @@
2846
import org.springframework.kafka.listener.MessageListener;
2947
import org.springframework.kafka.listener.MessageListenerContainer;
3048
import org.springframework.kafka.support.SendResult;
31-
import org.springframework.kafka.test.EmbeddedKafkaBroker;
32-
import org.springframework.kafka.test.context.EmbeddedKafka;
49+
import org.springframework.kafka.test.rule.EmbeddedKafkaRule;
3350
import org.springframework.kafka.test.utils.ContainerTestUtils;
3451
import org.springframework.kafka.test.utils.KafkaTestUtils;
52+
import org.springframework.test.annotation.DirtiesContext;
3553
import org.springframework.test.context.junit4.SpringRunner;
3654
import org.springframework.util.concurrent.ListenableFuture;
3755

3856
@RunWith(SpringRunner.class)
39-
@EmbeddedKafka(controlledShutdown = true)
57+
@SpringBootTest
58+
@DirtiesContext
4059
public class KafkaFeatureRowDeserializerTest {
4160

42-
@Autowired private EmbeddedKafkaBroker embeddedKafka;
61+
private static final String topic = "TEST_TOPIC";
62+
63+
@ClassRule public static EmbeddedKafkaRule embeddedKafka = new EmbeddedKafkaRule(1, true, topic);
4364
@Autowired private KafkaTemplate<byte[], byte[]> template;
4465

4566
private <MessageType extends MessageLite> void deserialize(MessageType input) {
46-
// generate a random UUID to create a unique topic and consumer group id for each test
47-
String uuid = UUID.randomUUID().toString();
48-
String topic = "topic-" + uuid;
49-
50-
embeddedKafka.addTopics(topic);
5167

5268
Deserializer deserializer = new FeatureRowDeserializer();
5369

5470
Map<String, Object> consumerProps =
55-
KafkaTestUtils.consumerProps(uuid, Boolean.FALSE.toString(), embeddedKafka);
71+
KafkaTestUtils.consumerProps("testGroup", "false", embeddedKafka.getEmbeddedKafka());
5672
ConsumerFactory<FeatureRow, FeatureRow> consumerFactory =
5773
new DefaultKafkaConsumerFactory<>(consumerProps, deserializer, deserializer);
5874

@@ -63,7 +79,8 @@ private <MessageType extends MessageLite> void deserialize(MessageType input) {
6379
MessageListenerContainer container =
6480
new KafkaMessageListenerContainer<>(consumerFactory, containerProps);
6581
container.start();
66-
ContainerTestUtils.waitForAssignment(container, embeddedKafka.getPartitionsPerTopic());
82+
ContainerTestUtils.waitForAssignment(
83+
container, embeddedKafka.getEmbeddedKafka().getPartitionsPerTopic());
6784

6885
byte[] data = input.toByteArray();
6986
ProducerRecord<byte[], byte[]> producerRecord = new ProducerRecord<>(topic, data, data);
@@ -99,12 +116,10 @@ public void deserializeFeatureRowProto() {
99116

100117
@Configuration
101118
static class ContextConfiguration {
102-
103-
@Autowired private EmbeddedKafkaBroker embeddedKafka;
104-
105119
@Bean
106120
ProducerFactory<byte[], byte[]> producerFactory() {
107-
Map<String, Object> producerProps = KafkaTestUtils.producerProps(embeddedKafka);
121+
Map<String, Object> producerProps =
122+
KafkaTestUtils.producerProps(embeddedKafka.getEmbeddedKafka());
108123

109124
return new DefaultKafkaProducerFactory<>(
110125
producerProps, new ByteArraySerializer(), new ByteArraySerializer());

0 commit comments

Comments
 (0)