Skip to content

Commit

Permalink
fixed pool execution errors
Browse files Browse the repository at this point in the history
  • Loading branch information
star-nox committed Dec 11, 2023
1 parent 0c0fe7a commit 05bc59e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions ai_ta_backend/filtering_contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,18 @@ def run_context_filtering(contexts, user_query, max_time_before_return=45, max_c
partial_func2 = partial(select_context, result=filtered_contexts)

with ThreadPoolExecutor(max_workers=200) as executor1:
results1 = list(executor1.map(partial_func1, contexts[:10]))
results1 = list(executor1.map(partial_func1, contexts))

print(f"⏰ ThreadPool runtime: {(time.monotonic() - start_time):.2f} seconds")

with ProcessPoolExecutor(max_workers=200) as executor:
executor.map(partial_func2, results1)
print(f"⏰ Context filtering runtime: {(time.monotonic() - start_time):.2f} seconds")
print("len of filtered contexts: ", len(filtered_contexts))
exit()
return filtered_contexts

filtered_contexts = list(filtered_contexts)
print(f"⏰ Context filtering runtime: {(time.monotonic() - start_time):.2f} seconds")
print("len of filtered contexts: ", len(filtered_contexts))

return filtered_contexts


def filter_context(context, user_query, langsmith_prompt_obj):
Expand Down
2 changes: 1 addition & 1 deletion ai_ta_backend/parallel_context_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def context_processing(found_docs, search_query, course_name):

result_contexts = supabase_contexts_no_duplicates + list(qdrant_contexts)

print(f"⏰ Context processing runtime: {(time.monotonic() - start_time):.2f} seconds")
print(f"⏰ Context padding runtime: {(time.monotonic() - start_time):.2f} seconds")

return result_contexts

Expand Down

0 comments on commit 05bc59e

Please sign in to comment.