From edf20a47b0eea2ba2e659e8a73a49f0602026ddb Mon Sep 17 00:00:00 2001 From: Willem Pienaar Date: Wed, 21 Apr 2021 09:15:44 -0700 Subject: [PATCH 1/2] Fix no-op for GCS registry Signed-off-by: Willem Pienaar --- sdk/python/feast/registry.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sdk/python/feast/registry.py b/sdk/python/feast/registry.py index 473de1b49c..603ec723d5 100644 --- a/sdk/python/feast/registry.py +++ b/sdk/python/feast/registry.py @@ -20,8 +20,6 @@ from typing import Callable, List, Optional from urllib.parse import urlparse -from google.auth.exceptions import DefaultCredentialsError - from feast.entity import Entity from feast.errors import ( EntityNotFoundException, @@ -71,7 +69,7 @@ def __init__(self, registry_path: str, repo_path: Path, cache_ttl: timedelta): def _initialize_registry(self): """Explicitly forces the initialization of a registry""" - self._registry_store.update_registry_proto() + self._registry_store.update_registry_proto(updater=None) def apply_entity(self, entity: Entity, project: str): """ @@ -377,7 +375,9 @@ def get_registry_proto(self): pass @abstractmethod - def update_registry_proto(self, updater: Callable[[RegistryProto], RegistryProto]): + def update_registry_proto( + self, updater: Optional[Callable[[RegistryProto], RegistryProto]] + ): """ Updates the registry using the function passed in. If the registry proto has not been created yet this method will create it. This method writes to the registry path. @@ -406,7 +406,7 @@ def get_registry_proto(self): ) def update_registry_proto( - self, updater: Callable[[RegistryProto], RegistryProto] = None + self, updater: Optional[Callable[[RegistryProto], RegistryProto]] = None ): try: registry_proto = self.get_registry_proto() @@ -431,6 +431,7 @@ def _write_registry(self, registry_proto: RegistryProto): class GCSRegistryStore(RegistryStore): def __init__(self, uri: str): try: + from google.auth.exceptions import DefaultCredentialsError from google.cloud import storage except ImportError: # TODO: Ensure versioning depends on requirements.txt/setup.py and isn't hardcoded @@ -470,13 +471,16 @@ def get_registry_proto(self): f'Registry not found at path "{self._uri.geturl()}". Have you run "feast apply"?' ) - def update_registry_proto(self, updater: Callable[[RegistryProto], RegistryProto]): + def update_registry_proto( + self, updater: Callable[[RegistryProto], RegistryProto] = None + ): try: registry_proto = self.get_registry_proto() except FileNotFoundError: registry_proto = RegistryProto() registry_proto.registry_schema_version = REGISTRY_SCHEMA_VERSION - registry_proto = updater(registry_proto) + if updater: + registry_proto = updater(registry_proto) self._write_registry(registry_proto) return From 4d8e3432a939112def08a3e4f279e419ff28cd69 Mon Sep 17 00:00:00 2001 From: Willem Pienaar Date: Wed, 21 Apr 2021 09:17:21 -0700 Subject: [PATCH 2/2] Unify signature Signed-off-by: Willem Pienaar --- sdk/python/feast/registry.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/python/feast/registry.py b/sdk/python/feast/registry.py index 603ec723d5..8832ea9f94 100644 --- a/sdk/python/feast/registry.py +++ b/sdk/python/feast/registry.py @@ -376,7 +376,7 @@ def get_registry_proto(self): @abstractmethod def update_registry_proto( - self, updater: Optional[Callable[[RegistryProto], RegistryProto]] + self, updater: Optional[Callable[[RegistryProto], RegistryProto]] = None ): """ Updates the registry using the function passed in. If the registry proto has not been created yet @@ -472,7 +472,7 @@ def get_registry_proto(self): ) def update_registry_proto( - self, updater: Callable[[RegistryProto], RegistryProto] = None + self, updater: Optional[Callable[[RegistryProto], RegistryProto]] = None ): try: registry_proto = self.get_registry_proto()