From c3e4026bd3b09e4bd8b137d709e8e771adfd926b Mon Sep 17 00:00:00 2001 From: Komal Grover Date: Mon, 29 Apr 2024 08:35:22 +0000 Subject: [PATCH 1/3] module load issue --- code/backend/batch/utilities/search/AzureSearchHandler.py | 4 ++-- .../utilities/search/IntegratedVectorizationSearchHandler.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code/backend/batch/utilities/search/AzureSearchHandler.py b/code/backend/batch/utilities/search/AzureSearchHandler.py index 229167309..43e8e4dd0 100644 --- a/code/backend/batch/utilities/search/AzureSearchHandler.py +++ b/code/backend/batch/utilities/search/AzureSearchHandler.py @@ -1,5 +1,5 @@ -from backend.batch.utilities.search.SearchHandlerBase import SearchHandlerBase -from backend.batch.utilities.helpers.AzureSearchHelper import AzureSearchHelper +from batch.utilities.search.SearchHandlerBase import SearchHandlerBase +from batch.utilities.helpers.AzureSearchHelper import AzureSearchHelper import json diff --git a/code/backend/batch/utilities/search/IntegratedVectorizationSearchHandler.py b/code/backend/batch/utilities/search/IntegratedVectorizationSearchHandler.py index 15d7a2023..4b0846831 100644 --- a/code/backend/batch/utilities/search/IntegratedVectorizationSearchHandler.py +++ b/code/backend/batch/utilities/search/IntegratedVectorizationSearchHandler.py @@ -1,4 +1,4 @@ -from backend.batch.utilities.search.SearchHandlerBase import SearchHandlerBase +from batch.utilities.search.SearchHandlerBase import SearchHandlerBase from azure.search.documents import SearchClient from azure.core.credentials import AzureKeyCredential from azure.identity import DefaultAzureCredential From c36395693ea1bc6f1b068bd9644b322e1492bfe0 Mon Sep 17 00:00:00 2001 From: Komal Grover Date: Mon, 29 Apr 2024 12:23:14 +0000 Subject: [PATCH 2/3] sync main --- code/backend/batch/utilities/search/AzureSearchHandler.py | 4 ++-- .../utilities/search/IntegratedVectorizationSearchHandler.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code/backend/batch/utilities/search/AzureSearchHandler.py b/code/backend/batch/utilities/search/AzureSearchHandler.py index 43e8e4dd0..d895e1f38 100644 --- a/code/backend/batch/utilities/search/AzureSearchHandler.py +++ b/code/backend/batch/utilities/search/AzureSearchHandler.py @@ -1,5 +1,5 @@ -from batch.utilities.search.SearchHandlerBase import SearchHandlerBase -from batch.utilities.helpers.AzureSearchHelper import AzureSearchHelper +from .SearchHandlerBase import SearchHandlerBase +from ..helpers.AzureSearchHelper import AzureSearchHelper import json diff --git a/code/backend/batch/utilities/search/IntegratedVectorizationSearchHandler.py b/code/backend/batch/utilities/search/IntegratedVectorizationSearchHandler.py index 4b0846831..440c14e01 100644 --- a/code/backend/batch/utilities/search/IntegratedVectorizationSearchHandler.py +++ b/code/backend/batch/utilities/search/IntegratedVectorizationSearchHandler.py @@ -1,4 +1,4 @@ -from batch.utilities.search.SearchHandlerBase import SearchHandlerBase +from .SearchHandlerBase import SearchHandlerBase from azure.search.documents import SearchClient from azure.core.credentials import AzureKeyCredential from azure.identity import DefaultAzureCredential From a0e1fd0d24282d75c28939fe1088c84b129ac491 Mon Sep 17 00:00:00 2001 From: Komal Grover Date: Thu, 9 May 2024 17:30:19 +0000 Subject: [PATCH 3/3] Delete files from storage --- .../utilities/helpers/AzureBlobStorageClient.py | 16 +++++++++++++++- code/backend/pages/03_Delete_Data.py | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/code/backend/batch/utilities/helpers/AzureBlobStorageClient.py b/code/backend/batch/utilities/helpers/AzureBlobStorageClient.py index ea1fb4dce..10dc1391c 100644 --- a/code/backend/batch/utilities/helpers/AzureBlobStorageClient.py +++ b/code/backend/batch/utilities/helpers/AzureBlobStorageClient.py @@ -168,7 +168,21 @@ def delete_file(self, file_name): blob_client = self.blob_service_client.get_blob_client( container=self.container_name, blob=file_name ) - blob_client.delete_blob() + if blob_client.exists(): + blob_client.delete_blob() + + def delete_files(self, files): + """ + Deletes files from the Azure Blob Storage container. + + Args: + files (list[str]): The names of the files to delete. + + Returns: + None + """ + for filename, ids in files.items(): + self.delete_file(filename) def get_all_files(self): # Get all files in the container from Azure Blob Storage diff --git a/code/backend/pages/03_Delete_Data.py b/code/backend/pages/03_Delete_Data.py index 6b71b547c..f9391b03b 100644 --- a/code/backend/pages/03_Delete_Data.py +++ b/code/backend/pages/03_Delete_Data.py @@ -5,6 +5,7 @@ import logging from batch.utilities.helpers.EnvHelper import EnvHelper from batch.utilities.search.Search import Search +from batch.utilities.helpers.AzureBlobStorageClient import AzureBlobStorageClient sys.path.append(os.path.join(os.path.dirname(__file__), "..")) env_helper: EnvHelper = EnvHelper() @@ -65,6 +66,9 @@ files_to_delete = search_handler.delete_files( selected_files, ) + # Delete from Storage + blob_client = AzureBlobStorageClient() + blob_client.delete_files(selected_files) if len(files_to_delete) > 0: st.success("Deleted files: " + str(files_to_delete))