GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: Add server async support flags at the [Online/Offline]Store impl level by robhowley · Pull Request #7 · robhowley/feast

feat: Add server async support flags at the [Online/Offline]Store impl level #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
robhowley wants to merge 3 commits into master from rh-async-check

Uh oh!

There was an error while loading. Please reload this page.

Closed

feat: Add server async support flags at the [Online/Offline]Store impl level #7

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
3 commits
Select commit Hold shift + click to select a range
9e13636
chore: Bump org.apache.avro:avro from 1.11.3 to 1.11.4 in /java/servi…
dependabot[bot] Oct 15, 2024
95fe8c2
chore: Updated tests to confirm behavior of inconsistent offline/onli…
franciscojavierarceo Oct 15, 2024
6d494d6
add async support flags on an opt in basis to off/online stores
robhowley Oct 16, 2024
File filter
Filter by extension


Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

2 changes: 1 addition & 1 deletion 2 java/serving/pom.xml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>1.11.3</version>
<version>1.11.4</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.arrow/arrow-java-root -->
Expand Down
106 changes: 64 additions & 42 deletions 106 sdk/python/feast/feature_server.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import time
import traceback
from contextlib import asynccontextmanager
from typing import List, Optional
from typing import Any, List, Optional

import pandas as pd
import psutil
Expand Down Expand Up @@ -68,6 +68,46 @@ class MaterializeIncrementalRequest(BaseModel):
feature_views: Optional[List[str]] = None


def _prepare_get_online_features_request(store, body) -> dict[str, Any]:
body = json.loads(body)
full_feature_names = body.get("full_feature_names", False)
entity_rows = body["entities"]
# Initialize parameters for FeatureStore.get_online_features(...) call
if "feature_service" in body:
feature_service = store.get_feature_service(
body["feature_service"], allow_cache=True
)
assert_permissions(
resource=feature_service, actions=[AuthzedAction.READ_ONLINE]
)
features = feature_service
else:
features = body["features"]
all_feature_views, all_on_demand_feature_views = (
utils._get_feature_views_to_use(
store.registry,
store.project,
features,
allow_cache=True,
hide_dummy_entity=False,
)
)
for feature_view in all_feature_views:
assert_permissions(
resource=feature_view, actions=[AuthzedAction.READ_ONLINE]
)
for od_feature_view in all_on_demand_feature_views:
assert_permissions(
resource=od_feature_view, actions=[AuthzedAction.READ_ONLINE]
)

return dict(
features=features,
entity_rows=entity_rows,
full_feature_names=full_feature_names,
)


