Ejemplo n.º 1
0
Archivo: client.py Proyecto: beoy/feast
    def _apply_feature_table(self, project: str, feature_table: FeatureTable):
        """
        Registers a single feature table with Feast

        Args:
            feature_table: Feature table that will be registered
        """

        feature_table.is_valid()
        feature_table_proto = feature_table.to_spec_proto()

        # Convert the feature table to a request and send to Feast Core
        try:
            apply_feature_table_response = self._core_service.ApplyFeatureTable(
                ApplyFeatureTableRequest(project=project, table_spec=feature_table_proto),  # type: ignore
                timeout=self._config.getint(CONFIG_GRPC_CONNECTION_TIMEOUT_DEFAULT_KEY),
                metadata=self._get_grpc_metadata(),
            )  # type: ApplyFeatureTableResponse
        except grpc.RpcError as e:
            raise grpc.RpcError(e.details())

        # Extract the returned feature table
        applied_feature_table = FeatureTable.from_proto(
            apply_feature_table_response.table
        )

        # Deep copy from the returned feature table to the local entity
        feature_table._update_from_feature_table(applied_feature_table)
Ejemplo n.º 2
0
    def apply_feature_table(self, feature_table: FeatureTable, project: str):
        """
        Registers a single feature table with Feast

        Args:
            feature_table: Feature table that will be registered
            project: Feast project that this feature table belongs to
        """
        feature_table.is_valid()
        feature_table_proto = feature_table.to_proto()
        feature_table_proto.spec.project = project

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

        self._registry_store.update_registry(updater)
        return
Ejemplo n.º 3
0
    def apply_feature_table(self,
                            feature_table: FeatureTable,
                            project: str,
                            commit: bool = True):
        """
        Registers a single feature table with Feast

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

        for idx, existing_feature_table_proto in enumerate(
                self.cached_registry_proto.feature_tables):
            if (existing_feature_table_proto.spec.name
                    == feature_table_proto.spec.name
                    and existing_feature_table_proto.spec.project == project):
                del self.cached_registry_proto.feature_tables[idx]
                break

        self.cached_registry_proto.feature_tables.append(feature_table_proto)
        if commit:
            self.commit()