Skip to content

Commit 41c0a05

Browse files
authored
check modal status, delete index pre-check (#191)
1 parent 051e9e3 commit 41c0a05

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

notebooks/document-chunking/with-index-pipelines.ipynb

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
},
7272
{
7373
"cell_type": "code",
74-
"execution_count": 30,
74+
"execution_count": null,
7575
"id": "f38e0397",
7676
"metadata": {
7777
"colab": {
@@ -80,16 +80,7 @@
8080
"id": "f38e0397",
8181
"outputId": "ad6df489-d242-4229-a42a-39c5ca19d124"
8282
},
83-
"outputs": [
84-
{
85-
"name": "stdin",
86-
"output_type": "stream",
87-
"text": [
88-
"Elastic Cloud ID: ········\n",
89-
"Elastic Api Key: ········\n"
90-
]
91-
}
92-
],
83+
"outputs": [],
9384
"source": [
9485
"from elasticsearch import Elasticsearch\n",
9586
"from getpass import getpass\n",
@@ -170,7 +161,16 @@
170161
" --hub-model-id \"sentence-transformers/all-MiniLM-L6-v2\" \\\n",
171162
" --task-type text_embedding \\\n",
172163
" --clear-previous \\\n",
173-
" --start"
164+
" --start\n",
165+
"\n",
166+
"while True:\n",
167+
" status = client.ml.get_trained_models_stats(model_id=MODEL_ID)\n",
168+
" if \"trained_model_stats\" in status.keys() and status[\"trained_model_stats\"][0][\"deployment_stats\"][\"state\"] == \"started\":\n",
169+
" print(MODEL_ID + \" Model has been successfully deployed & started.\")\n",
170+
" break\n",
171+
" else:\n",
172+
" print(MODEL_ID + \" Model is currently being deployed.\")\n",
173+
" time.sleep(5)\n"
174174
]
175175
},
176176
{
@@ -300,6 +300,8 @@
300300
"source": [
301301
"INDEX_NAME = \"chunk_passages_example\"\n",
302302
"\n",
303+
"client.indices.delete(index=INDEX_NAME, ignore_unavailable=True)\n",
304+
"\n",
303305
"# Setup the index\n",
304306
"client.indices.create(\n",
305307
" index=INDEX_NAME,\n",

0 commit comments

Comments
 (0)