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

fix saving (last chunk was skipped) #17

Open
wants to merge 1 commit into
base: add-rag
Choose a base branch
from
Open
Changes from all 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
4 changes: 3 additions & 1 deletion fulltext/search_boosted.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def load_and_merge(directory_path, id, args):
os.makedirs(f"intermediate_data/{id}", exist_ok=True)

intermediate_data = []
total_length = len(data)
for index in range(len(data)):
sample = data[index]
sample["topic_hits"] = []
Expand Down Expand Up @@ -113,7 +114,8 @@ def load_and_merge(directory_path, id, args):
save_interval = min(args.n_topics, args.save_interval)
if index > 0 and (index + 1) % save_interval == 0:
# Save data every save_interval topics and reinitialize intermediate dicts
save_path = f"intermediate_data/{id}/data_{index + 1 - save_interval}_{index + 1}.json"
start_index = index + 1 - save_interval if (index + 1) % save_interval == 0 else max(0, index + 1 - (index + 1) % save_interval)
save_path = f"intermediate_data/{id}/data_{start_index}_{index + 1}.json"
with open(save_path, "w") as fp:
json.dump(intermediate_data, fp)
print(f"💾 Saved intermediate data at {save_path}")
Expand Down