Updates the specific feature in place with inferred features and entities. Args: fv: The feature view on which to run inference. join_keys: The set of join keys for the feature view's entities. run_inference_for_features: Whether to run inference for features.
(
provider: Provider,
fv: Union[FeatureView, OnDemandFeatureView],
join_keys: Set[Optional[str]],
run_inference_for_features,
config,
)
| 201 | |
| 202 | |
| 203 | def _infer_features_and_entities( |
| 204 | provider: Provider, |
| 205 | fv: Union[FeatureView, OnDemandFeatureView], |
| 206 | join_keys: Set[Optional[str]], |
| 207 | run_inference_for_features, |
| 208 | config, |
| 209 | ) -> None: |
| 210 | """ |
| 211 | Updates the specific feature in place with inferred features and entities. |
| 212 | |
| 213 | Args: |
| 214 | fv: The feature view on which to run inference. |
| 215 | join_keys: The set of join keys for the feature view's entities. |
| 216 | run_inference_for_features: Whether to run inference for features. |
| 217 | config: The config for the current feature store. |
| 218 | """ |
| 219 | if isinstance(fv, OnDemandFeatureView): |
| 220 | return _infer_on_demand_features_and_entities( |
| 221 | fv, join_keys, run_inference_for_features, config |
| 222 | ) |
| 223 | |
| 224 | if fv.batch_source is None: |
| 225 | return |
| 226 | |
| 227 | entity_columns: List[Field] = fv.entity_columns if fv.entity_columns else [] |
| 228 | columns_to_exclude = { |
| 229 | fv.batch_source.timestamp_field, |
| 230 | fv.batch_source.created_timestamp_column, |
| 231 | } |
| 232 | for original_col, mapped_col in fv.batch_source.field_mapping.items(): |
| 233 | if mapped_col in columns_to_exclude: |
| 234 | columns_to_exclude.remove(mapped_col) |
| 235 | columns_to_exclude.add(original_col) |
| 236 | |
| 237 | table_column_names_and_types = ( |
| 238 | provider.get_table_column_names_and_types_from_data_source( |
| 239 | config, fv.batch_source |
| 240 | ) |
| 241 | ) |
| 242 | |
| 243 | for col_name, col_datatype in table_column_names_and_types: |
| 244 | if col_name in columns_to_exclude: |
| 245 | continue |
| 246 | elif col_name in join_keys: |
| 247 | field = Field( |
| 248 | name=col_name, |
| 249 | dtype=from_value_type( |
| 250 | fv.batch_source.source_datatype_to_feast_value_type()(col_datatype) |
| 251 | ), |
| 252 | ) |
| 253 | if field.name not in [ |
| 254 | entity_column.name for entity_column in fv.entity_columns |
| 255 | ]: |
| 256 | entity_columns.append(field) |
| 257 | elif not re.match( |
| 258 | "^__|__$", col_name |
| 259 | ): # double underscores often signal an internal-use column |
| 260 | if run_inference_for_features: |
no test coverage detected