Skip to content

Commit 1209d3a

Browse files
committed
Add support for on demand transforms using the Python FTS
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
1 parent e622a88 commit 1209d3a

File tree

10 files changed

+550
-6
lines changed

10 files changed

+550
-6
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "deps/feast"]
22
path = deps/feast
33
url = https://github.com/feast-dev/feast
4-
branch = v0.9-branch
4+
branch = master

common/src/main/java/feast/common/models/FeatureV2.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,16 @@ public static String getFeatureStringRef(FeatureReferenceV2 featureReference) {
3434
}
3535
return ref;
3636
}
37+
38+
/**
39+
* Accepts a feature reference as a string and returns the base feature name. For example, given
40+
* "driver_hourly_stats:conv_rate", "conv_rate" would be returned.
41+
*
42+
* @param featureReference {String}
43+
* @return Base feature name of the feature reference
44+
*/
45+
public static String getFeatureName(String featureReference) {
46+
String[] tokens = featureReference.split(":", 2);
47+
return tokens[tokens.length - 1];
48+
}
3749
}

pom.xml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,38 @@
269269
<version>${grpc.version}</version>
270270
<scope>test</scope>
271271
</dependency>
272-
272+
273+
<!-- https://mvnrepository.com/artifact/org.apache.arrow/arrow-java-root -->
274+
<dependency>
275+
<groupId>org.apache.arrow</groupId>
276+
<artifactId>arrow-java-root</artifactId>
277+
<version>5.0.0</version>
278+
<type>pom</type>
279+
</dependency>
280+
281+
<!-- https://mvnrepository.com/artifact/org.apache.arrow/arrow-vector -->
282+
<dependency>
283+
<groupId>org.apache.arrow</groupId>
284+
<artifactId>arrow-vector</artifactId>
285+
<version>5.0.0</version>
286+
</dependency>
287+
288+
<!-- https://mvnrepository.com/artifact/org.apache.arrow/arrow-memory -->
289+
<dependency>
290+
<groupId>org.apache.arrow</groupId>
291+
<artifactId>arrow-memory</artifactId>
292+
<version>5.0.0</version>
293+
<type>pom</type>
294+
</dependency>
295+
296+
<!-- https://mvnrepository.com/artifact/org.apache.arrow/arrow-memory-netty -->
297+
<dependency>
298+
<groupId>org.apache.arrow</groupId>
299+
<artifactId>arrow-memory-netty</artifactId>
300+
<version>5.0.0</version>
301+
<scope>runtime</scope>
302+
</dependency>
303+
273304
<!-- HTTP/REST -->
274305
<dependency>
275306
<groupId>io.swagger</groupId>

serving/pom.xml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,37 @@
269269
<version>1.10.2</version>
270270
</dependency>
271271

272+
<!-- https://mvnrepository.com/artifact/org.apache.arrow/arrow-java-root -->
273+
<dependency>
274+
<groupId>org.apache.arrow</groupId>
275+
<artifactId>arrow-java-root</artifactId>
276+
<version>5.0.0</version>
277+
<type>pom</type>
278+
</dependency>
279+
280+
<!-- https://mvnrepository.com/artifact/org.apache.arrow/arrow-vector -->
281+
<dependency>
282+
<groupId>org.apache.arrow</groupId>
283+
<artifactId>arrow-vector</artifactId>
284+
<version>5.0.0</version>
285+
</dependency>
286+
287+
<!-- https://mvnrepository.com/artifact/org.apache.arrow/arrow-memory -->
288+
<dependency>
289+
<groupId>org.apache.arrow</groupId>
290+
<artifactId>arrow-memory</artifactId>
291+
<version>5.0.0</version>
292+
<type>pom</type>
293+
</dependency>
294+
295+
<!-- https://mvnrepository.com/artifact/org.apache.arrow/arrow-memory-netty -->
296+
<dependency>
297+
<groupId>org.apache.arrow</groupId>
298+
<artifactId>arrow-memory-netty</artifactId>
299+
<version>5.0.0</version>
300+
<scope>runtime</scope>
301+
</dependency>
302+
272303
<!-- Utilities -->
273304
<dependency>
274305
<groupId>com.fasterxml.jackson.dataformat</groupId>

