Skip to content

Commit 994c0cb

Browse files
committed
1 parent 08cd59d commit 994c0cb

5 files changed

Lines changed: 39 additions & 36 deletions

File tree

‎docs/reference/feature-servers/python-feature-server.md‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,9 @@ Enable batching in your `feature_store.yaml`:
215215
```yaml
216216
feature_server:
217217
type: local
218-
offline_write_batching:
219-
enabled: true
220-
batch_size: 1000
221-
batch_interval_seconds: 10
218+
offline_push_batching_enabled: true
219+
offline_push_batching_batch_size: 1000
220+
offline_push_batching_batch_interval_seconds: 10
222221
```
223222
224223
### Materializing features

‎docs/reference/feature-store-yaml.md‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ An example configuration:
3636
```yaml
3737
feature_server:
3838
type: local
39-
offline_write_batching: # Enables batching of offline writes processed by /push. Online writes are unaffected.
40-
enabled: true
41-
batch_size: 100 # Maximum number of buffered rows before writing to the offline store.
42-
batch_interval_seconds: 5 # Maximum time rows may remain buffered before a forced flush.
39+
offline_push_batching_enabled: true # Enables batching of offline writes processed by /push. Online writes are unaffected.
40+
offline_push_batching_batch_size: 100 # Maximum number of buffered rows before writing to the offline store.
41+
offline_push_batching_batch_interval_seconds: 5 # Maximum time rows may remain buffered before a forced flush.
4342
```
4443

4544
## Providers

‎sdk/python/feast/feature_server.py‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from contextlib import asynccontextmanager
2323
from datetime import datetime
2424
from importlib import resources as importlib_resources
25+
from types import SimpleNamespace
2526
from typing import Any, DefaultDict, Dict, List, NamedTuple, Optional, Union
2627

2728
import pandas as pd
@@ -212,13 +213,28 @@ def get_app(
212213
fs_cfg = getattr(store.config, "feature_server", None)
213214
batching_cfg = None
214215
if fs_cfg is not None:
215-
batching_cfg = getattr(fs_cfg, "offline_write_batching", None)
216+
enabled = getattr(fs_cfg, "offline_push_batching_enabled", None)
217+
batch_size = getattr(fs_cfg, "offline_push_batching_batch_size", None)
218+
batch_interval_seconds = getattr(
219+
fs_cfg, "offline_push_batching_batch_interval_seconds", None
220+
)
221+
222+
if (
223+
enabled is not None
224+
or batch_size is not None
225+
or batch_interval_seconds is not None
226+
):
227+
batching_cfg = SimpleNamespace(
228+
enabled=bool(enabled) if enabled is not None else False,
229+
batch_size=batch_size if batch_size is not None else 100,
230+
batch_interval_seconds=batch_interval_seconds
231+
if batch_interval_seconds is not None
232+
else 1,
233+
)
216234

217235
offline_batcher: Optional[OfflineWriteBatcher] = None
218236
enabled = getattr(batching_cfg, "enabled", False)
219237
if batching_cfg is not None and isinstance(enabled, bool) and enabled is True:
220-
offline_batcher = OfflineWriteBatcher(store=store, cfg=batching_cfg)
221-
222238
offline_batcher = OfflineWriteBatcher(store=store, cfg=batching_cfg)
223239
logger.debug("Offline write batching is ENABLED")
224240
else:

‎sdk/python/feast/infra/feature_servers/base_config.py‎

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,6 @@
1717

1818
from feast.repo_config import FeastConfigBaseModel
1919

20-
class OfflinePushBatchingConfig(FeastConfigBaseModel):
21-
""" Optional configuration for batching offline writes via the `/push` endpoint.
22-
23-
Write attempts via `/push` to the offline store are buffered
24-
in memory and flushed either when either one of the batch size threshold or the batch interval duration is reached. """
25-
26-
enabled: StrictBool = False
27-
"""Whether or not to batch writes to offline store via push endpoint."""
28-
29-
batch_size: StrictInt = 100
30-
"""The maximum batch size for offline writes. """
31-
32-
batch_interval_seconds: StrictInt = 1
33-
"""The batch interval between offline writes. """
3420

3521
class FeatureLoggingConfig(FeastConfigBaseModel):
3622
enabled: StrictBool = False
@@ -60,5 +46,11 @@ class BaseFeatureServerConfig(FeastConfigBaseModel):
6046
feature_logging: Optional[FeatureLoggingConfig] = None
6147
""" Feature logging configuration """
6248

63-
offline_push_batching: Optional[OfflinePushBatchingConfig] = None
64-
""" Offline write batching configuration for the HTTP /push endpoint """
49+
offline_push_batching_enabled: Optional[StrictBool] = None
50+
"""Whether to batch writes to the offline store via the `/push` endpoint."""
51+
52+
offline_push_batching_batch_size: Optional[StrictInt] = None
53+
"""The maximum batch size for offline writes via `/push`."""
54+
55+
offline_push_batching_batch_interval_seconds: Optional[StrictInt] = None
56+
"""The batch interval between offline writes via `/push`."""

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def _enable_offline_batching_config(
229229
fs, enabled: bool = True, batch_size: int = 1, batch_interval_seconds: int = 60
230230
):
231231
"""
232-
Attach a minimal feature_server.offline_write_batching config
232+
Attach a minimal feature_server.offline_push_batching config
233233
to a mocked FeatureStore.
234234
"""
235235
if not hasattr(fs, "config") or fs.config is None:
@@ -238,14 +238,11 @@ def _enable_offline_batching_config(
238238
if not hasattr(fs.config, "feature_server") or fs.config.feature_server is None:
239239
fs.config.feature_server = SimpleNamespace()
240240

241-
if enabled:
242-
fs.config.feature_server.offline_write_batching = SimpleNamespace(
243-
enabled=True,
244-
batch_size=batch_size,
245-
batch_interval_seconds=batch_interval_seconds,
246-
)
247-
else:
248-
fs.config.feature_server.offline_write_batching = None
241+
fs.config.feature_server.offline_push_batching_enabled = enabled
242+
fs.config.feature_server.offline_push_batching_batch_size = batch_size
243+
fs.config.feature_server.offline_push_batching_batch_interval_seconds = (
244+
batch_interval_seconds
245+
)
249246

250247

251248
def push_body_many(push_mode=PushMode.ONLINE, count: int = 2, id_start: int = 100):

0 commit comments

Comments
 (0)