1515from tests .integration .feature_repos .universal .data_source_creator import (
1616 DataSourceCreator ,
1717)
18- from tests .integration .feature_repos .universal .online_store_creator import OnlineStoreCreator
18+ from tests .integration .feature_repos .universal .online_store_creator import (
19+ OnlineStoreCreator ,
20+ )
1921
2022logger = logging .getLogger (__name__ )
2123
@@ -38,24 +40,27 @@ def initialize(cls, project_name: str, *args, **kwargs):
3840 cls .project_name = project_name
3941
4042 if "offline_container" not in kwargs or not kwargs .get (
41- "offline_container" , None
43+ "offline_container" , None
4244 ):
4345 # If we don't get an offline container provided, we try to create it on the fly.
4446 # the problem here is that each test creates its own container, which basically
4547 # browns out developer laptops.
4648 cls .container = (
4749 DockerContainer ("postgres:latest" )
48- .with_exposed_ports (5432 )
49- .with_env ("POSTGRES_USER" , cls .postgres_user )
50- .with_env ("POSTGRES_PASSWORD" , cls .postgres_password )
51- .with_env ("POSTGRES_DB" , cls .postgres_db )
50+ .with_exposed_ports (5432 )
51+ .with_env ("POSTGRES_USER" , cls .postgres_user )
52+ .with_env ("POSTGRES_PASSWORD" , cls .postgres_password )
53+ .with_env ("POSTGRES_DB" , cls .postgres_db )
5254 )
5355
5456 cls .container .start ()
5557 cls .provided_container = False
5658 log_string_to_wait_for = "database system is ready to accept connections"
5759 waited = wait_for_logs (
58- container = cls .container , predicate = log_string_to_wait_for , timeout = 30 , interval = 10
60+ container = cls .container ,
61+ predicate = log_string_to_wait_for ,
62+ timeout = 30 ,
63+ interval = 10 ,
5964 )
6065 logger .info ("Waited for %s seconds until postgres container was up" , waited )
6166 cls .running = True
@@ -75,18 +80,19 @@ def initialize(cls, project_name: str, *args, **kwargs):
7580
7681 @classmethod
7782 def create_data_source (
78- cls ,
79- df : pd .DataFrame ,
80- destination_name : str ,
81- suffix : Optional [str ] = None ,
82- timestamp_field = "ts" ,
83- created_timestamp_column = "created_ts" ,
84- field_mapping : Dict [str , str ] = None ,
83+ cls ,
84+ df : pd .DataFrame ,
85+ destination_name : str ,
86+ suffix : Optional [str ] = None ,
87+ timestamp_field = "ts" ,
88+ created_timestamp_column = "created_ts" ,
89+ field_mapping : Dict [str , str ] = None ,
8590 ) -> DataSource :
8691
8792 destination_name = cls .get_prefixed_table_name (destination_name )
8893
89- df_to_postgres_table (cls .offline_store_config , df , destination_name )
94+ if cls .offline_store_config :
95+ df_to_postgres_table (cls .offline_store_config , df , destination_name )
9096
9197 return PostgreSQLSource (
9298 name = destination_name ,
@@ -97,7 +103,8 @@ def create_data_source(
97103 )
98104
99105 @classmethod
100- def create_offline_store_config (cls ) -> FeastConfigBaseModel :
106+ def create_offline_store_config (cls ) -> PostgreSQLOfflineStoreConfig :
107+ assert cls .offline_store_config
101108 return cls .offline_store_config
102109
103110 @classmethod
@@ -106,6 +113,7 @@ def get_prefixed_table_name(cls, suffix: str) -> str:
106113
107114 @classmethod
108115 def create_online_store (cls ) -> Dict [str , str ]:
116+ assert cls .container
109117 return {
110118 "type" : "postgres" ,
111119 "host" : "localhost" ,
@@ -152,7 +160,14 @@ def create_data_source(
152160 field_mapping : Dict [str , str ] = None ,
153161 ) -> DataSource :
154162
155- return PostgresSourceCreatorSingleton .create_data_source (df , destination_name , suffix , timestamp_field , created_timestamp_column , field_mapping )
163+ return PostgresSourceCreatorSingleton .create_data_source (
164+ df ,
165+ destination_name ,
166+ suffix ,
167+ timestamp_field ,
168+ created_timestamp_column ,
169+ field_mapping ,
170+ )
156171
157172 def create_offline_store_config (self ) -> FeastConfigBaseModel :
158173 return PostgresSourceCreatorSingleton .create_offline_store_config ()
0 commit comments