Skip to content

Commit b58c8ae

Browse files
feat: Enable ingestion without timestamp by using current time
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
1 parent cda6f9c commit b58c8ae

11 files changed

Lines changed: 99 additions & 8 deletions

File tree

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,26 @@ print(training_df.head())
109109
```
110110

111111
### 6. Load feature values into your online store
112+
113+
**Option 1: Incremental materialization (recommended)**
112114
```commandline
113115
CURRENT_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S")
114116
feast materialize-incremental $CURRENT_TIME
115117
```
116118

119+
**Option 2: Full materialization with timestamps**
120+
```commandline
121+
CURRENT_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S")
122+
feast materialize 2021-04-12T00:00:00 $CURRENT_TIME
123+
```
124+
125+
**Option 3: Simple materialization without timestamps**
126+
```commandline
127+
feast materialize --disable-event-timestamp
128+
```
129+
130+
The `--disable-event-timestamp` flag allows you to materialize features using the current datetime without needing to specify start and end timestamps. This is useful for quick testing or when you want to materialize all available data up to now.
131+
117132
```commandline
118133
Materializing feature view driver_hourly_stats from 2021-04-14 to 2021-04-15 done!
119134
```

docs/getting-started/concepts/data-ingestion.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,17 @@ materialize_python = PythonOperator(
6464

6565
#### How to run this in the CLI
6666

67+
**With timestamps:**
6768
```bash
6869
CURRENT_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S")
6970
feast materialize-incremental $CURRENT_TIME
7071
```
7172

73+
**Simple materialization (uses current datetime):**
74+
```bash
75+
feast materialize --disable-event-timestamp
76+
```
77+
7278
#### How to run this on Airflow
7379

7480
```python

docs/getting-started/quickstart.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,13 +499,19 @@ print(training_df.head())
499499
We now serialize the latest values of features since the beginning of time to prepare for serving. Note, `materialize_incremental` serializes all new features since the last `materialize` call, or since the time provided minus the `ttl` timedelta. In this case, this will be `CURRENT_TIME - 1 day` (`ttl` was set on the `FeatureView` instances in [feature_repo/feature_repo/example_repo.py](feature_repo/feature_repo/example_repo.py)).
500500

501501
{% tabs %}
502-
{% tab title="Bash" %}
502+
{% tab title="Bash (with timestamp)" %}
503503
```bash
504504
CURRENT_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S")
505505

506506
feast materialize-incremental $CURRENT_TIME
507507
```
508508
{% endtab %}
509+
{% tab title="Bash (simple)" %}
510+
```bash
511+
# Alternative: Use current datetime without specifying timestamps
512+
feast materialize --disable-event-timestamp
513+
```
514+
{% endtab %}
509515
{% endtabs %}
510516

511517
{% tabs %}

docs/reference/feast-cli-commands.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,30 @@ feast init -t gcp my_feature_repo
152152

153153
## Materialize
154154

155-
Load data from feature views into the online store between two dates
155+
Load data from feature views into the online store.
156156

157+
**With timestamps:**
157158
```bash
158159
feast materialize 2020-01-01T00:00:00 2022-01-01T00:00:00
159160
```
160161

161-
Load data for specific feature views into the online store between two dates
162+
**Without timestamps (uses current datetime):**
163+
```bash
164+
feast materialize --disable-event-timestamp
165+
```
166+
167+
Load data for specific feature views:
162168

163169
```text
164170
feast materialize -v driver_hourly_stats 2020-01-01T00:00:00 2022-01-01T00:00:00
165171
```
166172

173+
```text
174+
feast materialize --disable-event-timestamp -v driver_hourly_stats
175+
```
176+
177+
The `--disable-event-timestamp` flag is useful for quick testing or when you want to materialize all available data up to the current time.
178+
167179
```text
168180
Materializing 1 feature views from 2020-01-01 to 2022-01-01
169181

infra/templates/README.md.jinja2

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,26 @@ print(training_df.head())
107107
```
108108

109109
### 6. Load feature values into your online store
110+
111+
**Option 1: Incremental materialization (recommended)**
110112
```commandline
111113
CURRENT_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S")
112114
feast materialize-incremental $CURRENT_TIME
113115
```
114116

117+
**Option 2: Full materialization with timestamps**
118+
```commandline
119+
CURRENT_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S")
120+
feast materialize 2021-04-12T00:00:00 $CURRENT_TIME
121+
```
122+
123+
**Option 3: Simple materialization without timestamps**
124+
```commandline
125+
feast materialize --disable-event-timestamp
126+
```
127+
128+
The `--disable-event-timestamp` flag allows you to materialize features using the current datetime without needing to specify start and end timestamps. This is useful for quick testing or when you want to materialize all available data up to now.
129+
115130
```commandline
116131
Materializing feature view driver_hourly_stats from 2021-04-14 to 2021-04-15 done!
117132
```

sdk/python/feast/cli/cli.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,17 +303,26 @@ def registry_dump_command(ctx: click.Context):
303303

304304

