Exemple #1
0
    def test_register_feature_set(self, sqlite_store):
        fs = FeatureSet("my-feature-set")
        fs.add(Feature(name="my-feature-1", dtype=ValueType.INT64))
        fs.add(Feature(name="my-feature-2", dtype=ValueType.INT64))
        fs.add(Entity(name="my-entity-1", dtype=ValueType.INT64))
        fs._version = 1
        feature_set_spec_proto = fs.to_proto().spec

        sqlite_store.register_feature_set(feature_set_spec_proto)
        feature_row = FeatureRowProto.FeatureRow(
            feature_set="feature_set_1",
            event_timestamp=Timestamp(),
            fields=[
                FieldProto.Field(
                    name="feature_1", value=ValueProto.Value(float_val=1.2)
                ),
                FieldProto.Field(
                    name="feature_2", value=ValueProto.Value(float_val=1.2)
                ),
                FieldProto.Field(
                    name="feature_3", value=ValueProto.Value(float_val=1.2)
                ),
            ],
        )
        # sqlite_store.upsert_feature_row(feature_set_proto, feature_row)
        assert True
Exemple #2
0
def convert_dict_to_proto_values(row: dict,
                                 df_datetime_dtype: pd.DataFrame.dtypes,
                                 feature_set) -> FeatureRowProto.FeatureRow:
    """
    Encode a dictionary describing a feature row into a FeatureRows object.

    Args:
        row: Dictionary describing a feature row.
        df_datetime_dtype:  Pandas dtype of datetime column.
        feature_set: Feature set describing feature row.

    Returns:
        FeatureRow
    """

    feature_row = FeatureRowProto.FeatureRow(
        event_timestamp=_pd_datetime_to_timestamp_proto(
            df_datetime_dtype, row[DATETIME_COLUMN]),
        feature_set=feature_set.project + "/" + feature_set.name + ":" +
        str(feature_set.version),
    )

    for field_name, field in feature_set.fields.items():
        feature_row.fields.extend([
            FieldProto.Field(
                name=field.name,
                value=_python_value_to_proto_value(field.dtype,
                                                   row[field.name]),
            )
        ])
    return feature_row
Exemple #3
0
    def convert_series_to_proto_values(row: pd.Series):
        """
        Converts a Pandas Series to a Feast FeatureRow

        Args:
            row: pd.Series The row that should be converted

        Returns:
            Feast FeatureRow
        """

        feature_row = FeatureRowProto.FeatureRow(
            event_timestamp=_pd_datetime_to_timestamp_proto(
                dataframe[DATETIME_COLUMN].dtype, row[DATETIME_COLUMN]),
            feature_set=feature_set.name + ":" + str(feature_set.version),
        )

        for field_name, field in feature_set.fields.items():
            feature_row.fields.extend([
                FieldProto.Field(
                    name=field.name,
                    value=_python_value_to_proto_value(field.dtype,
                                                       row[field.name]),
                )
            ])
        return feature_row
Exemple #4
0
    def convert_series_to_proto_values(row: pd.Series):
        feature_row = FeatureRowProto.FeatureRow(
            event_timestamp=pd_datetime_to_timestamp_proto(
                dataframe[DATETIME_COLUMN].dtype, row[DATETIME_COLUMN]),
            feature_set=feature_set.name + ":" + str(feature_set.version),
        )

        for field_name, field in feature_set.fields.items():
            feature_row.fields.extend([
                FieldProto.Field(
                    name=field.name,
                    value=pd_value_to_proto_value(field.dtype,
                                                  row[field.name]),
                )
            ])
        return feature_row
    def GetOnlineFeatures(self, request: GetOnlineFeaturesRequest, context):

        response = GetOnlineFeaturesResponse(feature_data_sets=[
            GetOnlineFeaturesResponse.FeatureDataSet(
                name="feature_set_1",
                feature_rows=[
                    FeatureRowProto.FeatureRow(
                        feature_set="feature_set_1",
                        event_timestamp=Timestamp(),
                        fields=[
                            FieldProto.Field(
                                name="feature_1",
                                value=ValueProto.Value(float_val=1.2),
                            ),
                            FieldProto.Field(
                                name="feature_2",
                                value=ValueProto.Value(float_val=1.2),
                            ),
                            FieldProto.Field(
                                name="feature_3",
                                value=ValueProto.Value(float_val=1.2),
                            ),
                        ],
                    ),
                    FeatureRowProto.FeatureRow(
                        feature_set="feature_set_1",
                        event_timestamp=Timestamp(),
                        fields=[
                            FieldProto.Field(
                                name="feature_1",
                                value=ValueProto.Value(float_val=1.2),
                            ),
                            FieldProto.Field(
                                name="feature_2",
                                value=ValueProto.Value(float_val=1.2),
                            ),
                            FieldProto.Field(
                                name="feature_3",
                                value=ValueProto.Value(float_val=1.2),
                            ),
                        ],
                    ),
                    FeatureRowProto.FeatureRow(
                        feature_set="feature_set_1",
                        event_timestamp=Timestamp(),
                        fields=[
                            FieldProto.Field(
                                name="feature_1",
                                value=ValueProto.Value(float_val=1.2),
                            ),
                            FieldProto.Field(
                                name="feature_2",
                                value=ValueProto.Value(float_val=1.2),
                            ),
                            FieldProto.Field(
                                name="feature_3",
                                value=ValueProto.Value(float_val=1.2),
                            ),
                        ],
                    ),
                ],
            )
        ])

        return response