Skip to content

Commit 0fca98e

Browse files
author
zhilingc
committed
Cleanup and added some more informative comments
1 parent 8ff9cde commit 0fca98e

6 files changed

Lines changed: 56 additions & 17 deletions

File tree

protos/feast/core/CoreService.proto

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,47 @@ service CoreService {
3030
rpc GetFeastCoreVersion (GetFeastCoreVersionRequest) returns (GetFeastCoreVersionResponse);
3131

3232
// Retrieve feature set details given a filter.
33-
// Returns all featureSets matching that filter.
33+
//
34+
// Returns all feature sets matching that filter. If none are found,
35+
// an empty list will be returned.
36+
// If no filter is provided in the request, the response will contain all the feature
37+
// sets currently stored in the registry.
3438
rpc GetFeatureSets (GetFeatureSetsRequest) returns (GetFeatureSetsResponse);
3539

3640
// Retrieve store details given a filter.
37-
// Returns all stores matching that filter.
41+
//
42+
// Returns all stores matching that filter. If none are found, an empty list will be returned.
43+
// If no filter is provided in the request, the response will contain all the stores currently
44+
// stored in the registry.
3845
rpc GetStores (GetStoresRequest) returns (GetStoresResponse);
3946

40-
// Idempotent creation of feature set. Will not create a new feature set if schema does not change.
47+
// Create or update and existing feature set.
48+
//
49+
// This function is idempotent - it will not create a new feature set if schema does not change.
50+
// If an existing feature set is updated, core will advance the version number, which will be
51+
// returned in response.
4152
rpc ApplyFeatureSet (ApplyFeatureSetRequest) returns (ApplyFeatureSetResponse);
4253

43-
// Updates core with the configuration of the store. If the changes are valid,
44-
// core will return the given store configuration in response.
54+
// Updates core with the configuration of the store.
55+
//
56+
// If the changes are valid, core will return the given store configuration in response, and
57+
// start or update the necessary feature population jobs for the updated store.
4558
rpc UpdateStore(UpdateStoreRequest) returns (UpdateStoreResponse);
4659
}
4760

4861
// Retrieves details for all versions of a specific feature set
4962
message GetFeatureSetsRequest {
5063
message Filter {
64+
// Name of the desired feature set. Valid regex strings are allowed.
65+
// e.g.
66+
// - .* can be used to match all feature sets
67+
// - my-project-.* can be used to match all features prefixed by "my-project"
5168
string feature_set_name = 1;
69+
// Version of the desired feature set. Either a number or valid expression can be provided.
70+
// e.g.
71+
// - 1 will match version 1 exactly
72+
// - >=1 will match all versions greater or equal to 1
73+
// - <10 will match all versions less than 10
5274
string feature_set_version = 2;
5375
}
5476

@@ -61,6 +83,7 @@ message GetFeatureSetsResponse {
6183

6284
message GetStoresRequest {
6385
message Filter {
86+
// Name of desired store. Regex is not supported in this query.
6487
string name = 1;
6588
}
6689

serving/sample_redis_config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ redis_config:
44
host: localhost
55
port: 6379
66
subscriptions:
7-
- name: .*
8-
version: ">0"
7+
- name: .*
8+
version: ">0"

serving/src/main/java/feast/serving/controller/HealthServiceController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package feast.serving.controller;
22

3+
import feast.core.StoreProto.Store;
34
import feast.serving.ServingAPIProto.GetFeastServingTypeRequest;
45
import feast.serving.service.CachedSpecService;
56
import feast.serving.service.ServingService;
@@ -32,7 +33,7 @@ public void check(
3233
// Implement similary for batch service.
3334

3435
try {
35-
specService.getStore();
36+
Store store = specService.getStore();
3637
servingService.getFeastServingType(GetFeastServingTypeRequest.getDefaultInstance());
3738
responseObserver.onNext(
3839
HealthCheckResponse.newBuilder().setStatus(ServingStatus.SERVING).build());

serving/src/main/java/feast/serving/service/CachedSpecService.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
2525
import java.util.List;
2626
import java.util.Map;
2727
import java.util.concurrent.ExecutionException;
28+
import lombok.extern.slf4j.Slf4j;
2829

2930
/**
30-
* SpecStorage implementation with built-in in-memory cache.
31+
* In-memory cache of specs.
3132
*/
33+
@Slf4j
3234
public class CachedSpecService {
3335

3436
private static final int MAX_SPEC_COUNT = 1000;
@@ -53,16 +55,28 @@ public CachedSpecService(CoreSpecService coreService, Path configPath) {
5355
CacheBuilder.newBuilder().maximumSize(MAX_SPEC_COUNT).build(featureSetSpecCacheLoader);
5456
}
5557

58+
/**
59+
* Get the current store configuration.
60+
*
61+
* @return StoreProto.Store store configuration for this serving instance
62+
*/
5663
public Store getStore() {
5764
return this.store;
5865
}
5966

67+
/**
68+
* Get a single FeatureSetSpec matching the given name and version.
69+
*
70+
* @param name of the featureSet
71+
* @param version to retrieve
72+
* @return FeatureSetSpec of the matching FeatureSet
73+
*/
6074
public FeatureSetSpec getFeatureSet(String name, int version) {
6175
String id = String.format("%s:%d", name, version);
6276
try {
6377
return featureSetSpecCache.get(id);
6478
} catch (InvalidCacheLoadException e) {
65-
// if not found, default to core
79+
// if not found, try to retrieve from core
6680
GetFeatureSetsRequest request = GetFeatureSetsRequest.newBuilder()
6781
.setFilter(Filter.newBuilder()
6882
.setFeatureSetName(name)
@@ -83,7 +97,8 @@ public FeatureSetSpec getFeatureSet(String name, int version) {
8397
}
8498

8599
/**
86-
* Preload all specs into the cache.
100+
* Reload the store configuration from the given config path, then retrieve the necessary specs
101+
* from core to preload the cache.
87102
*/
88103
public void populateCache() {
89104
this.store = updateStore(readConfig(configPath));
@@ -110,7 +125,8 @@ private Map<String, FeatureSetSpec> getFeatureSetSpecMap() {
110125
featureSetSpec);
111126
}
112127
} catch (StatusRuntimeException e) {
113-
continue;
128+
throw new RuntimeException(
129+
String.format("Unable to retrieve specs matching subscription %s", subscription), e);
114130
}
115131
}
116132
return featureSetSpecs;

serving/src/main/java/feast/serving/service/CoreSpecService.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
import io.grpc.ManagedChannelBuilder;
1010
import lombok.extern.slf4j.Slf4j;
1111

12-
// TODO: Health check and recovery for this CoreSpecService, i.e.
13-
// if client fails to connect to Feast Core GRPC service, what to do or report?
14-
// By default, managed channel should do auto-retry etc, but just to double check.
15-
12+
/**
13+
* Client for spec retrieval from core.
14+
*/
1615
@Slf4j
1716
public class CoreSpecService {
1817
private final CoreServiceGrpc.CoreServiceBlockingStub blockingStub;

serving/src/main/resources/application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ feast:
1919

2020
store:
2121
# Path containing the store configuration for this serving store.
22-
config-path: ${FEAST_STORE_CONFIG_PATH:/etc/feast/sample_redis_config.yml}
22+
config-path: ${FEAST_STORE_CONFIG_PATH:./sample_redis_config.yml}
2323
# If serving redis, the redis pool max size
2424
redis-pool-max-size: 128
2525
# If serving redis, the redis pool max idle conns

0 commit comments

Comments
 (0)