Esempio n. 1
0
File: client.py Progetto: beoy/feast
    def _apply_entity(self, project: str, entity: Entity):
        """
        Registers a single entity with Feast

        Args:
            entity: Entity that will be registered
        """

        entity.is_valid()
        entity_proto = entity.to_spec_proto()

        # Convert the entity to a request and send to Feast Core
        try:
            apply_entity_response = self._core_service.ApplyEntity(
                ApplyEntityRequest(project=project, spec=entity_proto),  # type: ignore
                timeout=self._config.getint(CONFIG_GRPC_CONNECTION_TIMEOUT_DEFAULT_KEY),
                metadata=self._get_grpc_metadata(),
            )  # type: ApplyEntityResponse
        except grpc.RpcError as e:
            raise grpc.RpcError(e.details())

        # Extract the returned entity
        applied_entity = Entity.from_proto(apply_entity_response.entity)

        # Deep copy from the returned entity to the local entity
        entity._update_from_entity(applied_entity)
Esempio n. 2
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. 3
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()