Skip to content

Commit

Permalink
feat: add TIMEOUT to all notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratyush Singh committed Oct 9, 2023
1 parent 5f7856b commit 06f9380
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
16 changes: 13 additions & 3 deletions classic_dialog_skill_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
" )"
]
},
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
16 changes: 13 additions & 3 deletions classic_dialog_skill_analysis_cp4d.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
" )"
]
},
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
12 changes: 9 additions & 3 deletions new_experience_skill_analysis_cp4d.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
" )"
]
},
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 06f9380

Please sign in to comment.