Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
Update tests, fix concat vs join bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ykeremy committed Oct 12, 2023
1 parent 837351b commit 208ff88
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 242 deletions.
22 changes: 17 additions & 5 deletions examples/real_time_features_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,27 @@ async def execute(
)

time_start = time()
feature_map = await self.feature_retrieval_pipeline.execute(request)
feature_df = await self.feature_retrieval_pipeline.execute(request)
logger.info(f"operation feature_retrieval took:{time()-time_start:2.4f} sec")
profiler.stop()
profiler.print()
feature_dicts = feature_df.df.to_dicts()
feature_data: Dict[str, FeatureData] = {
str(feature_dict["IDENTIFIER"]): FeatureData(
identifier=Identifier(
identifier_type=feature_dict["IDENTIFIER"].split("::")[0],
identifier=feature_dict["IDENTIFIER"].split("::")[1],
),
features={
feature_name: feature_value
for feature_name, feature_value in feature_dict.items()
if feature_name != "IDENTIFIER"
},
)
for feature_dict in feature_dicts
}
return FeatureStoreResponse(
feature_data={
str(identifier): feature_map.feature_map[identifier]
for identifier in feature_map.feature_map.keys()
},
feature_data=feature_data,
)


Expand Down
272 changes: 77 additions & 195 deletions tests/feature_store/test_real_time_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,112 +69,60 @@ async def test_end_to_end(mock_redis, test_client, mock_feature_store):
"identifier_type": "request",
},
"features": {
"RealTimeNumberOfCandidatesFeature:f_number_of_candidates": 3.0,
"RealTimeNumberOfCandidatesFeature__f_number_of_candidates": 3.0,
},
},
"query::candle": {
"identifier": {"identifier": "candle", "identifier_type": "query"},
"features": {
"RealTimeQueryFeature:f_query_length": 6.0,
"RealTimeStringFeature:f_query": "candle",
"RealTimeEmbeddingFeature:f_query_embedding_vector_8": [
1,
2,
3,
4,
5,
6,
7,
8,
"RealTimeQueryFeature__f_query_length": 6.0,
"RealTimeStringFeature__f_query": "candle",
"RealTimeEmbeddingFeature__f_query_embedding_vector_8": [
1.0,
2.0,
3.0,
4.0,
5.0,
6.0,
7.0,
8.0,
],
"RealTimeUserQueryFeature__f_user_query_name_edit_distance": 3.0,
"RealTimeUserQueryFeature__f_user_query_name_jaccard_similarity": -3.0,
},
},
"user::1234": {
"identifier": {"identifier": "1234", "identifier_type": "user"},
"features": {"RealTimeUserFeature:f_user_name_length": 9.0},
},
"query:user::candle:1234": {
"identifier": {
"identifier": "candle:1234",
"identifier_type": "query:user",
},
"features": {
"RealTimeUserQueryFeature:f_user_query_name_edit_distance": 3.0,
"RealTimeUserQueryFeature:f_user_query_name_jaccard_similarity": -3.0,
},
"features": {"RealTimeUserFeature__f_user_name_length": 9.0},
},
"product::p1": {
"identifier": {"identifier": "p1", "identifier_type": "product"},
"features": {"RealTimeProductFeature:f_opensearch_score": 1.0},
},
"product::p2": {
"identifier": {"identifier": "p2", "identifier_type": "product"},
"features": {},
},
"product::p3": {
"identifier": {"identifier": "p3", "identifier_type": "product"},
"features": {},
},
"product:query::p1:candle": {
"identifier": {
"identifier": "p1:candle",
"identifier_type": "product:query",
},
"features": {
"RealTimeMatchedQueriesProductFeature:f_matched_queries_QUERY_1": 1.0,
"RealTimeMatchedQueriesProductFeature:f_matched_queries_QUERY_2": 1.0,
"RealTimeQueryProductFeature:f_query_product_name_edit_distance": 4.0,
"RealTimeQueryProductFeature:f_query_product_name_jaccard_similarity": -4.0,
"RealTimeMatchedQueriesProductFeature__f_matched_queries_QUERY_1": 1.0,
"RealTimeMatchedQueriesProductFeature__f_matched_queries_QUERY_2": 1.0,
"RealTimeProductFeature__f_opensearch_score": 1.0,
"RealTimeQueryProductFeature__f_query_product_name_edit_distance": 4.0,
"RealTimeQueryProductFeature__f_query_product_name_jaccard_similarity": -4.0,
"RealTimeUserProductFeature__f_user_product_name_edit_distance": 7.0,
"RealTimeUserProductFeature__f_user_product_name_jaccard_similarity": -7.0,
},
},
"product:query::p2:candle": {
"identifier": {
"identifier": "p2:candle",
"identifier_type": "product:query",
},
"features": {
"RealTimeQueryProductFeature:f_query_product_name_edit_distance": 4.0,
"RealTimeQueryProductFeature:f_query_product_name_jaccard_similarity": -4.0,
},
},
"product:query::p3:candle": {
"identifier": {
"identifier": "p3:candle",
"identifier_type": "product:query",
},
"features": {
"RealTimeQueryProductFeature:f_query_product_name_edit_distance": 4.0,
"RealTimeQueryProductFeature:f_query_product_name_jaccard_similarity": -4.0,
},
},
"product:user::p1:1234": {
"identifier": {
"identifier": "p1:1234",
"identifier_type": "product:user",
},
"features": {
"RealTimeUserProductFeature:f_user_product_name_edit_distance": 7.0,
"RealTimeUserProductFeature:f_user_product_name_jaccard_similarity": -7.0,
},
},
"product:user::p2:1234": {
"identifier": {
"identifier": "p2:1234",
"identifier_type": "product:user",
},
"product::p2": {
"identifier": {"identifier": "p2", "identifier_type": "product"},
"features": {
"RealTimeUserProductFeature:f_user_product_name_edit_distance": 7.0,
"RealTimeUserProductFeature:f_user_product_name_jaccard_similarity": -7.0,
"RealTimeQueryProductFeature__f_query_product_name_edit_distance": 4.0,
"RealTimeQueryProductFeature__f_query_product_name_jaccard_similarity": -4.0,
"RealTimeUserProductFeature__f_user_product_name_edit_distance": 7.0,
"RealTimeUserProductFeature__f_user_product_name_jaccard_similarity": -7.0,
},
},
"product:user::p3:1234": {
"identifier": {
"identifier": "p3:1234",
"identifier_type": "product:user",
},
"product::p3": {
"identifier": {"identifier": "p3", "identifier_type": "product"},
"features": {
"RealTimeUserProductFeature:f_user_product_name_edit_distance": 7.0,
"RealTimeUserProductFeature:f_user_product_name_jaccard_similarity": -7.0,
"RealTimeQueryProductFeature__f_query_product_name_edit_distance": 4.0,
"RealTimeQueryProductFeature__f_query_product_name_jaccard_similarity": -4.0,
"RealTimeUserProductFeature__f_user_product_name_edit_distance": 7.0,
"RealTimeUserProductFeature__f_user_product_name_jaccard_similarity": -7.0,
},
},
},
Expand Down Expand Up @@ -225,138 +173,72 @@ async def test_end_to_end__2(mock_redis__2, test_client):
"identifier_type": "request",
},
"features": {
"RealTimeNumberOfCandidatesFeature:f_number_of_candidates": 4.0,
"RealTimeNumberOfCandidatesFeature__f_number_of_candidates": 4.0,
},
},
"query::candle": {
"identifier": {"identifier": "candle", "identifier_type": "query"},
"features": {
"RealTimeQueryFeature:f_query_length": 6.0,
"RealTimeStringFeature:f_query": "candle",
"RealTimeEmbeddingFeature:f_query_embedding_vector_8": [
1,
2,
3,
4,
5,
6,
7,
8,
"RealTimeQueryFeature__f_query_length": 6.0,
"RealTimeStringFeature__f_query": "candle",
"RealTimeEmbeddingFeature__f_query_embedding_vector_8": [
1.0,
2.0,
3.0,
4.0,
5.0,
6.0,
7.0,
8.0,
],
"RealTimeUserQueryFeature__f_user_query_name_edit_distance": 3.0,
"RealTimeUserQueryFeature__f_user_query_name_jaccard_similarity": -3.0,
},
},
"user::1234": {
"identifier": {"identifier": "1234", "identifier_type": "user"},
"features": {"RealTimeUserFeature:f_user_name_length": 9.0},
},
"query:user::candle:1234": {
"identifier": {
"identifier": "candle:1234",
"identifier_type": "query:user",
},
"features": {
"RealTimeUserQueryFeature:f_user_query_name_edit_distance": 3.0,
"RealTimeUserQueryFeature:f_user_query_name_jaccard_similarity": -3.0,
},
"features": {"RealTimeUserFeature__f_user_name_length": 9.0},
},
"product::p1": {
"identifier": {"identifier": "p1", "identifier_type": "product"},
"features": {"RealTimeProductFeature:f_opensearch_score": 1.0},
},
"product::p2": {
"identifier": {"identifier": "p2", "identifier_type": "product"},
"features": {},
},
"product::p3": {
"identifier": {"identifier": "p3", "identifier_type": "product"},
"features": {},
},
"product::p4": {
"identifier": {"identifier": "p4", "identifier_type": "product"},
"features": {"RealTimeProductFeature:f_opensearch_score": 100.0},
},
"product:query::p1:candle": {
"identifier": {
"identifier": "p1:candle",
"identifier_type": "product:query",
},
"features": {
"RealTimeMatchedQueriesProductFeature:f_matched_queries_QUERY_1": 1.0,
"RealTimeMatchedQueriesProductFeature:f_matched_queries_QUERY_2": 1.0,
"RealTimeQueryProductFeature:f_query_product_name_edit_distance": 4.0,
"RealTimeQueryProductFeature:f_query_product_name_jaccard_similarity": -4.0,
"RealTimeProductFeature__f_opensearch_score": 1.0,
"RealTimeMatchedQueriesProductFeature__f_matched_queries_QUERY_1": 1.0,
"RealTimeMatchedQueriesProductFeature__f_matched_queries_QUERY_2": 1.0,
"RealTimeQueryProductFeature__f_query_product_name_edit_distance": 4.0,
"RealTimeQueryProductFeature__f_query_product_name_jaccard_similarity": -4.0,
"RealTimeUserProductFeature__f_user_product_name_edit_distance": 7.0,
"RealTimeUserProductFeature__f_user_product_name_jaccard_similarity": -7.0,
},
},
"product:query::p2:candle": {
"identifier": {
"identifier": "p2:candle",
"identifier_type": "product:query",
},
"features": {
"RealTimeQueryProductFeature:f_query_product_name_edit_distance": 4.0,
"RealTimeQueryProductFeature:f_query_product_name_jaccard_similarity": -4.0,
},
},
"product:query::p3:candle": {
"identifier": {
"identifier": "p3:candle",
"identifier_type": "product:query",
},
"features": {
"RealTimeQueryProductFeature:f_query_product_name_edit_distance": 4.0,
"RealTimeQueryProductFeature:f_query_product_name_jaccard_similarity": -4.0,
},
},
"product:query::p4:candle": {
"identifier": {
"identifier": "p4:candle",
"identifier_type": "product:query",
},
"features": {
"RealTimeMatchedQueriesProductFeature:f_matched_queries_MATIAS": 1.0,
"RealTimeMatchedQueriesProductFeature:f_matched_queries_QUERY_2": 1.0,
"RealTimeQueryProductFeature:f_query_product_name_edit_distance": 4.0,
"RealTimeQueryProductFeature:f_query_product_name_jaccard_similarity": -4.0,
},
},
"product:user::p1:1234": {
"identifier": {
"identifier": "p1:1234",
"identifier_type": "product:user",
},
"features": {
"RealTimeUserProductFeature:f_user_product_name_edit_distance": 7.0,
"RealTimeUserProductFeature:f_user_product_name_jaccard_similarity": -7.0,
},
},
"product:user::p2:1234": {
"identifier": {
"identifier": "p2:1234",
"identifier_type": "product:user",
},
"product::p2": {
"identifier": {"identifier": "p2", "identifier_type": "product"},
"features": {
"RealTimeUserProductFeature:f_user_product_name_edit_distance": 7.0,
"RealTimeUserProductFeature:f_user_product_name_jaccard_similarity": -7.0,
"RealTimeQueryProductFeature__f_query_product_name_edit_distance": 4.0,
"RealTimeQueryProductFeature__f_query_product_name_jaccard_similarity": -4.0,
"RealTimeUserProductFeature__f_user_product_name_edit_distance": 7.0,
"RealTimeUserProductFeature__f_user_product_name_jaccard_similarity": -7.0,
},
},
"product:user::p3:1234": {
"identifier": {
"identifier": "p3:1234",
"identifier_type": "product:user",
},
"product::p3": {
"identifier": {"identifier": "p3", "identifier_type": "product"},
"features": {
"RealTimeUserProductFeature:f_user_product_name_edit_distance": 7.0,
"RealTimeUserProductFeature:f_user_product_name_jaccard_similarity": -7.0,
"RealTimeQueryProductFeature__f_query_product_name_edit_distance": 4.0,
"RealTimeQueryProductFeature__f_query_product_name_jaccard_similarity": -4.0,
"RealTimeUserProductFeature__f_user_product_name_edit_distance": 7.0,
"RealTimeUserProductFeature__f_user_product_name_jaccard_similarity": -7.0,
},
},
"product:user::p4:1234": {
"identifier": {
"identifier": "p4:1234",
"identifier_type": "product:user",
},
"product::p4": {
"identifier": {"identifier": "p4", "identifier_type": "product"},
"features": {
"RealTimeUserProductFeature:f_user_product_name_edit_distance": 7.0,
"RealTimeUserProductFeature:f_user_product_name_jaccard_similarity": -7.0,
"RealTimeProductFeature__f_opensearch_score": 100.0,
"RealTimeMatchedQueriesProductFeature__f_matched_queries_MATIAS": 1.0,
"RealTimeMatchedQueriesProductFeature__f_matched_queries_QUERY_2": 1.0,
"RealTimeQueryProductFeature__f_query_product_name_edit_distance": 4.0,
"RealTimeQueryProductFeature__f_query_product_name_jaccard_similarity": -4.0,
"RealTimeUserProductFeature__f_user_product_name_edit_distance": 7.0,
"RealTimeUserProductFeature__f_user_product_name_jaccard_similarity": -7.0,
},
},
},
Expand Down
Loading

0 comments on commit 208ff88

Please sign in to comment.