|
1 | | -from datetime import timedelta |
2 | | -from typing import Dict, List, Optional, Union |
| 1 | +import warnings |
| 2 | +from datetime import datetime, timedelta |
| 3 | +from typing import Dict, List, Optional, Tuple, Union |
3 | 4 |
|
| 5 | +from feast import flags_helper |
4 | 6 | from feast.data_source import DataSource |
5 | 7 | from feast.entity import Entity |
6 | 8 | from feast.feature_view import FeatureView |
7 | 9 | from feast.field import Field |
8 | 10 | from feast.protos.feast.core.DataSource_pb2 import DataSource as DataSourceProto |
9 | 11 |
|
| 12 | +warnings.simplefilter("once", RuntimeWarning) |
| 13 | + |
10 | 14 | SUPPORTED_BATCH_SOURCES = { |
11 | 15 | "BigQuerySource", |
12 | 16 | "FileSource", |
|
19 | 23 |
|
20 | 24 |
|
21 | 25 | class BatchFeatureView(FeatureView): |
| 26 | + """ |
| 27 | + A batch feature view defines a logical group of features that has only a batch data source. |
| 28 | +
|
| 29 | + Attributes: |
| 30 | + name: The unique name of the batch feature view. |
| 31 | + entities: List of entities or entity join keys. |
| 32 | + ttl: The amount of time this group of features lives. A ttl of 0 indicates that |
| 33 | + this group of features lives forever. Note that large ttl's or a ttl of 0 |
| 34 | + can result in extremely computationally intensive queries. |
| 35 | + schema: The schema of the feature view, including feature, timestamp, and entity |
| 36 | + columns. If not specified, can be inferred from the underlying data source. |
| 37 | + source: The batch source of data where this group of features is stored. |
| 38 | + online: A boolean indicating whether online retrieval is enabled for this feature view. |
| 39 | + description: A human-readable description. |
| 40 | + tags: A dictionary of key-value pairs to store arbitrary metadata. |
| 41 | + owner: The owner of the batch feature view, typically the email of the primary maintainer. |
| 42 | + """ |
| 43 | + |
| 44 | + name: str |
| 45 | + entities: List[str] |
| 46 | + ttl: Optional[timedelta] |
| 47 | + source: DataSource |
| 48 | + schema: List[Field] |
| 49 | + entity_columns: List[Field] |
| 50 | + features: List[Field] |
| 51 | + online: bool |
| 52 | + description: str |
| 53 | + tags: Dict[str, str] |
| 54 | + owner: str |
| 55 | + timestamp_field: str |
| 56 | + materialization_intervals: List[Tuple[datetime, datetime]] |
| 57 | + |
22 | 58 | def __init__( |
23 | 59 | self, |
24 | 60 | *, |
25 | | - name: Optional[str] = None, |
| 61 | + name: str, |
| 62 | + source: DataSource, |
26 | 63 | entities: Optional[Union[List[Entity], List[str]]] = None, |
27 | 64 | ttl: Optional[timedelta] = None, |
28 | 65 | tags: Optional[Dict[str, str]] = None, |
29 | 66 | online: bool = True, |
30 | 67 | description: str = "", |
31 | 68 | owner: str = "", |
32 | 69 | schema: Optional[List[Field]] = None, |
33 | | - source: Optional[DataSource] = None, |
34 | 70 | ): |
| 71 | + if not flags_helper.is_test(): |
| 72 | + warnings.warn( |
| 73 | + "Batch feature views are experimental features in alpha development. " |
| 74 | + "Some functionality may still be unstable so functionality can change in the future.", |
| 75 | + RuntimeWarning, |
| 76 | + ) |
35 | 77 |
|
36 | | - if source is None: |
37 | | - raise ValueError("Feature views need a source specified") |
38 | 78 | if ( |
39 | 79 | type(source).__name__ not in SUPPORTED_BATCH_SOURCES |
40 | 80 | and source.to_proto().type != DataSourceProto.SourceType.CUSTOM_SOURCE |
|
0 commit comments