Example #1
0
    def apply_feature_view(self, feature_view: FeatureView, project: str):
        """
        Registers a single feature view with Feast

        Args:
            feature_view: Feature view that will be registered
            project: Feast project that this feature view belongs to
        """
        feature_view.is_valid()
        feature_view_proto = feature_view.to_proto()
        feature_view_proto.spec.project = project

        def updater(registry_proto: RegistryProto):
            for idx, existing_feature_view_proto in enumerate(
                registry_proto.feature_views
            ):
                if (
                    existing_feature_view_proto.spec.name
                    == feature_view_proto.spec.name
                    and existing_feature_view_proto.spec.project == project
                ):
                    # do not update if feature view has not changed; updating will erase tracked materialization intervals
                    if (
                        FeatureView.from_proto(existing_feature_view_proto)
                        == feature_view
                    ):
                        return registry_proto
                    else:
                        del registry_proto.feature_views[idx]
                        registry_proto.feature_views.append(feature_view_proto)
                        return registry_proto
            registry_proto.feature_views.append(feature_view_proto)
            return registry_proto

        self._registry_store.update_registry_proto(updater)
Example #2
0
    def apply_feature_view(self, feature_view: FeatureView, project: str):
        """
        Registers a single feature view with Feast

        Args:
            feature_view: Feature view that will be registered
            project: Feast project that this feature view belongs to
        """
        feature_view.is_valid()
        feature_view_proto = feature_view.to_proto()
        feature_view_proto.spec.project = project

        def updater(registry_proto: RegistryProto):
            for idx, existing_feature_view_proto in enumerate(
                    registry_proto.feature_views):
                if (existing_feature_view_proto.spec.name
                        == feature_view_proto.spec.name and
                        existing_feature_view_proto.spec.project == project):
                    del registry_proto.feature_views[idx]
                    registry_proto.feature_views.append(feature_view_proto)
                    return registry_proto
            registry_proto.feature_views.append(feature_view_proto)
            return registry_proto

        self._registry_store.update_registry(updater)
Example #3
0
    def apply_feature_view(self,
                           feature_view: FeatureView,
                           project: str,
                           commit: bool = True):
        """
        Registers a single feature view with Feast

        Args:
            feature_view: Feature view that will be registered
            project: Feast project that this feature view belongs to
            commit: Whether the change should be persisted immediately
        """
        feature_view.is_valid()
        feature_view_proto = feature_view.to_proto()
        feature_view_proto.spec.project = project
        self._prepare_registry_for_changes()
        assert self.cached_registry_proto

        for idx, existing_feature_view_proto in enumerate(
                self.cached_registry_proto.feature_views):
            if (existing_feature_view_proto.spec.name
                    == feature_view_proto.spec.name
                    and existing_feature_view_proto.spec.project == project):
                if FeatureView.from_proto(
                        existing_feature_view_proto) == feature_view:
                    return
                else:
                    del self.cached_registry_proto.feature_views[idx]
                    break

        self.cached_registry_proto.feature_views.append(feature_view_proto)
        if commit:
            self.commit()