Skip to content

Commit 597c543

Browse files
achalsfelixwang9817
authored andcommitted
fix: Fix DataSource constructor to unbreak custom data sources (#2492)
* fix: Fix DataSource constructor to unbreak custom data sources Signed-off-by: Achal Shah <achals@gmail.com> * fix first party refernces to use kwargs only Signed-off-by: Achal Shah <achals@gmail.com> * remove force kwargs Signed-off-by: Achal Shah <achals@gmail.com>
1 parent f7911b7 commit 597c543

File tree

6 files changed

+60
-39
lines changed

6 files changed

+60
-39
lines changed

sdk/python/feast/data_source.py

Lines changed: 35 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

@@ -160,14 +161,34 @@ class DataSource(ABC):
160161

161162
def __init__(
162163
self,
163-
name: str,
164164
event_timestamp_column: Optional[str] = None,
165165
created_timestamp_column: Optional[str] = None,
166166
field_mapping: Optional[Dict[str, str]] = None,
167167
date_partition_column: Optional[str] = None,
168+
name: Optional[str] = None,
168169
):
169-
"""Creates a DataSource object."""
170-
self.name = name
170+
"""
171+
Creates a DataSource object.
172+
Args:
173+
name: Name of data source, which should be unique within a project
174+
event_timestamp_column (optional): Event timestamp column used for point in time
175+
joins of feature values.
176+
created_timestamp_column (optional): Timestamp column indicating when the row
177+
was created, used for deduplicating rows.
178+
field_mapping (optional): A dictionary mapping of column names in this data
179+
source to feature names in a feature table or view. Only used for feature
180+
columns, not entity or timestamp columns.
181+
date_partition_column (optional): Timestamp column used for partitioning.
182+
"""
183+
if not name:
184+
warnings.warn(
185+
(
186+
"Names for data sources need to be supplied. "
187+
"Data sources without names will no tbe supported after Feast 0.23."
188+
),
189+
UserWarning,
190+
)
191+
self.name = name or ""
171192
self.event_timestamp_column = (
172193
event_timestamp_column if event_timestamp_column else ""
173194
)
@@ -321,11 +342,11 @@ def __init__(
321342
date_partition_column: Optional[str] = "",
322343
):
323344
super().__init__(
324-
name,
325-
event_timestamp_column,
326-
created_timestamp_column,
327-
field_mapping,
328-
date_partition_column,
345+
event_timestamp_column=event_timestamp_column,
346+
created_timestamp_column=created_timestamp_column,
347+
field_mapping=field_mapping,
348+
date_partition_column=date_partition_column,
349+
name=name,
329350
)
330351
self.kafka_options = KafkaOptions(
331352
bootstrap_servers=bootstrap_servers,
@@ -402,7 +423,7 @@ def __init__(
402423
self, name: str, schema: Dict[str, ValueType],
403424
):
404425
"""Creates a RequestDataSource object."""
405-
super().__init__(name)
426+
super().__init__(name=name)
406427
self.schema = schema
407428

408429
def validate(self, config: RepoConfig):
@@ -485,11 +506,11 @@ def __init__(
485506
date_partition_column: Optional[str] = "",
486507
):
487508
super().__init__(
488-
name,
489-
event_timestamp_column,
490-
created_timestamp_column,
491-
field_mapping,
492-
date_partition_column,
509+
name=name,
510+
event_timestamp_column=event_timestamp_column,
511+
created_timestamp_column=created_timestamp_column,
512+
field_mapping=field_mapping,
513+
date_partition_column=date_partition_column,
493514
)
494515
self.kinesis_options = KinesisOptions(
495516
record_format=record_format, region=region, stream_name=stream_name

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ def __init__(
7070
)
7171

7272
super().__init__(
73-
_name if _name else "",
74-
event_timestamp_column,
75-
created_timestamp_column,
76-
field_mapping,
77-
date_partition_column,
73+
name=_name if _name else "",
74+
event_timestamp_column=event_timestamp_column,
75+
created_timestamp_column=created_timestamp_column,
76+
field_mapping=field_mapping,
77+
date_partition_column=date_partition_column,
7878
)
7979

8080
# Note: Python requires redefining hash in child classes that override __eq__

sdk/python/feast/infra/offline_stores/contrib/spark_offline_store/spark_source.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ def __init__(
4949
else:
5050
raise DataSourceNoNameException()
5151
super().__init__(
52-
_name,
53-
event_timestamp_column,
54-
created_timestamp_column,
55-
field_mapping,
56-
date_partition_column,
52+
name=_name if _name else "",
53+
event_timestamp_column=event_timestamp_column,
54+
created_timestamp_column=created_timestamp_column,
55+
field_mapping=field_mapping,
56+
date_partition_column=date_partition_column,
5757
)
5858
warnings.warn(
5959
"The spark data source API is an experimental feature in alpha development. "

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ def __init__(
5858
)
5959

6060
super().__init__(
61-
name if name else path,
62-
event_timestamp_column,
63-
created_timestamp_column,
64-
field_mapping,
65-
date_partition_column,
61+
name=name if name else path,
62+
event_timestamp_column=event_timestamp_column,
63+
created_timestamp_column=created_timestamp_column,
64+
field_mapping=field_mapping,
65+
date_partition_column=date_partition_column,
6666
)
6767

6868
# Note: Python requires redefining hash in child classes that override __eq__

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ def __init__(
6363
)
6464

6565
super().__init__(
66-
_name if _name else "",
67-
event_timestamp_column,
68-
created_timestamp_column,
69-
field_mapping,
70-
date_partition_column,
66+
name=_name if _name else "",
67+
event_timestamp_column=event_timestamp_column,
68+
created_timestamp_column=created_timestamp_column,
69+
field_mapping=field_mapping,
70+
date_partition_column=date_partition_column,
7171
)
7272

7373
@staticmethod

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ def __init__(
6666
)
6767

6868
super().__init__(
69-
_name if _name else "",
70-
event_timestamp_column,
71-
created_timestamp_column,
72-
field_mapping,
73-
date_partition_column,
69+
name=_name if _name else "",
70+
event_timestamp_column=event_timestamp_column,
71+
created_timestamp_column=created_timestamp_column,
72+
field_mapping=field_mapping,
73+
date_partition_column=date_partition_column,
7474
)
7575

7676
@staticmethod

0 commit comments

Comments
 (0)