Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build and search params to raft-ann-bench.data_export CSVs #1971

Merged
merged 5 commits into from
Nov 8, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,33 @@
import argparse
import json
import os
import warnings

import pandas as pd

skip_build_cols = set(
[
"algo_name",
"index_name",
"time",
"name",
"family_index",
"per_family_instance_index",
"run_name",
"run_type",
"repetitions",
"repetition_index",
"iterations",
"real_time",
"time_unit",
"index_size",
]
)

skip_search_cols = (
set(["recall", "qps", "items_per_second", "Recall"]) | skip_build_cols
)


def read_file(dataset, dataset_path, method):
dir = os.path.join(dataset_path, dataset, "result", method)
Expand All @@ -42,6 +66,9 @@ def convert_json_to_csv_build(dataset, dataset_path):
"time": df["real_time"],
}
)
for name in df:
if name not in skip_build_cols:
write[name] = df[name]
filepath = os.path.normpath(file).split(os.sep)
filename = filepath[-1].split("-")[0] + ".csv"
write.to_csv(
Expand All @@ -52,6 +79,9 @@ def convert_json_to_csv_build(dataset, dataset_path):

def convert_json_to_csv_search(dataset, dataset_path):
for file, algo_name, df in read_file(dataset, dataset_path, "search"):
build_file = os.path.join(
dataset_path, dataset, "result", "build", f"{algo_name}.csv"
)
algo_name = algo_name.replace("_base", "")
df["name"] = df["name"].str.split("/").str[0]
write = pd.DataFrame(
Expand All @@ -62,6 +92,37 @@ def convert_json_to_csv_search(dataset, dataset_path):
"qps": df["items_per_second"],
}
)
for name in df:
if name not in skip_search_cols:
write[name] = df[name]

if os.path.exists(build_file):
divyegala marked this conversation as resolved.
Show resolved Hide resolved
build_df = pd.read_csv(build_file)
write_ncols = len(write.columns)
write["build time"] = None
write["build threads"] = None
write["build cpu_time"] = None
write["build GPU"] = None

for col_idx in range(5, len(build_df.columns)):
col_name = build_df.columns[col_idx]
write[col_name] = None

for s_index, search_row in write.iterrows():
for b_index, build_row in build_df.iterrows():
if search_row["index_name"] == build_row["index_name"]:
write.iloc[s_index, write_ncols] = build_df.iloc[
b_index, 2
]
write.iloc[s_index, write_ncols + 1:] = build_df.iloc[
b_index, 3:
]
break
else:
warnings.warn(
f"Build CSV not found for {algo_name}, build params won't be "
"appended in the Search CSV")

write.to_csv(file.replace(".json", ".csv"), index=False)


Expand Down
Loading