From 05bc59e0a91dfd64cdf9cc1af367b9801135aeb7 Mon Sep 17 00:00:00 2001 From: star-nox Date: Mon, 11 Dec 2023 16:30:12 -0600 Subject: [PATCH] fixed pool execution errors --- ai_ta_backend/filtering_contexts.py | 12 +++++++----- ai_ta_backend/parallel_context_processing.py | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ai_ta_backend/filtering_contexts.py b/ai_ta_backend/filtering_contexts.py index 0c49d921..54b3a864 100644 --- a/ai_ta_backend/filtering_contexts.py +++ b/ai_ta_backend/filtering_contexts.py @@ -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): diff --git a/ai_ta_backend/parallel_context_processing.py b/ai_ta_backend/parallel_context_processing.py index c27db33e..e1367da1 100644 --- a/ai_ta_backend/parallel_context_processing.py +++ b/ai_ta_backend/parallel_context_processing.py @@ -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