|
14 | 14 |
|
15 | 15 |
|
16 | 16 | import enum |
| 17 | +import warnings |
17 | 18 | from abc import ABC, abstractmethod |
18 | 19 | from typing import Any, Callable, Dict, Iterable, Optional, Tuple |
19 | 20 |
|
@@ -160,14 +161,34 @@ class DataSource(ABC): |
160 | 161 |
|
161 | 162 | def __init__( |
162 | 163 | self, |
163 | | - name: str, |
164 | 164 | event_timestamp_column: Optional[str] = None, |
165 | 165 | created_timestamp_column: Optional[str] = None, |
166 | 166 | field_mapping: Optional[Dict[str, str]] = None, |
167 | 167 | date_partition_column: Optional[str] = None, |
| 168 | + name: Optional[str] = None, |
168 | 169 | ): |
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 "" |
171 | 192 | self.event_timestamp_column = ( |
172 | 193 | event_timestamp_column if event_timestamp_column else "" |
173 | 194 | ) |
@@ -321,11 +342,11 @@ def __init__( |
321 | 342 | date_partition_column: Optional[str] = "", |
322 | 343 | ): |
323 | 344 | 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, |
329 | 350 | ) |
330 | 351 | self.kafka_options = KafkaOptions( |
331 | 352 | bootstrap_servers=bootstrap_servers, |
@@ -402,7 +423,7 @@ def __init__( |
402 | 423 | self, name: str, schema: Dict[str, ValueType], |
403 | 424 | ): |
404 | 425 | """Creates a RequestDataSource object.""" |
405 | | - super().__init__(name) |
| 426 | + super().__init__(name=name) |
406 | 427 | self.schema = schema |
407 | 428 |
|
408 | 429 | def validate(self, config: RepoConfig): |
@@ -485,11 +506,11 @@ def __init__( |
485 | 506 | date_partition_column: Optional[str] = "", |
486 | 507 | ): |
487 | 508 | 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, |
493 | 514 | ) |
494 | 515 | self.kinesis_options = KinesisOptions( |
495 | 516 | record_format=record_format, region=region, stream_name=stream_name |
|
0 commit comments