1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414import re
15+ import warnings
1516from datetime import datetime , timedelta
1617from typing import Dict , List , Optional , Tuple , Union
1718
3839from feast .usage import log_exceptions
3940from feast .value_type import ValueType
4041
42+ warnings .simplefilter ("once" , DeprecationWarning )
43+
4144
4245class FeatureView :
4346 """
@@ -51,7 +54,7 @@ class FeatureView:
5154 ttl : Optional [timedelta ]
5255 online : bool
5356 input : DataSource
54- batch_source : Optional [ DataSource ] = None
57+ batch_source : DataSource
5558 stream_source : Optional [DataSource ] = None
5659 created_timestamp : Optional [Timestamp ] = None
5760 last_updated_timestamp : Optional [Timestamp ] = None
@@ -63,13 +66,21 @@ def __init__(
6366 name : str ,
6467 entities : List [str ],
6568 ttl : Optional [Union [Duration , timedelta ]],
66- input : DataSource ,
69+ input : Optional [ DataSource ] = None ,
6770 batch_source : Optional [DataSource ] = None ,
6871 stream_source : Optional [DataSource ] = None ,
6972 features : List [Feature ] = None ,
7073 tags : Optional [Dict [str , str ]] = None ,
7174 online : bool = True ,
7275 ):
76+ warnings .warn (
77+ (
78+ "The argument 'input' is being deprecated. Please use 'batch_source' "
79+ "instead. Feast 0.13 and onwards will not support the argument 'input'."
80+ ),
81+ DeprecationWarning ,
82+ )
83+
7384 _input = input or batch_source
7485 assert _input is not None
7586
@@ -139,7 +150,7 @@ def __eq__(self, other):
139150 return False
140151 if sorted (self .features ) != sorted (other .features ):
141152 return False
142- if self .input != other .input :
153+ if self .batch_source != other .batch_source :
143154 return False
144155 if self .stream_source != other .stream_source :
145156 return False
@@ -182,10 +193,8 @@ def to_proto(self) -> FeatureViewProto:
182193 ttl_duration = Duration ()
183194 ttl_duration .FromTimedelta (self .ttl )
184195
185- batch_source_proto = self .input .to_proto ()
186- batch_source_proto .data_source_class_type = (
187- f"{ self .input .__class__ .__module__ } .{ self .input .__class__ .__name__ } "
188- )
196+ batch_source_proto = self .batch_source .to_proto ()
197+ batch_source_proto .data_source_class_type = f"{ self .batch_source .__class__ .__module__ } .{ self .batch_source .__class__ .__name__ } "
189198
190199 stream_source_proto = None
191200 if self .stream_source :
@@ -217,7 +226,7 @@ def from_proto(cls, feature_view_proto: FeatureViewProto):
217226 Returns a FeatureViewProto object based on the feature view protobuf
218227 """
219228
220- _input = DataSource .from_proto (feature_view_proto .spec .batch_source )
229+ batch_source = DataSource .from_proto (feature_view_proto .spec .batch_source )
221230 stream_source = (
222231 DataSource .from_proto (feature_view_proto .spec .stream_source )
223232 if feature_view_proto .spec .HasField ("stream_source" )
@@ -242,8 +251,8 @@ def from_proto(cls, feature_view_proto: FeatureViewProto):
242251 and feature_view_proto .spec .ttl .nanos == 0
243252 else feature_view_proto .spec .ttl
244253 ),
245- input = _input ,
246- batch_source = _input ,
254+ input = batch_source ,
255+ batch_source = batch_source ,
247256 stream_source = stream_source ,
248257 )
249258
@@ -265,29 +274,30 @@ def most_recent_end_time(self) -> Optional[datetime]:
265274 return None
266275 return max ([interval [1 ] for interval in self .materialization_intervals ])
267276
268- def infer_features_from_input_source (self , config : RepoConfig ):
277+ def infer_features_from_batch_source (self , config : RepoConfig ):
269278 if not self .features :
270279 columns_to_exclude = {
271- self .input .event_timestamp_column ,
272- self .input .created_timestamp_column ,
280+ self .batch_source .event_timestamp_column ,
281+ self .batch_source .created_timestamp_column ,
273282 } | set (self .entities )
274283
275- for col_name , col_datatype in self .input .get_table_column_names_and_types (
276- config
277- ):
284+ for (
285+ col_name ,
286+ col_datatype ,
287+ ) in self .batch_source .get_table_column_names_and_types (config ):
278288 if col_name not in columns_to_exclude and not re .match (
279289 "^__|__$" ,
280290 col_name , # double underscores often signal an internal-use column
281291 ):
282292 feature_name = (
283- self .input .field_mapping [col_name ]
284- if col_name in self .input .field_mapping .keys ()
293+ self .batch_source .field_mapping [col_name ]
294+ if col_name in self .batch_source .field_mapping .keys ()
285295 else col_name
286296 )
287297 self .features .append (
288298 Feature (
289299 feature_name ,
290- self .input .source_datatype_to_feast_value_type ()(
300+ self .batch_source .source_datatype_to_feast_value_type ()(
291301 col_datatype
292302 ),
293303 )
0 commit comments