From 06f93806e6060866d647cd61b75dea4c9ed9f3de Mon Sep 17 00:00:00 2001 From: Pratyush Singh Date: Mon, 9 Oct 2023 12:12:23 -0400 Subject: [PATCH] feat: add `TIMEOUT` to all notebooks --- classic_dialog_skill_analysis.ipynb | 16 +++++++++++++--- classic_dialog_skill_analysis_cp4d.ipynb | 16 +++++++++++++--- new_experience_skill_analysis_cp4d.ipynb | 12 +++++++++--- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/classic_dialog_skill_analysis.ipynb b/classic_dialog_skill_analysis.ipynb index 33f53ab..674f4db 100644 --- a/classic_dialog_skill_analysis.ipynb +++ b/classic_dialog_skill_analysis.ipynb @@ -590,11 +590,14 @@ "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 # `TIMEOUT` is set to 1 second\n", "full_results = inferencer.inference(conversation=conversation,\n", " test_data=test_df,\n", " max_thread=THREAD_NUM, \n", " skill_id=skill_id,\n", + " timeout=TIMEOUT\n", " )" ] }, @@ -850,12 +853,15 @@ "utterance = \"where is the closest agent\" # input example\n", "intent = \"General_Connect_to_Agent\" # 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 # `TIMEOUT` is set to 1 second\n", "inference_results = inferencer.inference(conversation=conversation, \n", " skill_id=skill_id, \n", " test_data=pd.DataFrame({'utterance':[utterance], \n", " 'intent':[intent]}), \n", - " max_thread = 1, \n", + " max_thread = 1,\n", + " timeout=TIMEOUT\n", " )\n", "\n", "highlighter.get_highlights_in_batch_multi_thread(conversation=conversation, \n", @@ -990,10 +996,14 @@ "importlib.reload(inferencer)\n", "if entities_list:\n", " THREAD_NUM = min(4, os.cpu_count() if os.cpu_count() else 1)\n", + " # increase timeout if you experience `TimeoutError`. \n", + " # Increasing the `TIMEOUT` allows the process more breathing room to compete\n", + " TIMEOUT = 1 # `TIMEOUT` is set to 1 second\n", " train_full_results = inferencer.inference(conversation=conversation,\n", " test_data=workspace_pd, \n", " max_thread=THREAD_NUM,\n", " skill_id=skill_id,\n", + " timeout=TIMEOUT\n", " )\n", " entity_label_correlation_df = entity_analyzer.entity_label_correlation_analysis(\n", " train_full_results, entities_list)\n", diff --git a/classic_dialog_skill_analysis_cp4d.ipynb b/classic_dialog_skill_analysis_cp4d.ipynb index 63eab0c..7242d04 100644 --- a/classic_dialog_skill_analysis_cp4d.ipynb +++ b/classic_dialog_skill_analysis_cp4d.ipynb @@ -596,11 +596,14 @@ "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 # `TIMEOUT` is set to 1 second\n", "full_results = inferencer.inference(conversation=conversation,\n", " test_data=test_df,\n", " max_thread=THREAD_NUM, \n", " skill_id=skill_id,\n", + " timeout=TIMEOUT\n", " )" ] }, @@ -856,12 +859,15 @@ "utterance = \"where is the closest agent\" # input example\n", "intent = \"General_Connect_to_Agent\" # 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 # `TIMEOUT` is set to 1 second\n", "inference_results = inferencer.inference(conversation=conversation, \n", " skill_id=skill_id, \n", " test_data=pd.DataFrame({'utterance':[utterance], \n", " 'intent':[intent]}), \n", - " max_thread = 1, \n", + " max_thread = 1,\n", + " timeout=TIMEOUT\n", " )\n", "\n", "highlighter.get_highlights_in_batch_multi_thread(conversation=conversation, \n", @@ -996,10 +1002,14 @@ "importlib.reload(inferencer)\n", "if entities_list:\n", " THREAD_NUM = min(4, os.cpu_count() if os.cpu_count() else 1)\n", + " # increase timeout if you experience `TimeoutError`. \n", + " # Increasing the `TIMEOUT` allows the process more breathing room to compete\n", + " TIMEOUT = 1 # `TIMEOUT` is set to 1 second\n", " train_full_results = inferencer.inference(conversation=conversation,\n", " test_data=workspace_pd, \n", " max_thread=THREAD_NUM,\n", " skill_id=skill_id,\n", + " timeout=TIMEOUT\n", " )\n", " entity_label_correlation_df = entity_analyzer.entity_label_correlation_analysis(\n", " train_full_results, entities_list)\n", diff --git a/new_experience_skill_analysis_cp4d.ipynb b/new_experience_skill_analysis_cp4d.ipynb index e13d558..757f4a7 100644 --- a/new_experience_skill_analysis_cp4d.ipynb +++ b/new_experience_skill_analysis_cp4d.ipynb @@ -582,12 +582,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 # `TIMEOUT` is set to 1 second\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", " )" ] }, @@ -756,13 +759,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 # `TIMEOUT` is set to 1 second\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",