Vela
commited on
Commit
·
03d6ad4
1
Parent(s):
4c686e7
modified get index method
Browse files
src/database_pinecone/__pycache__/create_database.cpython-313.pyc
CHANGED
Binary files a/src/database_pinecone/__pycache__/create_database.cpython-313.pyc and b/src/database_pinecone/__pycache__/create_database.cpython-313.pyc differ
|
|
src/database_pinecone/create_database.py
CHANGED
@@ -38,9 +38,10 @@ def wait_till_index_loaded(pinecone, index_name):
|
|
38 |
time.sleep(1)
|
39 |
|
40 |
def get_index():
|
|
|
|
|
41 |
try:
|
42 |
pc = Pinecone(api_key=pincone_api_key)
|
43 |
-
index = None
|
44 |
index_name = "imagesearch"
|
45 |
logger.info(f"Checking if the index '{index_name}' exists...")
|
46 |
if not pc.has_index(index_name):
|
@@ -51,10 +52,9 @@ def get_index():
|
|
51 |
else:
|
52 |
index = pc.Index(index_name)
|
53 |
logger.info(f"Index '{index_name}' already exists. Returning the existing index.")
|
54 |
-
return index
|
55 |
except Exception as e:
|
56 |
logger.info(f"Error occurred while getting or creating the Pinecone index: {str(e)}", exc_info=True)
|
57 |
-
|
58 |
|
59 |
def process_and_upsert_data(index, data: pd.Series, url_key: str, id_key: str):
|
60 |
"""
|
|
|
38 |
time.sleep(1)
|
39 |
|
40 |
def get_index():
|
41 |
+
global index
|
42 |
+
index = None
|
43 |
try:
|
44 |
pc = Pinecone(api_key=pincone_api_key)
|
|
|
45 |
index_name = "imagesearch"
|
46 |
logger.info(f"Checking if the index '{index_name}' exists...")
|
47 |
if not pc.has_index(index_name):
|
|
|
52 |
else:
|
53 |
index = pc.Index(index_name)
|
54 |
logger.info(f"Index '{index_name}' already exists. Returning the existing index.")
|
|
|
55 |
except Exception as e:
|
56 |
logger.info(f"Error occurred while getting or creating the Pinecone index: {str(e)}", exc_info=True)
|
57 |
+
return index
|
58 |
|
59 |
def process_and_upsert_data(index, data: pd.Series, url_key: str, id_key: str):
|
60 |
"""
|