Example #1
0
def construct_universal_feature_views(
    data_sources: Dict[str, DataSource], ) -> Dict[str, FeatureView]:
    driver_hourly_stats = create_driver_hourly_stats_feature_view(
        data_sources["driver"])
    return {
        "customer":
        create_customer_daily_profile_feature_view(data_sources["customer"]),
        "global":
        create_global_stats_feature_view(data_sources["global"]),
        "driver":
        driver_hourly_stats,
        "driver_odfv":
        conv_rate_plus_100_feature_view({
            "driver":
            driver_hourly_stats,
            "input_request":
            create_conv_rate_request_data_source(),
        }),
        "driver_age_request_fv":
        create_driver_age_request_feature_view(),
        "order":
        create_order_feature_view(data_sources["orders"]),
        "location":
        create_location_stats_feature_view(data_sources["location"]),
    }
def test_infer_odfv_features_with_error(environment, universal_data_sources):
    store = environment.feature_store

    (entities, datasets, data_sources) = universal_data_sources

    features = [Feature("conv_rate_plus_200", ValueType.DOUBLE)]
    driver_hourly_stats = create_driver_hourly_stats_feature_view(
        data_sources["driver"]
    )
    request_data_source = create_conv_rate_request_data_source()
    driver_odfv = conv_rate_plus_100_feature_view(
        {"driver": driver_hourly_stats, "input_request": request_data_source},
        features=features,
    )

    feast_objects = [driver_hourly_stats, driver_odfv, driver(), customer()]
    with pytest.raises(SpecifiedFeaturesNotPresentError):
        store.apply(feast_objects)
def test_infer_odfv_features(environment, universal_data_sources, infer_features):
    store = environment.feature_store

    (entities, datasets, data_sources) = universal_data_sources

    driver_hourly_stats = create_driver_hourly_stats_feature_view(
        data_sources["driver"]
    )
    request_data_source = create_conv_rate_request_data_source()
    driver_odfv = conv_rate_plus_100_feature_view(
        {"driver": driver_hourly_stats, "input_request": request_data_source},
        infer_features=infer_features,
    )

    feast_objects = [driver_hourly_stats, driver_odfv, driver(), customer()]
    store.apply(feast_objects)
    odfv = store.get_on_demand_feature_view("conv_rate_plus_100")
    assert len(odfv.features) == 2