From ea850860ff8de6edbddde6541708e889a70068d7 Mon Sep 17 00:00:00 2001 From: Achal Shah Date: Tue, 5 Apr 2022 09:47:55 -0700 Subject: [PATCH 1/3] fix: Fix DataSource constructor to unbreak custom data sources Signed-off-by: Achal Shah --- sdk/python/feast/data_source.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sdk/python/feast/data_source.py b/sdk/python/feast/data_source.py index f5c277aac4..66e38f9961 100644 --- a/sdk/python/feast/data_source.py +++ b/sdk/python/feast/data_source.py @@ -14,6 +14,7 @@ import enum +import warnings from abc import ABC, abstractmethod from typing import Any, Callable, Dict, Iterable, Optional, Tuple @@ -179,7 +180,7 @@ 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, @@ -187,6 +188,7 @@ def __init__( description: Optional[str] = "", tags: Optional[Dict[str, str]] = None, owner: Optional[str] = "", + name: Optional[str] = None, ): """ Creates a DataSource object. @@ -205,7 +207,13 @@ 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 "" ) From f5fc225a9edc75ce3780a00504fd42187ae8c5df Mon Sep 17 00:00:00 2001 From: Achal Shah Date: Tue, 5 Apr 2022 09:57:47 -0700 Subject: [PATCH 2/3] fix first party refernces to use kwargs only Signed-off-by: Achal Shah --- sdk/python/feast/data_source.py | 32 ++++++++++--------- .../infra/offline_stores/bigquery_source.py | 2 +- .../infra/offline_stores/redshift_source.py | 2 +- .../infra/offline_stores/snowflake_source.py | 2 +- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/sdk/python/feast/data_source.py b/sdk/python/feast/data_source.py index 66e38f9961..258b09d33e 100644 --- a/sdk/python/feast/data_source.py +++ b/sdk/python/feast/data_source.py @@ -209,9 +209,11 @@ def __init__( """ 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 + ( + "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 = ( @@ -348,14 +350,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, @@ -446,7 +448,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): @@ -544,11 +546,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, @@ -628,7 +630,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: diff --git a/sdk/python/feast/infra/offline_stores/bigquery_source.py b/sdk/python/feast/infra/offline_stores/bigquery_source.py index d36da8f342..a29b0eb81a 100644 --- a/sdk/python/feast/infra/offline_stores/bigquery_source.py +++ b/sdk/python/feast/infra/offline_stores/bigquery_source.py @@ -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, diff --git a/sdk/python/feast/infra/offline_stores/redshift_source.py b/sdk/python/feast/infra/offline_stores/redshift_source.py index 11407b9227..5beb50a2fb 100644 --- a/sdk/python/feast/infra/offline_stores/redshift_source.py +++ b/sdk/python/feast/infra/offline_stores/redshift_source.py @@ -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, diff --git a/sdk/python/feast/infra/offline_stores/snowflake_source.py b/sdk/python/feast/infra/offline_stores/snowflake_source.py index d335f33dda..1fa5032840 100644 --- a/sdk/python/feast/infra/offline_stores/snowflake_source.py +++ b/sdk/python/feast/infra/offline_stores/snowflake_source.py @@ -82,7 +82,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, From 392dc804bd28f90d96ef6f87918248f1ddb03557 Mon Sep 17 00:00:00 2001 From: Achal Shah Date: Tue, 5 Apr 2022 10:08:00 -0700 Subject: [PATCH 3/3] remove force kwargs Signed-off-by: Achal Shah --- sdk/python/feast/data_source.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/python/feast/data_source.py b/sdk/python/feast/data_source.py index 258b09d33e..db9eabfb9f 100644 --- a/sdk/python/feast/data_source.py +++ b/sdk/python/feast/data_source.py @@ -180,7 +180,6 @@ class DataSource(ABC): def __init__( self, - *, event_timestamp_column: Optional[str] = None, created_timestamp_column: Optional[str] = None, field_mapping: Optional[Dict[str, str]] = None,