diff --git a/assistant_skill_analysis/inferencing/inferencer.py b/assistant_skill_analysis/inferencing/inferencer.py index 9375355..c3dfa19 100644 --- a/assistant_skill_analysis/inferencing/inferencer.py +++ b/assistant_skill_analysis/inferencing/inferencer.py @@ -17,6 +17,7 @@ def inference( assistant_id=None, skill_id=None, intent_to_action_mapping=None, + timeout=1 ): """ query the message api to generate results on the test data @@ -115,6 +116,7 @@ def inference( skill_id=skill_id, assistant_id=assistant_id, intent_to_action_mapping=intent_to_action_mapping, + timeout=timeout ) return result_df @@ -127,6 +129,7 @@ def thread_inference( assistant_id=None, skill_id=None, intent_to_action_mapping=None, + timeout=1 ): """ Perform multi thread inference for faster inference time @@ -179,7 +182,7 @@ def thread_inference( futures[future] = (test_example, ground_truth) for future in tqdm(futures): - res = future.result(timeout=1) + res = future.result(timeout=timeout) test_example, ground_truth = futures[future] result.append( process_result( diff --git a/new_experience_skill_analysis.ipynb b/new_experience_skill_analysis.ipynb index 3717188..d632afe 100644 --- a/new_experience_skill_analysis.ipynb +++ b/new_experience_skill_analysis.ipynb @@ -606,12 +606,15 @@ "outputs": [], "source": [ "THREAD_NUM = min(4, os.cpu_count() if os.cpu_count() else 1)\n", - "\n", + "# increase timeout if you experience `TimeoutError`. \n", + "# Increasing the `TIMEOUT` allows the process more breathing room to compete\n", + "TIMEOUT = 1 \n", "full_results = inferencer.inference(conversation,\n", " test_df,\n", " max_thread=THREAD_NUM, \n", " assistant_id=ASSISTANT_ID,\n", - " intent_to_action_mapping=intent_to_action_mapping\n", + " intent_to_action_mapping=intent_to_action_mapping,\n", + " timeout=TIMEOUT\n", " )" ] }, @@ -782,13 +785,16 @@ "utterance = \"what can i do to talk to someone\" # input example\n", "intent = \"Schedule An Appointment\" # input an intent in your workspace which you are interested in.\n", "\n", - "\n", + "# increase timeout if you experience `TimeoutError`. \n", + "# Increasing the `TIMEOUT` allows the process more breathing room to compete\n", + "TIMEOUT = 1 \n", "inference_results = inferencer.inference(conversation=conversation, \n", " test_data=pd.DataFrame({'utterance':[utterance], \n", " 'intent':[intent]}), \n", " max_thread = 1, \n", " assistant_id=ASSISTANT_ID,\n", " intent_to_action_mapping=intent_to_action_mapping,\n", + " timeout=TIMEOUT\n", " )\n", "\n", "highlighter.get_highlights_in_batch_multi_thread(conversation=conversation, \n",