def _create_feature(column, entity, granularity, owner, serving_store, warehouse_store): """Create Feature object. Args: column (pandas.Series): data column entity (str): entity name granularity (feast.types.Granularity_pb2.Granularity): granularity of the feature owner (str): owner of the feature serving_store (feast.sdk.resources.feature.DataStore): Defaults to None. Serving store to write the features in this instance to. warehouse_store (feast.sdk.resources.feature.DataStore): Defaults to None. Warehouse store to write the features in this instance to. Returns: feast.sdk.resources.Feature: feature for this data column """ feature = Feature(name=column.name, entity=entity, granularity=granularity, owner=owner, value_type=dtype_to_value_type(column.dtype)) if serving_store is not None: feature.serving_store = serving_store if warehouse_store is not None: feature.warehouse_store = warehouse_store return feature
def dummy_feature(self): my_feature = Feature(name="my_feature", entity="my_entity", value_type=ValueType.BYTES, owner="*****@*****.**", description="test feature", uri="github.com/feature_repo") return my_feature
def test_create_feature(self): col = pd.Series([1] * 3, dtype='int32', name="test") expected = Feature(name="test", entity="test", owner="person", value_type=ValueType.INT32) actual = _create_feature(col, "test", "person", None, None) assert actual.id == expected.id assert actual.value_type == expected.value_type assert actual.owner == expected.owner
def test_apply_single_feature(self, client, mocker): my_feature = Feature(name="test", entity="test", granularity=Granularity.NONE) grpc_stub = core.CoreServiceStub(grpc.insecure_channel("")) with mocker.patch.object(grpc_stub, 'ApplyFeature', return_value=CoreServiceTypes.ApplyFeatureResponse( featureId="test.none.test")): client._core_service_stub = grpc_stub id = client.apply(my_feature) assert id == "test.none.test"
def dummy_feature(self): warehouse_data_store = Datastore(id="BIGQUERY1", options={}) serving_data_store = Datastore(id="REDIS1", options={}) my_feature = Feature(name="my_feature", entity="my_entity", value_type=ValueType.BYTES, owner="*****@*****.**", description="test feature", uri="github.com/feature_repo", warehouse_store=warehouse_data_store, serving_store=serving_data_store) return my_feature
def test_create_feature_with_stores(self): col = pd.Series([1] * 3, dtype='int32', name="test") expected = Feature(name="test", entity="test", owner="person", value_type=ValueType.INT32, serving_store=Datastore(id="SERVING"), warehouse_store=Datastore(id="WAREHOUSE")) actual = _create_feature(col, "test", "person", Datastore(id="SERVING"), Datastore(id="WAREHOUSE")) assert actual.id == expected.id assert actual.value_type == expected.value_type assert actual.owner == expected.owner assert actual.serving_store == expected.serving_store assert actual.warehouse_store == expected.warehouse_store