Skip to content

Commit 7ffd4ea

Browse files
committed
some improvements in terraform side and also app side
Signed-off-by: aalmoham <[email protected]>
1 parent 42d4551 commit 7ffd4ea

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

askme/askme.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def render_vector_store_creation_chatbot():
211211
warning_message = "\n\n".join(vector_creation_output)
212212
st.warning(f"Something Went Wrong, Error: ({warning_message})")
213213
logger.warning(f"Something Went Wrong, Error: ({warning_message})")
214+
cleanup_vector_table_materials(SCHEMA_NAME, [st.session_state.askme_chatbot_vector_creation_table_name], BUCKET_DIR_PREFIX)
214215
st.session_state.askme_chatbot_vector_creation_table_name = ""
215216
st.button("OK")
216217

@@ -274,7 +275,7 @@ def render_vector_store_management_main():
274275
warning_message = "\n\n".join(vector_creation_output)
275276
st.warning(f"Something Went Wrong, Error: ({warning_message})")
276277
logger.warning(f"Something Went Wrong, Error: ({warning_message})")
277-
cleanup_vector_table_materials(bucket_dir_name)
278+
cleanup_vector_table_materials(SCHEMA_NAME, [st.session_state.askme_main_vector_creation_table_name], BUCKET_DIR_PREFIX)
278279
clear_km_management_status()
279280
st.button("OK")
280281

@@ -295,8 +296,7 @@ def render_vector_store_management_main():
295296
col1, col2 = st.columns(2)
296297
with col1:
297298
if st.button("Yes, Delete", type="primary"):
298-
bucket_folder_to_delete = f"{BUCKET_DIR_PREFIX}{table}"
299-
cleanup_vector_table_materials(SCHEMA_NAME, [table], bucket_folder_to_delete)
299+
cleanup_vector_table_materials(SCHEMA_NAME, [table], BUCKET_DIR_PREFIX)
300300
update_table_list()
301301
if not table in st.session_state.askme_knowledge[SCHEMA_NAME]:
302302
st.success(f"Deleted successfully.")
@@ -318,7 +318,7 @@ def render_vector_store_management_main():
318318
deletion_flag = False
319319
with col1:
320320
if st.button("Reset Knowledge Base"):
321-
cleanup_vector_table_materials(SCHEMA_NAME, st.session_state.askme_knowledge[SCHEMA_NAME], DEFAULT_USER_UPLOAD_BUCKET_DIR)
321+
cleanup_vector_table_materials(SCHEMA_NAME, st.session_state.askme_knowledge[SCHEMA_NAME], BUCKET_DIR_PREFIX)
322322
update_table_list()
323323
deletion_flag = True
324324
if deletion_flag:

askme/terraform/constants.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Constants for setup
55
locals {
66
mysql_shape = "MySQL.8"
7-
mysql_version = "9.2.1"
7+
mysql_version = "9.2.2"
88
mysql_username = "admin"
99
heatwave_shape = "HeatWave.512GB"
1010
compute_shape = "VM.Standard.E4.Flex"

askme/terraform/instance.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ resource "oci_core_instance" "askme_instance" {
3535
}
3636
preserve_boot_volume = false
3737
freeform_tags = {"${local.resource_tag_key}"="${local.resource_tag_value}"}
38+
depends_on = [
39+
oci_vault_secret.askme_mysql_host_ip_secret,
40+
oci_vault_secret.askme_mysql_username_secret,
41+
oci_vault_secret.askme_mysql_password_secret,
42+
oci_mysql_heat_wave_cluster.askme_heatwave_cluster
43+
]
3844
}
3945

4046
# Sleep time to make sure the instance user_data was executed

askme/utils/genai_helper.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get_connection(schema_name = DEFAULT_ASKME_SCHEMA_NAME):
2020
host=host,
2121
database=schema_name,
2222
port="3306",
23-
connection_timeout=3,
23+
connection_timeout=11,
2424
repeat=3
2525
)
2626
return conn
@@ -404,12 +404,14 @@ def group_relevant_chunks_by_url(relevant_chunks):
404404

405405
return sorted_grouped_results
406406

407-
def cleanup_vector_table_materials(schema, table_list, bucket_folder_to_delete):
407+
def cleanup_vector_table_materials(schema, table_list, bucket_folder_to_delete_prefix):
408408
conn = get_connection()
409+
bucket_name = get_askme_bucket_name()
409410
for table in table_list:
410411
if table not in [DEFAULT_EMPTY_VECTOR_TABLE_NAME, HEATWAVE_MANUALS_VECTOR_TABLE_NAME]:
411412
response = delete_table_from_database(schema, table)
412413
logger.info(f"{schema}.{table} deletion: {response}")
413-
bucket_name = get_askme_bucket_name()
414-
delete_object_store_folder(bucket_name, bucket_folder_to_delete)
415-
logger.info(f"All user data from the bucket {bucket_folder_to_delete} deletion.")
414+
bucket_folder_to_delete = f"{bucket_folder_to_delete_prefix}{table}"
415+
delete_object_store_folder(bucket_name, bucket_folder_to_delete)
416+
logger.info(f"{bucket_folder_to_delete} deletion is done.")
417+

askme/utils/mysql_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from utils.exceptions import AskMEException, BackendConnectionException , UnknownException
88

99
# Connection to the MySQL server
10-
def mysql_connect(username, password, host, database, port, connection_timeout=1, repeat=5):
10+
def mysql_connect(username, password, host, database, port, connection_timeout=11, repeat=5):
1111
for i in range(repeat):
1212
try:
1313
return mysql.connector.connect(

0 commit comments

Comments
 (0)