Skip to content

Commit b20d2f6

Browse files
author
saket3395
committed
fix: feast apply ignores ttl updates when new ttl is None or timedelta(0)
Fixes feast-dev#6703. Registry._update_metadata_fields() routes ttl changes on re-apply through a truthiness check: if (... and updated_fv.ttl): None and timedelta(0) are both the documented way to express "no ttl", and both are falsy, so re-applying a FeatureView/LabelView with ttl cleared silently kept the old finite ttl -- feast apply reported the update but nothing changed in the registry. Removing that outer truthy gate isn't sufficient by itself: for the FeatureView branch, get_ttl_duration() returns Python None when self.ttl is None, and the existing inner check if ttl_duration: existing_proto.spec.ttl.CopyFrom(ttl_duration) would still silently skip CopyFrom in that case, leaving the stale ttl in place. Fixed both by explicitly writing an empty Duration() (which decodes back to timedelta(0), per FeatureView.from_proto's existing ToNanoseconds()==0 check) whenever there's no real ttl to write, instead of skipping the write. The LabelView branch is adjusted the same way, guarding FromTimedelta() against a None ttl now that the outer gate no longer prevents ttl=None from reaching this branch. Traced all three cases (None, timedelta(0), a finite value) through the new branch logic in isolation and confirmed FeatureView and LabelView now resolve identically: None and timedelta(0) both produce a zero Duration, a finite ttl passes through unchanged. Signed-off-by: saket3395 <[email protected]>
1 parent a9219d9 commit b20d2f6

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

‎sdk/python/feast/infra/registry/registry.py‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -580,20 +580,22 @@ def _update_metadata_fields(
580580
existing_proto.spec.version = getattr(updated_fv, "version")
581581

582582
# Configuration fields (FeatureView / LabelView TTL)
583-
if (
584-
hasattr(existing_proto.spec, "ttl")
585-
and hasattr(updated_fv, "ttl")
586-
and updated_fv.ttl
587-
):
583+
# Note: don't gate this on `updated_fv.ttl` being truthy -- None and
584+
# timedelta(0) are both the documented way to express "no ttl", and
585+
# are falsy, so that check would silently drop the update exactly
586+
# when a user clears an existing ttl.
587+
if hasattr(existing_proto.spec, "ttl") and hasattr(updated_fv, "ttl"):
588+
from google.protobuf.duration_pb2 import Duration
589+
588590
if isinstance(updated_fv, FeatureView):
589591
ttl_duration = updated_fv.get_ttl_duration()
590-
if ttl_duration:
591-
existing_proto.spec.ttl.CopyFrom(ttl_duration)
592+
existing_proto.spec.ttl.CopyFrom(
593+
ttl_duration if ttl_duration is not None else Duration()
594+
)
592595
elif isinstance(updated_fv, LabelView):
593-
from google.protobuf.duration_pb2 import Duration
594-
595596
ttl_duration = Duration()
596-
ttl_duration.FromTimedelta(updated_fv.ttl)
597+
if updated_fv.ttl is not None:
598+
ttl_duration.FromTimedelta(updated_fv.ttl)
597599
existing_proto.spec.ttl.CopyFrom(ttl_duration)
598600
if hasattr(existing_proto.spec, "online") and hasattr(updated_fv, "online"):
599601
existing_proto.spec.online = getattr(updated_fv, "online")

0 commit comments

Comments
 (0)