Visitar URL original
feat: Add registry list feature views by updated since (#6092) by nquinn408 · Pull Request #6093 · feast-dev/feast · GitHub
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
Feedback and fixing lint-python issues
Signed-off-by: Nick Quinn <nicholas_quinn@apple.com>
  • Loading branch information
nickquinn408 committed Jun 28, 2026
commit 098d2bc42709a958b762648b4717394a0694e1e8
6 changes: 1 addition & 5 deletions sdk/python/feast/infra/registry/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,7 @@ def list_all_feature_views(
updated_since_proto = None
if updated_since is not None:
ts = Timestamp()
ts.FromDatetime(
updated_since.replace(tzinfo=None)
if updated_since.tzinfo
else updated_since
)
ts.FromDatetime(updated_since)
updated_since_proto = ts
request = RegistryServer_pb2.ListAllFeatureViewsRequest(
project=project,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,12 @@ def test_list_all_feature_views_updated_since(test_registry: BaseRegistry):
test_registry.teardown()
Comment thread
nquinn408 marked this conversation as resolved.


@pytest.mark.integration
@pytest.mark.parametrize(
"test_registry",
all_fixtures,
)
def test_apply_data_source(test_registry):
# Create Feature Views
batch_source = FileSource(
name="test_source",
Expand Down
85 changes: 85 additions & 0 deletions sdk/python/tests/unit/infra/registry/test_remote_registry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Copyright 2024 The Feast Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from datetime import datetime, timedelta, timezone
from unittest.mock import MagicMock, patch

import pytest
from google.protobuf.timestamp_pb2 import Timestamp

from feast.infra.registry.remote import RemoteRegistry
from feast.protos.feast.registry import RegistryServer_pb2


@pytest.fixture
def remote_registry():
with patch.object(RemoteRegistry, "__init__", return_value=None):
registry = RemoteRegistry.__new__(RemoteRegistry)
registry.stub = MagicMock()
registry.stub.ListAllFeatureViews.return_value = (
RegistryServer_pb2.ListAllFeatureViewsResponse(feature_views=[])
)
yield registry


def _captured_updated_since(remote_registry) -> Timestamp:
"""Return the updated_since Timestamp from the last ListAllFeatureViews call."""
call_args = remote_registry.stub.ListAllFeatureViews.call_args
request: RegistryServer_pb2.ListAllFeatureViewsRequest = call_args[0][0]
return request.updated_since


def test_updated_since_utc_aware(remote_registry):
"""A UTC-aware datetime is encoded to the correct UTC epoch seconds."""
dt = datetime(2024, 6, 1, 17, 0, 0, tzinfo=timezone.utc)
remote_registry.list_all_feature_views("project", updated_since=dt)

ts = _captured_updated_since(remote_registry)
assert ts.seconds == int(dt.timestamp())


def test_updated_since_non_utc_aware(remote_registry):
"""A non-UTC tz-aware datetime is converted to the correct UTC epoch, not treated as UTC."""
est = timezone(timedelta(hours=-5))
# 2024-06-01 12:00 EST == 2024-06-01 17:00 UTC
dt_est = datetime(2024, 6, 1, 12, 0, 0, tzinfo=est)
dt_utc = datetime(2024, 6, 1, 17, 0, 0, tzinfo=timezone.utc)

remote_registry.list_all_feature_views("project", updated_since=dt_est)

ts = _captured_updated_since(remote_registry)
assert ts.seconds == int(dt_utc.timestamp()), (
"Non-UTC datetime must be converted to UTC before encoding, "
"not have its tzinfo stripped (which would misinterpret 12:00 EST as 12:00 UTC)"
)


def test_updated_since_naive_datetime(remote_registry):
"""A naive datetime is treated as UTC by protobuf's FromDatetime."""
dt_naive = datetime(2024, 6, 1, 17, 0, 0)
dt_utc = datetime(2024, 6, 1, 17, 0, 0, tzinfo=timezone.utc)
remote_registry.list_all_feature_views("project", updated_since=dt_naive)

ts = _captured_updated_since(remote_registry)
assert ts.seconds == int(dt_utc.timestamp())


def test_updated_since_none(remote_registry):
"""When updated_since is None, the field is not set in the request."""
remote_registry.list_all_feature_views("project", updated_since=None)

request: RegistryServer_pb2.ListAllFeatureViewsRequest = (
remote_registry.stub.ListAllFeatureViews.call_args[0][0]
)
assert not request.HasField("updated_since")