Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Add type annotations and formatting fixes for performance optimi…
…zations
  • Loading branch information
franciscojavierarceo committed Jan 30, 2026
commit 2dcfcc158bb6263b5fa1e138e09e090476e1f70c
29 changes: 16 additions & 13 deletions sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ class FeatureStore:

config: RepoConfig
repo_path: Path
_registry: BaseRegistry
_provider: Provider
_registry: Optional[BaseRegistry]
_provider: Optional[Provider]
_openlineage_emitter: Optional[Any] = None
_feature_service_cache: Dict[str, List[str]]

def __init__(
self,
Expand Down Expand Up @@ -207,8 +208,12 @@ def registry(self) -> BaseRegistry:
if self._registry is None:
self._registry = self._create_registry()
# Add feature service cache to registry for performance optimization
if not hasattr(self._registry, '_feature_service_cache'):
self._registry._feature_service_cache = self._feature_service_cache
if not hasattr(self._registry, "_feature_service_cache"):
setattr(
self._registry,
"_feature_service_cache",
self._feature_service_cache,
)
return self._registry

def _create_registry(self) -> BaseRegistry:
Expand All @@ -219,9 +224,7 @@ def _create_registry(self) -> BaseRegistry:
elif registry_config.registry_type == "snowflake.registry":
from feast.infra.registry.snowflake import SnowflakeRegistry

return SnowflakeRegistry(
registry_config, self.config.project, None
)
return SnowflakeRegistry(registry_config, self.config.project, None)
elif registry_config and registry_config.registry_type == "remote":
from feast.infra.registry.remote import RemoteRegistry

Expand Down Expand Up @@ -848,9 +851,7 @@ def plan(

# Compute the desired difference between the current objects in the registry and
# the desired repo state.
registry_diff = diff_between(
self.registry, self.project, desired_repo_contents
)
registry_diff = diff_between(self.registry, self.project, desired_repo_contents)

if progress_ctx:
progress_ctx.update_phase_progress("Computing infrastructure diff")
Expand All @@ -860,7 +861,7 @@ def plan(
self.registry.refresh(project=self.project)
current_infra_proto = self.registry.get_infra(self.project).to_proto()
desired_registry_proto = desired_repo_contents.to_registry_proto()
new_infra = self._provider.plan_infra(self.config, desired_registry_proto)
new_infra = self.provider.plan_infra(self.config, desired_registry_proto)
new_infra_proto = new_infra.to_proto()
infra_diff = diff_infra_protos(
current_infra_proto, new_infra_proto, project=self.project
Expand Down Expand Up @@ -1307,7 +1308,9 @@ def get_historical_features(
if entity_df is None and end_date is None:
end_date = datetime.now()

_feature_refs = utils._get_features(self.registry, self.project, features, allow_cache=True)
_feature_refs = utils._get_features(
self.registry, self.project, features, allow_cache=True
)
(
all_feature_views,
all_on_demand_feature_views,
Expand Down Expand Up @@ -2853,7 +2856,7 @@ def serve(

def get_feature_server_endpoint(self) -> Optional[str]:
"""Returns endpoint for the feature server, if it exists."""
return self._provider.get_feature_server_endpoint()
return self.provider.get_feature_server_endpoint()

def serve_ui(
self,
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/feast/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ def _get_features(
cache_key = f"{_features.name}:{project}:{hash(tuple(str(fv) for fv in _features.feature_view_projections))}"

# Check cache first if caching is enabled and available
if allow_cache and hasattr(registry, '_feature_service_cache'):
if allow_cache and hasattr(registry, "_feature_service_cache"):
if cache_key in registry._feature_service_cache:
return registry._feature_service_cache[cache_key]

Expand All @@ -1133,7 +1133,7 @@ def _get_features(
)

# Cache the result if caching is enabled and available
if allow_cache and hasattr(registry, '_feature_service_cache'):
if allow_cache and hasattr(registry, "_feature_service_cache"):
registry._feature_service_cache[cache_key] = _feature_refs
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
else:
assert isinstance(_features, list)
Expand Down
Loading