4747from feast .repo_contents import RepoContents
4848from feast .saved_dataset import SavedDataset , ValidationReference
4949from feast .stream_feature_view import StreamFeatureView
50+ from feast .utils import _utc_now
5051
5152REGISTRY_SCHEMA_VERSION = "1"
5253
@@ -217,7 +218,7 @@ def clone(self) -> "Registry":
217218 if self .cached_registry_proto
218219 else RegistryProto ()
219220 )
220- new_registry .cached_registry_proto_created = datetime . utcnow ()
221+ new_registry .cached_registry_proto_created = _utc_now ()
221222 new_registry ._registry_store = NoopRegistryStore ()
222223 return new_registry
223224
@@ -248,7 +249,7 @@ def get_infra(self, project: str, allow_cache: bool = False) -> Infra:
248249 def apply_entity (self , entity : Entity , project : str , commit : bool = True ):
249250 entity .is_valid ()
250251
251- now = datetime . utcnow ()
252+ now = _utc_now ()
252253 if not entity .created_timestamp :
253254 entity .created_timestamp = now
254255 entity .last_updated_timestamp = now
@@ -334,7 +335,7 @@ def delete_data_source(self, name: str, project: str, commit: bool = True):
334335 def apply_feature_service (
335336 self , feature_service : FeatureService , project : str , commit : bool = True
336337 ):
337- now = datetime . utcnow ()
338+ now = _utc_now ()
338339 if not feature_service .created_timestamp :
339340 feature_service .created_timestamp = now
340341 feature_service .last_updated_timestamp = now
@@ -390,7 +391,7 @@ def apply_feature_view(
390391 ):
391392 feature_view .ensure_valid ()
392393
393- now = datetime . utcnow ()
394+ now = _utc_now ()
394395 if not feature_view .created_timestamp :
395396 feature_view .created_timestamp = now
396397 feature_view .last_updated_timestamp = now
@@ -517,7 +518,7 @@ def apply_materialization(
517518 existing_feature_view .materialization_intervals .append (
518519 (start_date , end_date )
519520 )
520- existing_feature_view .last_updated_timestamp = datetime . utcnow ()
521+ existing_feature_view .last_updated_timestamp = _utc_now ()
521522 feature_view_proto = existing_feature_view .to_proto ()
522523 feature_view_proto .spec .project = project
523524 del self .cached_registry_proto .feature_views [idx ]
@@ -539,7 +540,7 @@ def apply_materialization(
539540 existing_stream_feature_view .materialization_intervals .append (
540541 (start_date , end_date )
541542 )
542- existing_stream_feature_view .last_updated_timestamp = datetime . utcnow ()
543+ existing_stream_feature_view .last_updated_timestamp = _utc_now ()
543544 stream_feature_view_proto = existing_stream_feature_view .to_proto ()
544545 stream_feature_view_proto .spec .project = project
545546 del self .cached_registry_proto .stream_feature_views [idx ]
@@ -664,7 +665,7 @@ def apply_saved_dataset(
664665 project : str ,
665666 commit : bool = True ,
666667 ):
667- now = datetime . utcnow ()
668+ now = _utc_now ()
668669 if not saved_dataset .created_timestamp :
669670 saved_dataset .created_timestamp = now
670671 saved_dataset .last_updated_timestamp = now
@@ -812,7 +813,7 @@ def _prepare_registry_for_changes(self, project: str):
812813 registry_proto = RegistryProto ()
813814 registry_proto .registry_schema_version = REGISTRY_SCHEMA_VERSION
814815 self .cached_registry_proto = registry_proto
815- self .cached_registry_proto_created = datetime . utcnow ()
816+ self .cached_registry_proto_created = _utc_now ()
816817
817818 # Initialize project metadata if needed
818819 assert self .cached_registry_proto
@@ -848,7 +849,7 @@ def _get_registry_proto(
848849 self .cached_registry_proto_ttl .total_seconds ()
849850 > 0 # 0 ttl means infinity
850851 and (
851- datetime . utcnow ()
852+ _utc_now ()
852853 > (
853854 self .cached_registry_proto_created
854855 + self .cached_registry_proto_ttl
@@ -871,7 +872,7 @@ def _get_registry_proto(
871872 logger .info ("Registry cache expired, so refreshing" )
872873 registry_proto = self ._registry_store .get_registry_proto ()
873874 self .cached_registry_proto = registry_proto
874- self .cached_registry_proto_created = datetime . utcnow ()
875+ self .cached_registry_proto_created = _utc_now ()
875876
876877 if not project :
877878 return registry_proto
0 commit comments