A LabelView manages mutable labels decoupled from immutable feature data. A LabelView defines a mutable set of labels or annotations that are kept separate from the immutable feature data stored in regular FeatureViews. It supports multi-labeler workflows where different sources (human
| 26 | |
| 27 | @typechecked |
| 28 | class LabelView(BaseFeatureView): |
| 29 | """A LabelView manages mutable labels decoupled from immutable feature data. |
| 30 | |
| 31 | A LabelView defines a mutable set of labels or annotations that are kept |
| 32 | separate from the immutable feature data stored in regular FeatureViews. |
| 33 | It supports multi-labeler workflows where different sources (human reviewers, |
| 34 | automated safety scanners, reward models) can independently write labels for |
| 35 | the same entity keys. |
| 36 | |
| 37 | .. note:: |
| 38 | |
| 39 | **Enforcement scope:** |
| 40 | |
| 41 | - ``conflict_policy`` is enforced for **offline store reads** (training |
| 42 | data generation, UI browse/quality endpoints, batch pipelines). The |
| 43 | online store always uses LAST_WRITE_WINS for low-latency serving. |
| 44 | - The offline store always retains full write history (all writes are |
| 45 | appended). The online store keeps only the latest value per entity key. |
| 46 | |
| 47 | Attributes: |
| 48 | name: The unique name of the label view. |
| 49 | entities: The list of entity names associated with this label view. |
| 50 | ttl: How long labels are valid for online serving. ``timedelta(0)`` |
| 51 | means labels never expire. |
| 52 | source: The data source (typically a ``PushSource``) feeding label data. |
| 53 | entity_columns: The entity key columns in the schema. |
| 54 | features: The label columns (non-entity fields in the schema). |
| 55 | online: Whether labels are served from the online store. |
| 56 | description: A human-readable description. |
| 57 | tags: Arbitrary key-value metadata. |
| 58 | owner: Owner email or identifier. |
| 59 | labeler_field: Name of the schema field that identifies who wrote the |
| 60 | label (default ``"labeler"``). |
| 61 | conflict_policy: How conflicting labels from different labelers are |
| 62 | resolved (default ``ConflictPolicy.LAST_WRITE_WINS``). Enforced for |
| 63 | offline store reads (training, UI). Online store uses LAST_WRITE_WINS. |
| 64 | reference_feature_view: Optional name of the ``FeatureView`` whose |
| 65 | entities this label view annotates. |
| 66 | """ |
| 67 | |
| 68 | name: str |
| 69 | entities: List[str] |
| 70 | ttl: Optional[timedelta] |
| 71 | source: Optional[DataSource] |
| 72 | entity_columns: List[Field] |
| 73 | features: List[Field] |
| 74 | online: bool |
| 75 | description: str |
| 76 | tags: Dict[str, str] |
| 77 | owner: str |
| 78 | |
| 79 | labeler_field: str |
| 80 | conflict_policy: ConflictPolicy |
| 81 | reference_feature_view: Optional[str] |
| 82 | |
| 83 | def __init__( |
| 84 | self, |
| 85 | *, |
no outgoing calls