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 <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>
  • Loading branch information
achals authored Apr 5, 2022
1 parent 2917e27 commit 712653e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
37 changes: 23 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 @@ -179,14 +180,14 @@ 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,
description: Optional[str] = "",
tags: Optional[Dict[str, str]] = None,
owner: Optional[str] = "",
name: Optional[str] = None,
):
"""
Creates a DataSource object.
Expand All @@ -205,7 +206,15 @@ def __init__(
owner (optional): The owner of the data source, typically the email of the primary
maintainer.
"""
self.name = name
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 @@ -340,14 +349,14 @@ def __init__(
owner: 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,
description=description,
tags=tags,
owner=owner,
name=name,
)
self.kafka_options = KafkaOptions(
bootstrap_servers=bootstrap_servers,
Expand Down Expand Up @@ -438,7 +447,7 @@ def __init__(
owner: Optional[str] = "",
):
"""Creates a RequestDataSource object."""
super().__init__(name, description=description, tags=tags, owner=owner)
super().__init__(name=name, description=description, tags=tags, owner=owner)
self.schema = schema

def validate(self, config: RepoConfig):
Expand Down Expand Up @@ -536,11 +545,11 @@ def __init__(
owner: 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,
description=description,
tags=tags,
owner=owner,
Expand Down Expand Up @@ -620,7 +629,7 @@ def __init__(
owner (optional): The owner of the data source, typically the email of the primary
maintainer.
"""
super().__init__(name, description=description, tags=tags, owner=owner)
super().__init__(name=name, description=description, tags=tags, owner=owner)
self.schema = schema
self.batch_source = batch_source
if not self.batch_source:
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/feast/infra/offline_stores/bigquery_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(
)

super().__init__(
_name if _name else "",
name=_name if _name else "",
event_timestamp_column=event_timestamp_column,
created_timestamp_column=created_timestamp_column,
field_mapping=field_mapping,
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/feast/infra/offline_stores/redshift_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(
)

super().__init__(
_name if _name else "",
name=_name if _name else "",
event_timestamp_column=event_timestamp_column,
created_timestamp_column=created_timestamp_column,
field_mapping=field_mapping,
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/feast/infra/offline_stores/snowflake_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(
)

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

0 comments on commit 712653e

Please sign in to comment.