Skip to content

Commit

Permalink
fix: Fix DataSource constructor to unbreak custom data sources (#2492)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
achals authored and felixwang9817 committed Apr 6, 2022
1 parent f7911b7 commit 597c543
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 39 deletions.
49 changes: 35 additions & 14 deletions sdk/python/feast/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@


import enum
import warnings
from abc import ABC, abstractmethod
from typing import Any, Callable, Dict, Iterable, Optional, Tuple

Expand Down Expand Up @@ -160,14 +161,34 @@ class DataSource(ABC):

def __init__(
self,
name: str,
event_timestamp_column: Optional[str] = None,
created_timestamp_column: Optional[str] = None,
field_mapping: Optional[Dict[str, str]] = None,
date_partition_column: Optional[str] = None,
name: Optional[str] = None,
):
"""Creates a DataSource object."""
self.name = name
"""
Creates a DataSource object.
Args:
name: Name of data source, which should be unique within a project
event_timestamp_column (optional): Event timestamp column used for point in time
joins of feature values.
created_timestamp_column (optional): Timestamp column indicating when the row
was created, used for deduplicating rows.
field_mapping (optional): A dictionary mapping of column names in this data
source to feature names in a feature table or view. Only used for feature
columns, not entity or timestamp columns.
date_partition_column (optional): Timestamp column used for partitioning.
"""
if not name:
warnings.warn(
(
"Names for data sources need to be supplied. "
"Data sources without names will no tbe supported after Feast 0.23."
),
UserWarning,
)
self.name = name or ""
self.event_timestamp_column = (
event_timestamp_column if event_timestamp_column else ""
)
Expand Down Expand Up @@ -321,11 +342,11 @@ def __init__(
date_partition_column: Optional[str] = "",
):
super().__init__(
name,
event_timestamp_column,
created_timestamp_column,
field_mapping,
date_partition_column,
event_timestamp_column=event_timestamp_column,
created_timestamp_column=created_timestamp_column,
field_mapping=field_mapping,
date_partition_column=date_partition_column,
name=name,
)
self.kafka_options = KafkaOptions(
bootstrap_servers=bootstrap_servers,
Expand Down Expand Up @@ -402,7 +423,7 @@ def __init__(
self, name: str, schema: Dict[str, ValueType],
):
"""Creates a RequestDataSource object."""
super().__init__(name)
super().__init__(name=name)
self.schema = schema

def validate(self, config: RepoConfig):
Expand Down Expand Up @@ -485,11 +506,11 @@ def __init__(
date_partition_column: Optional[str] = "",
):
super().__init__(
name,
event_timestamp_column,
created_timestamp_column,
field_mapping,
date_partition_column,
name=name,
event_timestamp_column=event_timestamp_column,
created_timestamp_column=created_timestamp_column,
field_mapping=field_mapping,
date_partition_column=date_partition_column,
)
self.kinesis_options = KinesisOptions(
record_format=record_format, region=region, stream_name=stream_name
Expand Down
10 changes: 5 additions & 5 deletions sdk/python/feast/infra/offline_stores/bigquery_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ def __init__(
)

super().__init__(
_name if _name else "",
event_timestamp_column,
created_timestamp_column,
field_mapping,
date_partition_column,
name=_name if _name else "",
event_timestamp_column=event_timestamp_column,
created_timestamp_column=created_timestamp_column,
field_mapping=field_mapping,
date_partition_column=date_partition_column,
)

# Note: Python requires redefining hash in child classes that override __eq__
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ def __init__(
else:
raise DataSourceNoNameException()
super().__init__(
_name,
event_timestamp_column,
created_timestamp_column,
field_mapping,
date_partition_column,
name=_name if _name else "",
event_timestamp_column=event_timestamp_column,
created_timestamp_column=created_timestamp_column,
field_mapping=field_mapping,
date_partition_column=date_partition_column,
)
warnings.warn(
"The spark data source API is an experimental feature in alpha development. "
Expand Down
10 changes: 5 additions & 5 deletions sdk/python/feast/infra/offline_stores/file_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ def __init__(
)

super().__init__(
name if name else path,
event_timestamp_column,
created_timestamp_column,
field_mapping,
date_partition_column,
name=name if name else path,
event_timestamp_column=event_timestamp_column,
created_timestamp_column=created_timestamp_column,
field_mapping=field_mapping,
date_partition_column=date_partition_column,
)

# Note: Python requires redefining hash in child classes that override __eq__
Expand Down
10 changes: 5 additions & 5 deletions sdk/python/feast/infra/offline_stores/redshift_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ def __init__(
)

super().__init__(
_name if _name else "",
event_timestamp_column,
created_timestamp_column,
field_mapping,
date_partition_column,
name=_name if _name else "",
event_timestamp_column=event_timestamp_column,
created_timestamp_column=created_timestamp_column,
field_mapping=field_mapping,
date_partition_column=date_partition_column,
)

@staticmethod
Expand Down
10 changes: 5 additions & 5 deletions sdk/python/feast/infra/offline_stores/snowflake_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ def __init__(
)

super().__init__(
_name if _name else "",
event_timestamp_column,
created_timestamp_column,
field_mapping,
date_partition_column,
name=_name if _name else "",
event_timestamp_column=event_timestamp_column,
created_timestamp_column=created_timestamp_column,
field_mapping=field_mapping,
date_partition_column=date_partition_column,
)

@staticmethod
Expand Down

0 comments on commit 597c543

Please sign in to comment.