serving/src/main/java/feast/serving/registry/LocalRegistryRepo.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import feast.proto.core.FeatureProto;
2020
import feast.proto.core.FeatureViewProto;
21+
import feast.proto.core.OnDemandFeatureViewProto;
2122
import feast.proto.core.RegistryProto;
2223
import feast.proto.serving.ServingAPIProto;
2324
import feast.serving.exception.SpecRetrievalException;
@@ -75,4 +76,43 @@ public FeatureProto.FeatureSpecV2 getFeatureSpec(
7576
"Unable to find feature with name: %s in feature view: %s",
7677
featureReference.getName(), featureReference.getFeatureTable()));
7778
}
79+
80+
@Override
81+
public OnDemandFeatureViewProto.OnDemandFeatureViewSpec getOnDemandFeatureViewSpec(
82+
String projectName, ServingAPIProto.FeatureReferenceV2 featureReference) {
83+
final RegistryProto.Registry registry = this.getRegistry();
84+
for (final OnDemandFeatureViewProto.OnDemandFeatureView onDemandFeatureView :
85+
registry.getOnDemandFeatureViewsList()) {
86+
if (onDemandFeatureView.getSpec().getName().equals(featureReference.getFeatureTable())) {
87+
return onDemandFeatureView.getSpec();
88+
}
89+
}
90+
throw new SpecRetrievalException(
91+
String.format(
92+
"Unable to find on demand feature view with name: %s",
93+
featureReference.getFeatureTable()));
94+
}
95+
96+
@Override
97+
public boolean isBatchFeatureReference(ServingAPIProto.FeatureReferenceV2 featureReference) {
98+
final RegistryProto.Registry registry = this.getRegistry();
99+
for (final FeatureViewProto.FeatureView featureView : registry.getFeatureViewsList()) {
100+
if (featureView.getSpec().getName().equals(featureReference.getFeatureTable())) {
101+
return true;
102+
}
103+
}
104+
return false;
105+
}
106+
107+
@Override
108+
public boolean isOnDemandFeatureReference(ServingAPIProto.FeatureReferenceV2 featureReference) {
109+
final RegistryProto.Registry registry = this.getRegistry();
110+
for (final OnDemandFeatureViewProto.OnDemandFeatureView onDemandFeatureView :
111+
registry.getOnDemandFeatureViewsList()) {
112+
if (onDemandFeatureView.getSpec().getName().equals(featureReference.getFeatureTable())) {
113+
return true;
114+
}
115+
}
116+
return false;
117+
}
78118
}

serving/src/main/java/feast/serving/registry/RegistryRepository.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import feast.proto.core.FeatureProto;
2020
import feast.proto.core.FeatureViewProto;
21+
import feast.proto.core.OnDemandFeatureViewProto;
2122
import feast.proto.core.RegistryProto;
2223
import feast.proto.serving.ServingAPIProto;
2324

@@ -33,4 +34,11 @@ FeatureViewProto.FeatureViewSpec getFeatureViewSpec(
3334

3435
FeatureProto.FeatureSpecV2 getFeatureSpec(
3536
String projectName, ServingAPIProto.FeatureReferenceV2 featureReference);
37+
38+
OnDemandFeatureViewProto.OnDemandFeatureViewSpec getOnDemandFeatureViewSpec(
39+
String projectName, ServingAPIProto.FeatureReferenceV2 featureReference);
40+
41+
boolean isBatchFeatureReference(ServingAPIProto.FeatureReferenceV2 featureReference);
42+
43+
boolean isOnDemandFeatureReference(ServingAPIProto.FeatureReferenceV2 featureReference);
3644
}

0 commit comments

Comments
 (0)