def get_app(
store: "feast.FeatureStore",
registry_ttl_sec: int = DEFAULT_FEATURE_SERVER_REGISTRY_TTL,
Expand Down Expand Up @@ -108,53 +148,35 @@ async def lifespan(app: FastAPI):
async def get_body(request: Request):
return await request.body()

@app.post(
_post_get_online_features = app.post(
"/get-online-features",
dependencies=[Depends(inject_user_details)],
)
def get_online_features(body=Depends(get_body)):
body = json.loads(body)
full_feature_names = body.get("full_feature_names", False)
entity_rows = body["entities"]
# Initialize parameters for FeatureStore.get_online_features(...) call
if "feature_service" in body:
feature_service = store.get_feature_service(
body["feature_service"], allow_cache=True

async_supported = store._get_provider().async_supported
if async_supported.online.read:

@_post_get_online_features
async def get_online_features(body=Depends(get_body)):
Comment thread
Comment on lines +156 to +160

@robhowley robhowley Oct 15, 2024

Copy link
Copy Markdown
Owner Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build our endpoints based upon the SupportedAsyncMethods values

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
response = await store.get_online_features_async(
**_prepare_get_online_features_request(store, body)
)
assert_permissions(
resource=feature_service, actions=[AuthzedAction.READ_ONLINE]
# Convert the Protobuf object to JSON and return it
return MessageToDict(
response.proto, preserving_proto_field_name=True, float_precision=18
)
features = feature_service
else:
features = body["features"]
all_feature_views, all_on_demand_feature_views = (
utils._get_feature_views_to_use(
store.registry,
store.project,
features,
allow_cache=True,
hide_dummy_entity=False,
)
else:

@_post_get_online_features
def get_online_features(body=Depends(get_body)):
response_proto = store.get_online_features(
**_prepare_get_online_features_request(store, body)
).proto

# Convert the Protobuf object to JSON and return it
return MessageToDict(
response_proto, preserving_proto_field_name=True, float_precision=18
)
for feature_view in all_feature_views:
assert_permissions(
resource=feature_view, actions=[AuthzedAction.READ_ONLINE]
)
for od_feature_view in all_on_demand_feature_views:
assert_permissions(
resource=od_feature_view, actions=[AuthzedAction.READ_ONLINE]
)

response_proto = store.get_online_features(
features=features,
entity_rows=entity_rows,
full_feature_names=full_feature_names,
).proto

# Convert the Protobuf object to JSON and return it
return MessageToDict(
response_proto, preserving_proto_field_name=True, float_precision=18
)

@app.post("/push", dependencies=[Depends(inject_user_details)])
def push(body=Depends(get_body)):
Expand Down
5 changes: 5 additions & 0 deletions 5 sdk/python/feast/infra/offline_stores/offline_store.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from feast.feature_logging import LoggingConfig, LoggingSource
from feast.feature_view import FeatureView
from feast.infra.registry.base_registry import BaseRegistry
from feast.infra.supported_async_methods import SupportedAsyncMethods
from feast.on_demand_feature_view import OnDemandFeatureView
from feast.repo_config import RepoConfig
from feast.saved_dataset import SavedDatasetStorage
Expand Down Expand Up @@ -223,6 +224,10 @@ class OfflineStore(ABC):
the SnowflakeOfflineStore can handle SnowflakeSources but not FileSources.
"""

@property
def async_supported(self) -> SupportedAsyncMethods:
return SupportedAsyncMethods()

@staticmethod
def pull_latest_from_table_or_query(
config: RepoConfig,
Expand Down
5 changes: 5 additions & 0 deletions 5 sdk/python/feast/infra/online_stores/dynamodb.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from feast.infra.infra_object import DYNAMODB_INFRA_OBJECT_CLASS_TYPE, InfraObject
from feast.infra.online_stores.helpers import compute_entity_id
from feast.infra.online_stores.online_store import OnlineStore
from feast.infra.supported_async_methods import SupportedAsyncMethods
from feast.protos.feast.core.DynamoDBTable_pb2 import (
DynamoDBTable as DynamoDBTableProto,
)
Expand Down Expand Up @@ -88,6 +89,10 @@ class DynamoDBOnlineStore(OnlineStore):
_dynamodb_resource = None
_aioboto_session = None

@property
def async_supported(self) -> SupportedAsyncMethods:
return SupportedAsyncMethods(read=True)
Comment thread
Comment on lines +92 to +94

@robhowley robhowley Oct 15, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Owner Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default impl of this property has

online:
    read: False
    write: False
offline:
    read: False
    write: False

override and mark supported operations as they're added. dynamo support async reads so just set that value.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

def update(
self,
config: RepoConfig,
Expand Down
5 changes: 5 additions & 0 deletions 5 sdk/python/feast/infra/online_stores/online_store.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from feast.feature_view import FeatureView
from feast.infra.infra_object import InfraObject
from feast.infra.registry.base_registry import BaseRegistry
from feast.infra.supported_async_methods import SupportedAsyncMethods
from feast.online_response import OnlineResponse
from feast.protos.feast.core.Registry_pb2 import Registry as RegistryProto
from feast.protos.feast.types.EntityKey_pb2 import EntityKey as EntityKeyProto
Expand All @@ -36,6 +37,10 @@ class OnlineStore(ABC):
The interface that Feast uses to interact with the storage system that handles online features.
"""

@property
def async_supported(self) -> SupportedAsyncMethods:
return SupportedAsyncMethods()

@abstractmethod
def online_write_batch(
self,
Expand Down
8 changes: 8 additions & 0 deletions 8 sdk/python/feast/infra/passthrough_provider.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from feast.infra.online_stores.helpers import get_online_store_from_config
from feast.infra.provider import Provider
from feast.infra.registry.base_registry import BaseRegistry
from feast.infra.supported_async_methods import ProviderAsyncMethods
from feast.online_response import OnlineResponse
from feast.protos.feast.core.Registry_pb2 import Registry as RegistryProto
from feast.protos.feast.types.EntityKey_pb2 import EntityKey as EntityKeyProto
Expand Down Expand Up @@ -79,6 +80,13 @@ def offline_store(self):
)
return self._offline_store

@property
def async_supported(self) -> ProviderAsyncMethods:
return ProviderAsyncMethods(
online=self.online_store.async_supported,
offline=self.offline_store.async_supported,
)

@property
def batch_engine(self) -> BatchMaterializationEngine:
if self._batch_engine:
Expand Down
5 changes: 5 additions & 0 deletions 5 sdk/python/feast/infra/provider.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from feast.infra.infra_object import Infra
from feast.infra.offline_stores.offline_store import RetrievalJob
from feast.infra.registry.base_registry import BaseRegistry
from feast.infra.supported_async_methods import ProviderAsyncMethods
from feast.on_demand_feature_view import OnDemandFeatureView
from feast.online_response import OnlineResponse
from feast.protos.feast.core.Registry_pb2 import Registry as RegistryProto
Expand Down Expand Up @@ -55,6 +56,10 @@ class Provider(ABC):
def __init__(self, config: RepoConfig):
pass

@property
def async_supported(self) -> ProviderAsyncMethods:
return ProviderAsyncMethods()

@abstractmethod
def update_infra(
self,
Expand Down
11 changes: 11 additions & 0 deletions 11 sdk/python/feast/infra/supported_async_methods.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from pydantic import BaseModel, Field


class SupportedAsyncMethods(BaseModel):
read: bool = Field(default=False)
write: bool = Field(default=False)


class ProviderAsyncMethods(BaseModel):
online: SupportedAsyncMethods = Field(default_factory=SupportedAsyncMethods)
offline: SupportedAsyncMethods = Field(default_factory=SupportedAsyncMethods)
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.