47
47
from feast .repo_contents import RepoContents
48
48
from feast .saved_dataset import SavedDataset , ValidationReference
49
49
from feast .stream_feature_view import StreamFeatureView
50
+ from feast .utils import _utc_now
50
51
51
52
REGISTRY_SCHEMA_VERSION = "1"
52
53
@@ -217,7 +218,7 @@ def clone(self) -> "Registry":
217
218
if self .cached_registry_proto
218
219
else RegistryProto ()
219
220
)
220
- new_registry .cached_registry_proto_created = datetime . utcnow ()
221
+ new_registry .cached_registry_proto_created = _utc_now ()
221
222
new_registry ._registry_store = NoopRegistryStore ()
222
223
return new_registry
223
224
@@ -248,7 +249,7 @@ def get_infra(self, project: str, allow_cache: bool = False) -> Infra:
248
249
def apply_entity (self , entity : Entity , project : str , commit : bool = True ):
249
250
entity .is_valid ()
250
251
251
- now = datetime . utcnow ()
252
+ now = _utc_now ()
252
253
if not entity .created_timestamp :
253
254
entity .created_timestamp = now
254
255
entity .last_updated_timestamp = now
@@ -334,7 +335,7 @@ def delete_data_source(self, name: str, project: str, commit: bool = True):
334
335
def apply_feature_service (
335
336
self , feature_service : FeatureService , project : str , commit : bool = True
336
337
):
337
- now = datetime . utcnow ()
338
+ now = _utc_now ()
338
339
if not feature_service .created_timestamp :
339
340
feature_service .created_timestamp = now
340
341
feature_service .last_updated_timestamp = now
@@ -390,7 +391,7 @@ def apply_feature_view(
390
391
):
391
392
feature_view .ensure_valid ()
392
393
393
- now = datetime . utcnow ()
394
+ now = _utc_now ()
394
395
if not feature_view .created_timestamp :
395
396
feature_view .created_timestamp = now
396
397
feature_view .last_updated_timestamp = now
@@ -517,7 +518,7 @@ def apply_materialization(
517
518
existing_feature_view .materialization_intervals .append (
518
519
(start_date , end_date )
519
520
)
520
- existing_feature_view .last_updated_timestamp = datetime . utcnow ()
521
+ existing_feature_view .last_updated_timestamp = _utc_now ()
521
522
feature_view_proto = existing_feature_view .to_proto ()
522
523
feature_view_proto .spec .project = project
523
524
del self .cached_registry_proto .feature_views [idx ]
@@ -539,7 +540,7 @@ def apply_materialization(
539
540
existing_stream_feature_view .materialization_intervals .append (
540
541
(start_date , end_date )
541
542
)
542
- existing_stream_feature_view .last_updated_timestamp = datetime . utcnow ()
543
+ existing_stream_feature_view .last_updated_timestamp = _utc_now ()
543
544
stream_feature_view_proto = existing_stream_feature_view .to_proto ()
544
545
stream_feature_view_proto .spec .project = project
545
546
del self .cached_registry_proto .stream_feature_views [idx ]
@@ -664,7 +665,7 @@ def apply_saved_dataset(
664
665
project : str ,
665
666
commit : bool = True ,
666
667
):
667
- now = datetime . utcnow ()
668
+ now = _utc_now ()
668
669
if not saved_dataset .created_timestamp :
669
670
saved_dataset .created_timestamp = now
670
671
saved_dataset .last_updated_timestamp = now
@@ -812,7 +813,7 @@ def _prepare_registry_for_changes(self, project: str):
812
813
registry_proto = RegistryProto ()
813
814
registry_proto .registry_schema_version = REGISTRY_SCHEMA_VERSION
814
815
self .cached_registry_proto = registry_proto
815
- self .cached_registry_proto_created = datetime . utcnow ()
816
+ self .cached_registry_proto_created = _utc_now ()
816
817
817
818
# Initialize project metadata if needed
818
819
assert self .cached_registry_proto
@@ -848,7 +849,7 @@ def _get_registry_proto(
848
849
self .cached_registry_proto_ttl .total_seconds ()
849
850
> 0 # 0 ttl means infinity
850
851
and (
851
- datetime . utcnow ()
852
+ _utc_now ()
852
853
> (
853
854
self .cached_registry_proto_created
854
855
+ self .cached_registry_proto_ttl
@@ -871,7 +872,7 @@ def _get_registry_proto(
871
872
logger .info ("Registry cache expired, so refreshing" )
872
873
registry_proto = self ._registry_store .get_registry_proto ()
873
874
self .cached_registry_proto = registry_proto
874
- self .cached_registry_proto_created = datetime . utcnow ()
875
+ self .cached_registry_proto_created = _utc_now ()
875
876
876
877
if not project :
877
878
return registry_proto
0 commit comments