Skip to content

Commit 712653e

Browse files
authored
fix: Fix DataSource constructor to unbreak custom data sources (#2492)
* fix: Fix DataSource constructor to unbreak custom data sources Signed-off-by: Achal Shah <[email protected]> * fix first party refernces to use kwargs only Signed-off-by: Achal Shah <[email protected]> * remove force kwargs Signed-off-by: Achal Shah <[email protected]>
1 parent 2917e27 commit 712653e

File tree

4 files changed

+26
-17
lines changed

4 files changed

+26
-17
lines changed

sdk/python/feast/data_source.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515

1616
import enum
17+
import warnings
1718
from abc import ABC, abstractmethod
1819
from typing import Any, Callable, Dict, Iterable, Optional, Tuple
1920

@@ -179,14 +180,14 @@ class DataSource(ABC):
179180

180181
def __init__(
181182
self,
182-
name: str,
183183
event_timestamp_column: Optional[str] = None,
184184
created_timestamp_column: Optional[str] = None,
185185
field_mapping: Optional[Dict[str, str]] = None,
186186
date_partition_column: Optional[str] = None,
187187
description: Optional[str] = "",
188188
tags: Optional[Dict[str, str]] = None,
189189
owner: Optional[str] = "",
190+
name: Optional[str] = None,
190191
):
191192
"""
192193
Creates a DataSource object.
@@ -205,7 +206,15 @@ def __init__(
205206
owner (optional): The owner of the data source, typically the email of the primary
206207
maintainer.
207208
"""
208-
self.name = name
209+
if not name:
210+
warnings.warn(
211+
(
212+
"Names for data sources need to be supplied. "
213+
"Data sources without names will no tbe supported after Feast 0.23."
214+
),
215+
UserWarning,
216+
)
217+
self.name = name or ""
209218
self.event_timestamp_column = (
210219
event_timestamp_column if event_timestamp_column else ""
211220
)
@@ -340,14 +349,14 @@ def __init__(
340349
owner: Optional[str] = "",
341350
):
342351
super().__init__(
343-
name,
344-
event_timestamp_column,
345-
created_timestamp_column,
346-
field_mapping,
347-
date_partition_column,
352+
event_timestamp_column=event_timestamp_column,
353+
created_timestamp_column=created_timestamp_column,
354+
field_mapping=field_mapping,
355+
date_partition_column=date_partition_column,
348356
description=description,
349357
tags=tags,
350358
owner=owner,
359+
name=name,
351360
)
352361
self.kafka_options = KafkaOptions(
353362
bootstrap_servers=bootstrap_servers,
@@ -438,7 +447,7 @@ def __init__(
438447
owner: Optional[str] = "",
439448
):
440449
"""Creates a RequestDataSource object."""
441-
super().__init__(name, description=description, tags=tags, owner=owner)
450+
super().__init__(name=name, description=description, tags=tags, owner=owner)
442451
self.schema = schema
443452

444453
def validate(self, config: RepoConfig):
@@ -536,11 +545,11 @@ def __init__(
536545
owner: Optional[str] = "",
537546
):
538547
super().__init__(
539-
name,
540-
event_timestamp_column,
541-
created_timestamp_column,
542-
field_mapping,
543-
date_partition_column,
548+
name=name,
549+
event_timestamp_column=event_timestamp_column,
550+
created_timestamp_column=created_timestamp_column,
551+
field_mapping=field_mapping,
552+
date_partition_column=date_partition_column,
544553
description=description,
545554
tags=tags,
546555
owner=owner,
@@ -620,7 +629,7 @@ def __init__(
620629
owner (optional): The owner of the data source, typically the email of the primary
621630
maintainer.
622631
"""
623-
super().__init__(name, description=description, tags=tags, owner=owner)
632+
super().__init__(name=name, description=description, tags=tags, owner=owner)
624633
self.schema = schema
625634
self.batch_source = batch_source
626635
if not self.batch_source:

sdk/python/feast/infra/offline_stores/bigquery_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def __init__(
8686
)
8787

8888
super().__init__(
89-
_name if _name else "",
89+
name=_name if _name else "",
9090
event_timestamp_column=event_timestamp_column,
9191
created_timestamp_column=created_timestamp_column,
9292
field_mapping=field_mapping,

sdk/python/feast/infra/offline_stores/redshift_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(
8080
)
8181

8282
super().__init__(
83-
_name if _name else "",
83+
name=_name if _name else "",
8484
event_timestamp_column=event_timestamp_column,
8585
created_timestamp_column=created_timestamp_column,
8686
field_mapping=field_mapping,

sdk/python/feast/infra/offline_stores/snowflake_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def __init__(
8888
)
8989

9090
super().__init__(
91-
_name if _name else "",
91+
name=_name if _name else "",
9292
event_timestamp_column=event_timestamp_column,
9393
created_timestamp_column=created_timestamp_column,
9494
field_mapping=field_mapping,

0 commit comments

Comments
 (0)