Skip to content

Commit d31b36e

Browse files
Merge pull request #65 from oracle-samples/cdb-fix
Cdb fix
2 parents c4a313f + c9cf3a1 commit d31b36e

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ temp/rag_agent.ipynb
4343
temp/tools.ipynb
4444
temp/tools.py
4545
temp/json-dual.sql
46+
env.sh

app/src/content/split_embed.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import os
1111
import re
1212
import requests
13+
import time
1314

1415
# Streamlit
1516
import streamlit as st
@@ -316,6 +317,15 @@ def main():
316317
progress_text = "Operation in progress. Please wait."
317318
progress_bar = st.progress(0, text=progress_text)
318319
progress_ind = 100 / len(process_list)
320+
321+
try:
322+
utilities.oci_create_bucket(state.oci_config, state.oci_namespace, oci_compartments[bucket_compartment], dst_bucket)
323+
time.sleep(5)
324+
except oci.exceptions.ServiceError as ex:
325+
logger.info("WARNING: bucket exists")
326+
327+
328+
319329
for index, f in process_list.iterrows():
320330
progress_stat = int((((index + 1) * progress_ind) / 2))
321331
progress_bar.progress(progress_stat, text=progress_text)

app/src/modules/split.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def load_and_split_documents(
185185
all_split_docos += split_docos
186186
logger.info("Total Number of Chunks: %i", len(all_split_docos))
187187

188-
return split_docos, split_files
188+
return all_split_docos, split_files
189189

190190

191191
##########################################

app/src/modules/utilities.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,19 +621,27 @@ def oci_get_object(config, namespace, bucket_name, directory, object_name, retri
621621
return file_path
622622

623623

624+
624625
def oci_put_object(config, namespace, compartment, bucket_name, file_path, retries=True):
625626
"""Upload file to Object Storage"""
627+
MAX_RETRY = 2
626628
file_name = os.path.basename(file_path)
627629
logger.info("Uploading %s to %s as %s ", file_path, bucket_name, file_name)
628630
client = oci_init_client(oci.object_storage.ObjectStorageClient, config, retries)
629631
upload_manager = oci.object_storage.UploadManager(client, allow_parallel_uploads=True, parallel_process_count=10)
630632
try:
631633
upload_manager.upload_file(namespace, bucket_name, file_name, file_path)
634+
logger.info("Uploaded successfully %s to %s", file_name, bucket_name)
632635
except oci.exceptions.ServiceError as ex:
633636
logger.exception(ex, exc_info=False)
634-
oci_create_bucket(config, namespace, compartment, bucket_name)
635-
upload_manager.upload_file(namespace, bucket_name, file_name, file_path)
636-
logger.info("Uploaded %s to %s", file_name, bucket_name)
637+
for i in range(1, MAX_RETRY):
638+
try:
639+
logger.info("RETRY: upload_manager.upload_file()")
640+
upload_manager.upload_file(namespace, bucket_name, file_name, file_path)
641+
logger.info("Uploaded successfully %s to %s", file_name, bucket_name)
642+
break
643+
except oci.exceptions.ServiceError as ex:
644+
logger.exception(ex, exc_info=False)
637645

638646
os.remove(file_path)
639647

0 commit comments

Comments
 (0)