Applies the given diff to the given Feast project in the registry. Args: registry: The registry to be updated. registry_diff: The diff to apply. project: Feast project to be updated. commit: Whether the change should be persisted immediately
(
registry: BaseRegistry,
registry_diff: RegistryDiff,
project: str,
commit: bool = True,
no_promote: bool = False,
)
| 312 | |
| 313 | |
| 314 | def apply_diff_to_registry( |
| 315 | registry: BaseRegistry, |
| 316 | registry_diff: RegistryDiff, |
| 317 | project: str, |
| 318 | commit: bool = True, |
| 319 | no_promote: bool = False, |
| 320 | ): |
| 321 | """ |
| 322 | Applies the given diff to the given Feast project in the registry. |
| 323 | |
| 324 | Args: |
| 325 | registry: The registry to be updated. |
| 326 | registry_diff: The diff to apply. |
| 327 | project: Feast project to be updated. |
| 328 | commit: Whether the change should be persisted immediately |
| 329 | no_promote: If True, save new feature view version snapshots without |
| 330 | promoting them to the active definition. New versions are accessible |
| 331 | only via explicit @v<N> reads. |
| 332 | """ |
| 333 | for feast_object_diff in registry_diff.feast_object_diffs: |
| 334 | # There is no need to delete the object on an update, since applying the new object |
| 335 | # will automatically delete the existing object. |
| 336 | if feast_object_diff.transition_type == TransitionType.DELETE: |
| 337 | if feast_object_diff.feast_object_type == FeastObjectType.ENTITY: |
| 338 | entity_obj = cast(Entity, feast_object_diff.current_feast_object) |
| 339 | registry.delete_entity(entity_obj.name, project, commit=False) |
| 340 | elif feast_object_diff.feast_object_type == FeastObjectType.FEATURE_SERVICE: |
| 341 | feature_service_obj = cast( |
| 342 | FeatureService, feast_object_diff.current_feast_object |
| 343 | ) |
| 344 | registry.delete_feature_service( |
| 345 | feature_service_obj.name, project, commit=False |
| 346 | ) |
| 347 | elif feast_object_diff.feast_object_type in [ |
| 348 | FeastObjectType.FEATURE_VIEW, |
| 349 | FeastObjectType.ON_DEMAND_FEATURE_VIEW, |
| 350 | FeastObjectType.STREAM_FEATURE_VIEW, |
| 351 | FeastObjectType.LABEL_VIEW, |
| 352 | ]: |
| 353 | feature_view_obj = cast( |
| 354 | BaseFeatureView, feast_object_diff.current_feast_object |
| 355 | ) |
| 356 | registry.delete_feature_view( |
| 357 | feature_view_obj.name, |
| 358 | project, |
| 359 | commit=False, |
| 360 | ) |
| 361 | elif feast_object_diff.feast_object_type == FeastObjectType.DATA_SOURCE: |
| 362 | ds_obj = cast(DataSource, feast_object_diff.current_feast_object) |
| 363 | registry.delete_data_source( |
| 364 | ds_obj.name, |
| 365 | project, |
| 366 | commit=False, |
| 367 | ) |
| 368 | elif feast_object_diff.feast_object_type == FeastObjectType.PERMISSION: |
| 369 | permission_obj = cast( |
| 370 | Permission, feast_object_diff.current_feast_object |
| 371 | ) |
no test coverage detected