2020from typing import Callable , List , Optional
2121from urllib .parse import urlparse
2222
23- from google .auth .exceptions import DefaultCredentialsError
24-
2523from feast .entity import Entity
2624from feast .errors import (
2725 EntityNotFoundException ,
@@ -71,7 +69,7 @@ def __init__(self, registry_path: str, repo_path: Path, cache_ttl: timedelta):
7169
7270 def _initialize_registry (self ):
7371 """Explicitly forces the initialization of a registry"""
74- self ._registry_store .update_registry_proto ()
72+ self ._registry_store .update_registry_proto (updater = None )
7573
7674 def apply_entity (self , entity : Entity , project : str ):
7775 """
@@ -377,7 +375,9 @@ def get_registry_proto(self):
377375 pass
378376
379377 @abstractmethod
380- def update_registry_proto (self , updater : Callable [[RegistryProto ], RegistryProto ]):
378+ def update_registry_proto (
379+ self , updater : Optional [Callable [[RegistryProto ], RegistryProto ]] = None
380+ ):
381381 """
382382 Updates the registry using the function passed in. If the registry proto has not been created yet
383383 this method will create it. This method writes to the registry path.
@@ -406,7 +406,7 @@ def get_registry_proto(self):
406406 )
407407
408408 def update_registry_proto (
409- self , updater : Callable [[RegistryProto ], RegistryProto ] = None
409+ self , updater : Optional [ Callable [[RegistryProto ], RegistryProto ] ] = None
410410 ):
411411 try :
412412 registry_proto = self .get_registry_proto ()
@@ -431,6 +431,7 @@ def _write_registry(self, registry_proto: RegistryProto):
431431class GCSRegistryStore (RegistryStore ):
432432 def __init__ (self , uri : str ):
433433 try :
434+ from google .auth .exceptions import DefaultCredentialsError
434435 from google .cloud import storage
435436 except ImportError :
436437 # TODO: Ensure versioning depends on requirements.txt/setup.py and isn't hardcoded
@@ -470,13 +471,16 @@ def get_registry_proto(self):
470471 f'Registry not found at path "{ self ._uri .geturl ()} ". Have you run "feast apply"?'
471472 )
472473
473- def update_registry_proto (self , updater : Callable [[RegistryProto ], RegistryProto ]):
474+ def update_registry_proto (
475+ self , updater : Optional [Callable [[RegistryProto ], RegistryProto ]] = None
476+ ):
474477 try :
475478 registry_proto = self .get_registry_proto ()
476479 except FileNotFoundError :
477480 registry_proto = RegistryProto ()
478481 registry_proto .registry_schema_version = REGISTRY_SCHEMA_VERSION
479- registry_proto = updater (registry_proto )
482+ if updater :
483+ registry_proto = updater (registry_proto )
480484 self ._write_registry (registry_proto )
481485 return
482486
0 commit comments