305305
@cli.command("materialize")
306-
@click.argument("start_ts")
307-
@click.argument("end_ts")
306+
@click.argument("start_ts", required=False)
307+
@click.argument("end_ts", required=False)
308308
@click.option(
309309
"--views",
310310
"-v",
311311
help="Feature views to materialize",
312312
multiple=True,
313313
)
314+
@click.option(
315+
"--disable-event-timestamp",
316+
is_flag=True,
317+
help="Use current datetime for materialization instead of requiring timestamps",
318+
)
314319
@click.pass_context
315320
def materialize_command(
316-
ctx: click.Context, start_ts: str, end_ts: str, views: List[str]
321+
ctx: click.Context,
322+
start_ts: Optional[str],
323+
end_ts: Optional[str],
324+
views: List[str],
325+
disable_event_timestamp: bool,
317326
):
318327
"""
319328
Run a (non-incremental) materialization job to ingest data into the online store. Feast
@@ -322,13 +331,32 @@ def materialize_command(
322331
Views will be materialized.
323332
324333
START_TS and END_TS should be in ISO 8601 format, e.g. '2021-07-16T19:20:01'
334+
335+
If --disable-event-timestamp is used, timestamps are not required and datetime.now() will be used.
325336
"""
326337
store = create_feature_store(ctx)
327338

339+
if disable_event_timestamp:
340+
if start_ts or end_ts:
341+
raise click.UsageError(
342+
"Cannot specify START_TS or END_TS when --disable-event-timestamp is used"
343+
)
344+
now = datetime.now()
345+
start_date = now
346+
end_date = now
347+
else:
348+
if not start_ts or not end_ts:
349+
raise click.UsageError(
350+
"START_TS and END_TS are required unless --disable-event-timestamp is used"
351+
)
352+
start_date = utils.make_tzaware(parser.parse(start_ts))
353+
end_date = utils.make_tzaware(parser.parse(end_ts))
354+
328355
store.materialize(
329356
feature_views=None if not views else views,
330-
start_date=utils.make_tzaware(parser.parse(start_ts)),
331-
end_date=utils.make_tzaware(parser.parse(end_ts)),
357+
start_date=start_date,
358+
end_date=end_date,
359+
disable_event_timestamp=disable_event_timestamp,
332360
)
333361

334362

sdk/python/feast/feature_store.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,7 @@ def materialize(
15421542
start_date: datetime,
15431543
end_date: datetime,
15441544
feature_views: Optional[List[str]] = None,
1545+
disable_event_timestamp: bool = False,
15451546
) -> None:
15461547
"""
15471548
Materialize data from the offline store into the online store.
@@ -1555,6 +1556,7 @@ def materialize(
15551556
end_date (datetime): End date for time range of data to materialize into the online store
15561557
feature_views (List[str]): Optional list of feature view names. If selected, will only run
15571558
materialization for the specified feature views.
1559+
disable_event_timestamp (bool): If True, uses current datetime for materialization instead of event timestamps
15581560
15591561
Examples:
15601562
Materialize all features into the online store over the interval
@@ -1609,6 +1611,7 @@ def tqdm_builder(length):
16091611
registry=self._registry,
16101612
project=self.project,
16111613
tqdm_builder=tqdm_builder,
1614+
disable_event_timestamp=disable_event_timestamp,
16121615
)
16131616

16141617
self._registry.apply_materialization(

sdk/python/feast/infra/common/materialization_job.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class MaterializationTask:
2222
end_time: datetime
2323
only_latest: bool = True
2424
tqdm_builder: Union[None, Callable[[int], tqdm]] = None
25+
disable_event_timestamp: bool = False
2526

2627

2728
class MaterializationJobStatus(enum.Enum):

sdk/python/feast/infra/passthrough_provider.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ def materialize_single_feature_view(
426426
registry: BaseRegistry,
427427
project: str,
428428
tqdm_builder: Callable[[int], tqdm],
429+
disable_event_timestamp: bool = False,
429430
) -> None:
430431
if isinstance(feature_view, OnDemandFeatureView):
431432
if not feature_view.write_to_online_store:
@@ -445,6 +446,7 @@ def materialize_single_feature_view(
445446
start_time=start_date,
446447
end_time=end_date,
447448
tqdm_builder=tqdm_builder,
449+
disable_event_timestamp=disable_event_timestamp,
448450
)
449451
jobs = self.batch_engine.materialize(registry, task)
450452
assert len(jobs) == 1

sdk/python/feast/infra/provider.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ def materialize_single_feature_view(
228228
registry: BaseRegistry,
229229
project: str,
230230
tqdm_builder: Callable[[int], tqdm],
231+
disable_event_timestamp: bool = False,
231232
) -> None:
232233
"""
233234
Writes latest feature values in the specified time range to the online store.
@@ -240,6 +241,7 @@ def materialize_single_feature_view(
240241
registry: The registry for the current feature store.
241242
project: Feast project to which the objects belong.
242243
tqdm_builder: A function to monitor the progress of materialization.
244+
disable_event_timestamp: If True, uses current datetime for materialization instead of event timestamps.
243245
"""
244246
pass
245247

0 commit comments

Comments
 (0)