From a39411a3a8afe944a29db819af5c28361f7f6b1a Mon Sep 17 00:00:00 2001 From: saarikabhasi Date: Wed, 21 Feb 2024 21:45:55 -0500 Subject: [PATCH] check modal status, delete index pre-check --- .../with-index-pipelines.ipynb | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/notebooks/document-chunking/with-index-pipelines.ipynb b/notebooks/document-chunking/with-index-pipelines.ipynb index 5e7535df..396baaaa 100644 --- a/notebooks/document-chunking/with-index-pipelines.ipynb +++ b/notebooks/document-chunking/with-index-pipelines.ipynb @@ -71,7 +71,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": null, "id": "f38e0397", "metadata": { "colab": { @@ -80,16 +80,7 @@ "id": "f38e0397", "outputId": "ad6df489-d242-4229-a42a-39c5ca19d124" }, - "outputs": [ - { - "name": "stdin", - "output_type": "stream", - "text": [ - "Elastic Cloud ID: ········\n", - "Elastic Api Key: ········\n" - ] - } - ], + "outputs": [], "source": [ "from elasticsearch import Elasticsearch\n", "from getpass import getpass\n", @@ -170,7 +161,16 @@ " --hub-model-id \"sentence-transformers/all-MiniLM-L6-v2\" \\\n", " --task-type text_embedding \\\n", " --clear-previous \\\n", - " --start" + " --start\n", + "\n", + "while True:\n", + " status = client.ml.get_trained_models_stats(model_id=MODEL_ID)\n", + " if \"trained_model_stats\" in status.keys() and status[\"trained_model_stats\"][0][\"deployment_stats\"][\"state\"] == \"started\":\n", + " print(MODEL_ID + \" Model has been successfully deployed & started.\")\n", + " break\n", + " else:\n", + " print(MODEL_ID + \" Model is currently being deployed.\")\n", + " time.sleep(5)\n" ] }, { @@ -300,6 +300,8 @@ "source": [ "INDEX_NAME = \"chunk_passages_example\"\n", "\n", + "client.indices.delete(index=INDEX_NAME, ignore_unavailable=True)\n", + "\n", "# Setup the index\n", "client.indices.create(\n", " index=INDEX_NAME,\n",