Skip to content

Commit 95d2cc2

Browse files
patelchaitanyntkathole
authored andcommitted
feat: Allow unlimited sequences in OnlineConfig
Sequence mode no longer requires max_length. Leaving max_length or max_age unset (proto 0) now means no limit of that kind, so a sequence with neither set keeps every event. Signed-off-by: Chaitany Patel <patelchaitany93@gmail.com>
1 parent 591c1ff commit 95d2cc2

5 files changed

Lines changed: 18 additions & 13 deletions

File tree

‎docs/getting-started/concepts/feature-view.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Feature views are used during
6262

6363
## Online retention configuration
6464

65-
`OnlineConfig` declares whether a feature view uses the current latest-value model or a bounded sequence of historical values per entity. Sequence mode requires append writes and a positive maximum length. An optional maximum age adds a second retention limit.
65+
`OnlineConfig` declares whether a feature view uses the current latest-value model or a sequence of historical values per entity. Sequence mode requires append writes. A maximum length and a maximum age are optional retention limits; leave both unset to keep an unlimited sequence.
6666

6767
```python
6868
from datetime import timedelta

‎protos/feast/core/FeatureView.proto‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ message OnlineConfig {
7070

7171
Mode mode = 1;
7272

73-
// Maximum number of events retained per entity. 0 means unset.
73+
// Maximum number of events retained per entity. 0 means no length limit.
7474
int32 max_length = 2;
7575

76-
// Maximum event age in whole seconds. 0 means unset.
76+
// Maximum event age in whole seconds. 0 means no age limit.
7777
int64 max_age_seconds = 3;
7878

7979
enum WriteMode {

‎sdk/python/feast/online_config.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class OnlineConfig:
2727
Sequence mode is a declarative contract in this foundation release. Online
2828
stores must add explicit sequence support before these settings affect data
2929
storage or retrieval.
30+
31+
In sequence mode, ``max_length`` and ``max_age`` are optional retention
32+
limits. Leaving either unset (``None``) means no limit of that kind, so a
33+
sequence with neither set is unlimited.
3034
"""
3135

3236
mode: str = "latest"
@@ -73,10 +77,6 @@ def validate(self) -> None:
7377
raise ValueError(
7478
"OnlineConfig mode='sequence' requires write_mode='append'."
7579
)
76-
if self.max_length is None:
77-
raise ValueError(
78-
"OnlineConfig mode='sequence' requires max_length to be set."
79-
)
8080
else:
8181
if self.write_mode != "overwrite":
8282
raise ValueError(

‎sdk/python/feast/protos/feast/core/FeatureView_pb2.pyi‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ class OnlineConfig(google.protobuf.message.Message):
147147
WRITE_MODE_FIELD_NUMBER: builtins.int
148148
mode: global___OnlineConfig.Mode.ValueType
149149
max_length: builtins.int
150-
"""Maximum number of events retained per entity. 0 means unset."""
150+
"""Maximum number of events retained per entity. 0 means no length limit."""
151151
max_age_seconds: builtins.int
152-
"""Maximum event age in whole seconds. 0 means unset."""
152+
"""Maximum event age in whole seconds. 0 means no age limit."""
153153
write_mode: global___OnlineConfig.WriteMode.ValueType
154154
def __init__(
155155
self,

‎sdk/python/tests/unit/test_online_config.py‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ def test_online_config_proto_round_trip() -> None:
3030
assert OnlineConfig.from_proto(proto) == config
3131

3232

33+
def test_online_config_sequence_without_limits_is_unlimited() -> None:
34+
config = OnlineConfig(mode="sequence", write_mode="append")
35+
36+
proto = config.to_proto()
37+
assert proto.max_length == 0
38+
assert proto.max_age_seconds == 0
39+
assert OnlineConfig.from_proto(proto) == config
40+
41+
3342
@pytest.mark.parametrize(
3443
("kwargs", "message"),
3544
[
@@ -44,10 +53,6 @@ def test_online_config_proto_round_trip() -> None:
4453
{"mode": "sequence", "max_length": 10},
4554
"mode='sequence' requires write_mode='append'",
4655
),
47-
(
48-
{"mode": "sequence", "write_mode": "append"},
49-
"mode='sequence' requires max_length to be set",
50-
),
5156
],
5257
)
5358
def test_online_config_validation(kwargs: dict, message: str) -> None:

0 commit comments

Comments
 (0)