From 930e6782876a18939308edb1575a2193fd9d158f Mon Sep 17 00:00:00 2001 From: Kristof Van Tricht Date: Thu, 17 Oct 2024 12:43:13 +0200 Subject: [PATCH] Catch an empty df and throw error --- src/worldcereal/utils/refdata.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/worldcereal/utils/refdata.py b/src/worldcereal/utils/refdata.py index 6fcb3e68..bd9067f0 100644 --- a/src/worldcereal/utils/refdata.py +++ b/src/worldcereal/utils/refdata.py @@ -333,9 +333,14 @@ def process_parquet( public_df_raw["valid_date"] = public_df_raw["sample_id"].map( sample_dates.set_index("sample_id")["proposed_valid_date"] ) - logger.warning( - f"Removed {invalid_samples.shape[0]} samples that do not fit into selected temporal extent." - ) + if public_df_raw.empty: + error_msg = "None of the samples matched the proposed temporal extent. Please select a different temporal extent." + logger.error(error_msg) + raise ValueError(error_msg) + else: + logger.warning( + f"Removed {invalid_samples.shape[0]} samples that do not fit into selected temporal extent." + ) public_df = process_parquet_for_presto(public_df_raw)