Skip to content

Commit 6c61fd3

Browse files
committed
create new indexes every time a new staging version is born
1 parent c648381 commit 6c61fd3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

llm-complete-guide/utils/llm_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import logging
2323
import os
24+
import uuid
2425

2526
from elasticsearch import Elasticsearch
2627
from zenml.client import Client
@@ -304,6 +305,9 @@ def get_pinecone_client(model_version_stage: str = "staging") -> pinecone.Index:
304305
index_name = model_version.run_metadata["vector_store"]["index_name"]
305306
except KeyError:
306307
index_name = client.get_secret(SECRET_NAME_PINECONE).secret_values.get("pinecone_index", "zenml-docs-dev")
308+
# if index by that name exists already, create a new one with a random suffix
309+
if index_name in pc.list_indexes().names():
310+
index_name = f"{index_name}-{uuid.uuid4()}"
307311
model_version.run_metadata["vector_store"]["index_name"] = index_name
308312

309313
# Create index if it doesn't exist

0 commit comments

Comments
 (0)