diff --git a/deepsearch/cps/data_indices/utils.py b/deepsearch/cps/data_indices/utils.py index a45cda81..cefb3509 100644 --- a/deepsearch/cps/data_indices/utils.py +++ b/deepsearch/cps/data_indices/utils.py @@ -74,6 +74,10 @@ def process_url_input( task_ids = [] # submit urls count_urls = len(urls) + + # Check if there are valid targets to iterate over + if count_urls == 0: + raise ValueError("No urls resolved from input") with tqdm( total=count_urls, desc=f"{'Submitting input:': <{progressbar.padding}}", @@ -133,6 +137,9 @@ def process_local_file( # container for task_ids task_ids = [] + # Check if there are valid targets to iterate over + if count_total_files == 0: + raise ValueError("No files resolved from input") # start loop with tqdm( total=count_total_files, diff --git a/deepsearch/documents/core/convert.py b/deepsearch/documents/core/convert.py index 10b26a39..a3362208 100644 --- a/deepsearch/documents/core/convert.py +++ b/deepsearch/documents/core/convert.py @@ -116,6 +116,10 @@ def send_files_for_conversion( # container for task_ids task_ids = [] + # Check if there are valid targets to iterate over + if len(files_zip) == 0: + raise ValueError("No files resolved from input") + # start loop with tqdm( total=len(files_zip), @@ -163,6 +167,10 @@ def check_status_running_tasks( ) statuses = [] + # Check if there are valid targets to iterate over + if count_total == 0: + raise ValueError("No task_ids resolved from input") + with tqdm( total=count_total, desc=f"{'Converting input:': <{progressbar.padding}}", @@ -227,6 +235,10 @@ def download_converted_documents( shows progress bar if True """ + # Check if there are valid targets to iterate over + if len(download_urls) == 0: + raise ValueError("No urls resolved from input") + with tqdm( total=len(download_urls), desc=f"{'Downloading result:': <{progressbar.padding}}", @@ -280,6 +292,11 @@ def send_urls_for_conversion( """ count_urls = len(urls) task_ids = [] + + # Check if there are valid targets to iterate over + if count_urls == 0: + raise ValueError("No urls resolved from input") + with tqdm( total=count_urls, desc=f"{'Submitting input:': <{progressbar.padding}}", diff --git a/deepsearch/documents/core/create_report.py b/deepsearch/documents/core/create_report.py index 976c13c2..348f41fe 100644 --- a/deepsearch/documents/core/create_report.py +++ b/deepsearch/documents/core/create_report.py @@ -71,6 +71,10 @@ def get_multiple_reports( writer = csv.writer(csvfile) writer.writerow(["batch_number", "task_id", "status", "document"]) + # Check if there are valid targets to iterate over + if len(task_ids) == 0: + raise ValueError("No task_ids resolved from input") + # start loop with tqdm( total=len(task_ids),