Exemplo n.º 1
0
def _ingest_test_getfeaturetable_mocked_resp(file_url: str,
                                             date_partition_col: str = None):
    return GetFeatureTableResponse(table=FeatureTableProto(
        spec=FeatureTableSpecProto(
            name="ingest_featuretable",
            max_age=Duration(seconds=3600),
            features=[
                FeatureSpecProto(
                    name="dev_feature_float",
                    value_type=ValueProto.ValueType.FLOAT,
                ),
                FeatureSpecProto(
                    name="dev_feature_string",
                    value_type=ValueProto.ValueType.STRING,
                ),
            ],
            entities=["dev_entity"],
            batch_source=DataSourceProto(
                file_options=DataSourceProto.FileOptions(
                    file_format=ParquetFormat().to_proto(), file_url=file_url),
                event_timestamp_column="datetime",
                created_timestamp_column="timestamp",
                date_partition_column=date_partition_col
                if date_partition_col is not None else None,
            ),
        ),
        meta=FeatureTableMetaProto(),
    ))
Exemplo n.º 2
0
    def to_spec_proto(self) -> FeatureTableSpecProto:
        """
        Converts an FeatureTableProto object to its protobuf representation.
        Used when passing FeatureTableSpecProto object to Feast request.

        Returns:
            FeatureTableSpecProto protobuf
        """

        spec = FeatureTableSpecProto(
            name=self.name,
            entities=self.entities,
            features=[
                feature.to_proto() if type(feature) == Feature else feature
                for feature in self.features
            ],
            labels=self.labels,
            max_age=self.max_age,
            batch_source=(self.batch_source.to_proto() if issubclass(
                type(self.batch_source), DataSource) else self.batch_source),
            stream_source=(self.stream_source.to_proto() if issubclass(
                type(self.stream_source), DataSource) else self.stream_source),
        )

        return spec
Exemplo n.º 3
0
    def to_proto(self) -> FeatureTableProto:
        """
        Converts an feature table object to its protobuf representation

        Returns:
            FeatureTableProto protobuf
        """

        meta = FeatureTableMetaProto(
            created_timestamp=self.created_timestamp,
            last_updated_timestamp=self.last_updated_timestamp,
        )

        spec = FeatureTableSpecProto(
            name=self.name,
            entities=self.entities,
            features=[
                feature.to_proto() if type(feature) == Feature else feature
                for feature in self.features
            ],
            labels=self.labels,
            max_age=self.max_age,
            batch_source=(self.batch_source.to_proto() if issubclass(
                type(self.batch_source), DataSource) else self.batch_source),
            stream_source=(self.stream_source.to_proto() if issubclass(
                type(self.stream_source), DataSource) else self.stream_source),
        )

        return FeatureTableProto(spec=spec, meta=meta)
Exemplo n.º 4
0
    def to_spec_proto(self) -> FeatureTableSpecProto:
        """
        Converts an FeatureTableProto object to its protobuf representation.
        Used when passing FeatureTableSpecProto object to Feast request.

        Returns:
            FeatureTableSpecProto protobuf
        """

        spec = FeatureTableSpecProto(
            name=self.name,
            entities=self.entities,
            features=self.features,
            labels=self.labels,
            max_age=self.max_age,
            batch_source=self.batch_source,
            stream_source=self.stream_source,
        )

        return spec
Exemplo n.º 5
0
    def to_proto(self) -> FeatureTableProto:
        """
        Converts an feature table object to its protobuf representation

        Returns:
            FeatureTableProto protobuf
        """

        meta = FeatureTableMetaProto(
            created_timestamp=self.created_timestamp,
            last_updated_timestamp=self.last_updated_timestamp,
        )

        spec = FeatureTableSpecProto(
            name=self.name,
            entities=self.entities,
            features=self.features,
            labels=self.labels,
            max_age=self.max_age,
            batch_source=self.batch_source,
            stream_source=self.stream_source,
        )

        return FeatureTableProto(spec=spec, meta=meta)