MCPcopy Index your code
hub / github.com/feast-dev/feast / get_historical_features

Method get_historical_features

sdk/python/feast/offline_server.py:428–482  ·  view source on GitHub ↗
(self, command: dict, key: Optional[str] = None)

Source from the content-addressed store, hash-verified

426 assert "full_feature_names" in command, "full_feature_names is mandatory"
427
428 def get_historical_features(self, command: dict, key: Optional[str] = None):
429 self._validate_get_historical_features_parameters(command, key)
430 entity_df = None
431 if key:
432 # Extract parameters from the internal flights dictionary
433 entity_df_value = self.flights[key]
434 entity_df = pa.Table.to_pandas(entity_df_value)
435 # Check if this is a mock/empty table (contains only 'key' column)
436 if len(entity_df.columns) == 1 and "key" in entity_df.columns:
437 entity_df = None
438
439 # If the client sent a SQL string, use it directly
440 if entity_df is None and "entity_df_sql" in command:
441 entity_df = command["entity_df_sql"]
442
443 feature_view_names = command["feature_view_names"]
444 name_aliases = command["name_aliases"]
445 feature_refs = command["feature_refs"]
446 project = command["project"]
447 full_feature_names = command["full_feature_names"]
448
449 feature_views = self.list_feature_views_by_name(
450 feature_view_names=feature_view_names,
451 name_aliases=name_aliases,
452 project=project,
453 )
454
455 for feature_view in feature_views:
456 assert_permissions(
457 resource=feature_view, actions=[AuthzedAction.READ_OFFLINE]
458 )
459
460 # Extract and deserialize start_date/end_date if present
461 kwargs = {}
462 if "start_date" in command and command["start_date"] is not None:
463 kwargs["start_date"] = utils.make_tzaware(
464 datetime.fromisoformat(command["start_date"])
465 )
466 if "end_date" in command and command["end_date"] is not None:
467 kwargs["end_date"] = utils.make_tzaware(
468 datetime.fromisoformat(command["end_date"])
469 )
470
471 retJob = self.offline_store.get_historical_features(
472 config=self.store.config,
473 feature_views=feature_views,
474 feature_refs=feature_refs,
475 entity_df=entity_df,
476 registry=self.store.registry,
477 project=project,
478 full_feature_names=full_feature_names,
479 **kwargs,
480 )
481
482 return retJob
483
484 def _validate_persist_parameters(self, command: dict):
485 assert "retrieve_func" in command, "retrieve_func is mandatory"

Callers 2

do_getMethod · 0.95
persistMethod · 0.95

Calls 4

assert_permissionsFunction · 0.90
to_pandasMethod · 0.45

Tested by

no test coverage detected