66import mmh3
77import pandas
88import pyarrow
9- from google .auth .exceptions import DefaultCredentialsError
109from tqdm import tqdm
1110
1211from feast import FeatureTable , utils
2726from feast .registry import Registry
2827from feast .repo_config import DatastoreOnlineStoreConfig , RepoConfig
2928
29+ try :
30+ from google .auth .exceptions import DefaultCredentialsError
31+ from google .cloud import bigquery , datastore
32+ except ImportError as e :
33+ from feast .errors import FeastExtrasDependencyImportError
34+
35+ raise FeastExtrasDependencyImportError ("gcp" , str (e ))
36+
3037
3138class GcpProvider (Provider ):
3239 _gcp_project_id : Optional [str ]
@@ -39,8 +46,6 @@ def __init__(self, config: RepoConfig):
3946 self ._gcp_project_id = None
4047
4148 def _initialize_client (self ):
42- from google .cloud import datastore
43-
4449 try :
4550 if self ._gcp_project_id is not None :
4651 return datastore .Client (self ._gcp_project_id )
@@ -49,7 +54,8 @@ def _initialize_client(self):
4954 except DefaultCredentialsError as e :
5055 raise FeastProviderLoginError (
5156 str (e )
52- + '\n It may be necessary to run "gcloud auth application-default login" if you would like to use your local Google Cloud account'
57+ + '\n It may be necessary to run "gcloud auth application-default login" if you would like to use your '
58+ "local Google Cloud account "
5359 )
5460
5561 def update_infra (
@@ -61,7 +67,6 @@ def update_infra(
6167 entities_to_keep : Sequence [Entity ],
6268 partial : bool ,
6369 ):
64- from google .cloud import datastore
6570
6671 client = self ._initialize_client ()
6772
@@ -190,8 +195,6 @@ def materialize_single_feature_view(
190195
191196 @staticmethod
192197 def _pull_query (query : str ) -> pyarrow .Table :
193- from google .cloud import bigquery
194-
195198 client = bigquery .Client ()
196199 query_job = client .query (query )
197200 return query_job .to_arrow ()
@@ -248,8 +251,6 @@ def _write_minibatch(
248251 ],
249252 progress : Optional [Callable [[int ], Any ]],
250253):
251- from google .cloud import datastore
252-
253254 entities = []
254255 for entity_key , features , timestamp , created_ts in data :
255256 document_id = compute_datastore_entity_id (entity_key )
0 commit comments