Skip to content
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.

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

Update feature views with commit hash included #75

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 5 additions & 4 deletions domino_data/_feature_store/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Feature Store module."""
from typing import List, Optional, cast
from typing import Any, List, Optional, cast

import json
import os
Expand Down Expand Up @@ -44,16 +44,17 @@ def __attrs_post_init__(self):
),
)

def post_feature_views(self, feature_views: List[FeatureViewRequest]) -> None:
def post_feature_views(self, feature_views: List[FeatureViewRequest], commit_id: str) -> None:
"""Insert or update feature views.

Args:
feature_views: an array of feature views to be inserted or updated.
commit_id: the commit hash the feature store is to be synced with

Raises:
ServerException: if update fails
"""
request = UpsertFeatureViewsRequest(feature_views=feature_views)
request = UpsertFeatureViewsRequest(feature_views=feature_views, git_commit_hash=commit_id)
response = post_featureview.sync_detailed(
client=self.client,
json_body=request,
Expand Down Expand Up @@ -103,7 +104,7 @@ def unlock(self, unlock_request: UnlockFeatureStoreRequest) -> bool:
return False if response.parsed is None else response.parsed


def _raise_response_exn(response: Response, msg: str):
def _raise_response_exn(response: Response[Any], msg: str) -> None:
try:
response_json = json.loads(response.content.decode("utf8"))
server_msg = response_json.get("errors")
Expand Down
11 changes: 5 additions & 6 deletions domino_data/_feature_store/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
LockFeatureStoreRequest,
UnlockFeatureStoreRequest,
)
from feature_store_api_client.types import UNSET

from ..logging import logger
from .client import FeatureStoreClient
Expand Down Expand Up @@ -110,15 +111,13 @@ def update_feature_views(commit_id: str, repo_path: str) -> None:
for x, y in zip(fv.entities, fv.entity_columns)
],
features=[Feature(name=f.name, dtype=str(f.dtype)) for f in fv.features],
ttl=None if fv.ttl is None else int(fv.ttl.total_seconds() * 1000),
ttl=UNSET if fv.ttl is None else int(fv.ttl.total_seconds() * 1000),
tags=FeatureViewRequestTags.from_dict(fv.tags),
)
request_input.append(feature_v)

# TODO update the API to include the commit id so that feature views
# and commit id can be updated to domino in one call
client = FeatureStoreClient()
client.post_feature_views(request_input)
client.post_feature_views(request_input, commit_id)
logger.info("Feature Views successfully synced.")


Expand Down Expand Up @@ -176,8 +175,8 @@ def feature_store_sync(
repo_path_str: str,
branch_name: str,
max_retries: int,
skip_source_validation=False,
):
skip_source_validation: bool = False,
) -> None:
"""run feature store syncing
Args:
feature_store_id: the feature store domino id
Expand Down
2 changes: 1 addition & 1 deletion feature_store_api_client/api/default/post_lock.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion feature_store_api_client/api/default/post_unlock.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions openapi/featurestore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,11 @@ components:
type: array
items:
$ref: '#/components/schemas/FeatureViewRequest'
gitCommitHash:
type: string
required:
- featureViews
- gitCommitHash
FeatureViewRequest:
type: object
properties:
Expand Down
Loading