MCPcopy Index your code
hub / github.com/feast-dev/feast / apply_diff_to_registry

Function apply_diff_to_registry

sdk/python/feast/diff/registry_diff.py:314–425  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

312
313
314def 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 )

Callers 1

_apply_diffsMethod · 0.90

Calls 12

delete_entityMethod · 0.45
delete_feature_viewMethod · 0.45
delete_data_sourceMethod · 0.45
delete_permissionMethod · 0.45
apply_projectMethod · 0.45
apply_data_sourceMethod · 0.45
apply_entityMethod · 0.45
apply_feature_serviceMethod · 0.45
apply_feature_viewMethod · 0.45
apply_permissionMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected