Esempio n. 1
0
    def apply_entity(self, entity: Entity, project: str):
        """
        Registers a single entity with Feast

        Args:
            entity: Entity that will be registered
            project: Feast project that this entity belongs to
        """
        entity.is_valid()
        entity_proto = entity.to_proto()
        entity_proto.spec.project = project

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

        self._registry_store.update_registry(updater)
        return
Esempio n. 2
0
    def apply_entity(self, entity: Entity, project: str, commit: bool = True):
        """
        Registers a single entity with Feast

        Args:
            entity: Entity that will be registered
            project: Feast project that this entity belongs to
            commit: Whether the change should be persisted immediately
        """
        entity.is_valid()
        entity_proto = entity.to_proto()
        entity_proto.spec.project = project
        self._prepare_registry_for_changes()
        assert self.cached_registry_proto

        for idx, existing_entity_proto in enumerate(
                self.cached_registry_proto.entities):
            if (existing_entity_proto.spec.name == entity_proto.spec.name
                    and existing_entity_proto.spec.project == project):
                del self.cached_registry_proto.entities[idx]
                break

        self.cached_registry_proto.entities.append(entity_proto)
        if commit:
            self.commit()