Materialize data from the offline store into the online store. This method loads feature data in the specified interval from either the specified feature views, or all feature views if none are specified, into the online store where it is available for online servin
(
self,
start_date: datetime,
end_date: datetime,
feature_views: Optional[List[str]] = None,
disable_event_timestamp: bool = False,
full_feature_names: bool = False,
version: Optional[str] = None,
)
| 2284 | raise |
| 2285 | |
| 2286 | def materialize( |
| 2287 | self, |
| 2288 | start_date: datetime, |
| 2289 | end_date: datetime, |
| 2290 | feature_views: Optional[List[str]] = None, |
| 2291 | disable_event_timestamp: bool = False, |
| 2292 | full_feature_names: bool = False, |
| 2293 | version: Optional[str] = None, |
| 2294 | ) -> None: |
| 2295 | """ |
| 2296 | Materialize data from the offline store into the online store. |
| 2297 | |
| 2298 | This method loads feature data in the specified interval from either |
| 2299 | the specified feature views, or all feature views if none are specified, |
| 2300 | into the online store where it is available for online serving. |
| 2301 | |
| 2302 | Args: |
| 2303 | start_date (datetime): Start date for time range of data to materialize into the online store |
| 2304 | end_date (datetime): End date for time range of data to materialize into the online store |
| 2305 | feature_views (List[str]): Optional list of feature view names. If selected, will only run |
| 2306 | materialization for the specified feature views. |
| 2307 | disable_event_timestamp (bool): If True, materializes all available data using current datetime as event timestamp instead of source event timestamps |
| 2308 | full_feature_names (bool): If True, feature names will be prefixed with the corresponding |
| 2309 | feature view name. |
| 2310 | version (str): Optional version to materialize (e.g., 'v2'). Requires feature_views |
| 2311 | with exactly one entry and enable_online_feature_view_versioning to be enabled. |
| 2312 | |
| 2313 | Examples: |
| 2314 | Materialize all features into the online store over the interval |
| 2315 | from 3 hours ago to 10 minutes ago. |
| 2316 | >>> from feast import FeatureStore, RepoConfig |
| 2317 | >>> from datetime import datetime, timedelta |
| 2318 | >>> fs = FeatureStore(repo_path="project/feature_repo") |
| 2319 | >>> fs.materialize( |
| 2320 | ... start_date=_utc_now() - timedelta(hours=3), end_date=_utc_now() - timedelta(minutes=10) |
| 2321 | ... ) |
| 2322 | Materializing... |
| 2323 | <BLANKLINE> |
| 2324 | ... |
| 2325 | """ |
| 2326 | if utils.make_tzaware(start_date) > utils.make_tzaware(end_date): |
| 2327 | raise ValueError( |
| 2328 | f"The given start_date {start_date} is greater than the given end_date {end_date}." |
| 2329 | ) |
| 2330 | |
| 2331 | parsed_version = self._validate_materialize_version(version, feature_views) |
| 2332 | feature_views_to_materialize = self._get_feature_views_to_materialize( |
| 2333 | feature_views, version=parsed_version |
| 2334 | ) |
| 2335 | _print_materialization_log( |
| 2336 | start_date, |
| 2337 | end_date, |
| 2338 | len(feature_views_to_materialize), |
| 2339 | self.config.online_store.type, |
| 2340 | ) |
| 2341 | |
| 2342 | # Emit OpenLineage START event |
| 2343 | ol_run_id = self._emit_openlineage_materialize_start( |