Skip to content

Commit bb676f2

Browse files
authored
Update Feast Serving documentation with ways to run and debug locally (#2272)
Signed-off-by: Danny Chiao <danny@tecton.ai>
1 parent ffe82fd commit bb676f2

File tree

1 file changed

+88
-77
lines changed

1 file changed

+88
-77
lines changed

java/serving/README.md

Lines changed: 88 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,112 @@
1-
### Getting Started Guide for Feast Serving Developers
1+
## Getting Started Guide for Feast Serving Developers
22

3-
Pre-requisites:
3+
### Pre-requisites:
44

55
- [Maven](https://maven.apache.org/install.html) build tool version 3.6.x
6-
- A running Feast Core instance
7-
- A running Store instance e.g. local Redis Store instance
6+
- A Feast feature repo (e.g. https://github.com/feast-dev/feast-demo)
7+
- A running Store instance e.g. local Redis instance with `redis-server`
88

9-
From the Feast project root directory, run the following Maven command to start Feast Serving gRPC service running on port 6566 locally:
9+
### Building and running Feast Serving locally:
10+
From the Feast GitHub root, run:
1011

11-
```bash
12-
# Assumptions:
13-
# - Local Feast Core is running on localhost:6565
14-
# Uses configuration from serving/src/main/resources/application.yml
15-
mvn -pl serving spring-boot:run -Dspring-boot.run.arguments=\
16-
--feast.core-host=localhost,\
17-
--feast.core-port=6565
18-
```
12+
1. `mvn -f java/pom.xml install -Dmaven.test.skip=true`
13+
2. Package an executable jar for serving: `mvn -f java/serving/pom.xml package -Dmaven.test.skip=true`
14+
3. Make a file called `application-override.yaml` that specifies your Feast repo project and registry path:
15+
1. Note if you have a remote registry, you can specify that too (e.g. `gs://...`)
16+
```yaml
17+
feast:
18+
project: "feast_demo"
19+
registry: "/Users/[your username]/GitHub/feast-demo/feature_repo/data/registry.db"
20+
```
21+
4. Run the jar with dependencies that was built from Maven (note the version might vary):
22+
```
23+
java \
24+
-Xms1g \
25+
-Xmx4g \
26+
-jar java/serving/target/feast-serving-0.17.1-SNAPSHOT-jar-with-dependencies.jar \
27+
classpath:/application.yml,file:./application-override.yaml
28+
```
29+
5. Now you have a Feast Serving gRPC service running on port 6566 locally!
1930

31+
### Running test queries
2032
If you have [grpc_cli](https://github.com/grpc/grpc/blob/master/doc/command_line_tool.md) installed, you can check that Feast Serving is running
2133
```
2234
grpc_cli ls localhost:6566
23-
grpc_cli call localhost:6566 GetFeastServingVersion ''
24-
grpc_cli call localhost:6566 GetFeastServingType ''
2535
```
2636

37+
An example of fetching features
2738
```bash
28-
grpc_cli call localhost:6565 ApplyFeatureSet '
29-
feature_set {
30-
name: "driver"
31-
entities {
32-
name: "driver_id"
33-
value_type: STRING
34-
}
35-
features {
36-
name: "city"
37-
value_type: STRING
38-
}
39-
features {
40-
name: "booking_completed_count"
41-
value_type: INT64
42-
}
43-
source {
44-
type: KAFKA
45-
kafka_source_config {
46-
bootstrap_servers: "localhost:9092"
39+
grpc_cli call localhost:6566 GetOnlineFeatures '
40+
features {
41+
val: "driver_hourly_stats:conv_rate"
42+
val: "driver_hourly_stats:acc_rate"
43+
}
44+
entities {
45+
key: "driver_id"
46+
value {
47+
val {
48+
int64_val: 1001
49+
}
50+
val {
51+
int64_val: 1002
4752
}
4853
}
4954
}
5055
'
51-
52-
grpc_cli call localhost:6565 GetFeatureSets '
53-
filter {
54-
feature_set_name: "driver"
56+
```
57+
Example output:
58+
```
59+
connecting to localhost:6566
60+
metadata {
61+
feature_names {
62+
val: "driver_hourly_stats:conv_rate"
63+
val: "driver_hourly_stats:acc_rate"
64+
}
5565
}
56-
'
57-
58-
grpc_cli call localhost:6566 GetBatchFeatures '
59-
feature_sets {
60-
name: "driver"
61-
feature_names: "booking_completed_count"
62-
max_age {
63-
seconds: 86400
66+
results {
67+
values {
68+
float_val: 0.812357187
69+
}
70+
values {
71+
float_val: 0.379484832
72+
}
73+
statuses: PRESENT
74+
statuses: PRESENT
75+
event_timestamps {
76+
seconds: 1631725200
77+
}
78+
event_timestamps {
79+
seconds: 1631725200
6480
}
6581
}
66-
entity_dataset {
67-
entity_names: "driver_id"
68-
entity_dataset_rows {
69-
entity_timestamp {
70-
seconds: 1569873954
71-
}
82+
results {
83+
values {
84+
float_val: 0.840873241
85+
}
86+
values {
87+
float_val: 0.151376978
88+
}
89+
statuses: PRESENT
90+
statuses: PRESENT
91+
event_timestamps {
92+
seconds: 1631725200
93+
}
94+
event_timestamps {
95+
seconds: 1631725200
7296
}
7397
}
74-
'
75-
```
76-
98+
Rpc succeeded with OK status
7799
```
78-
python3 <<EOF
79-
import pandas as pd
80-
import fastavro
81100

82-
with open("/tmp/000000000000.avro", "rb") as f:
83-
reader = fastavro.reader(f)
84-
records = [r for r in reader]
85-
df = pd.DataFrame.from_records(records)
86-
print(df.columns)
87-
print(df.shape)
88-
print(df.head(5))
89-
EOF
90-
```
91-
#### Working with Feast 0.10+
92-
Feast serving supports reading feature values materialized into Redis by feast 0.10+. To configure this, feast-serving
93-
needs to be able to read the registry file for the project.
94-
The location of the registry file can be specified in the `application.yml` like so:
95-
```yaml
96-
feast:
97-
registry: "src/test/resources/docker-compose/feast10/registry.db"
101+
### Debugging Feast Serving
102+
You can debug this like any other Java executable. Swap the java command above with:
98103
```
99-
100-
This changes the behaviour of feast-serving to look up feature view definitions and specifications from the registry file instead
101-
of the core service.
104+
java \
105+
-Xdebug \
106+
-Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y \
107+
-Xms1g \
108+
-Xmx4g \
109+
-jar java/serving/target/feast-serving-0.17.1-SNAPSHOT-jar-with-dependencies.jar \
110+
classpath:/application.yml,file:./application-override.yaml
111+
```
112+
Now you can attach e.g. a Remote debugger in IntelliJ to port 5005 to debug / make breakpoints.

0 commit comments

Comments
 (0)