From 2c4090462934044762bb97d2b8d0120aabd05ea9 Mon Sep 17 00:00:00 2001 From: chenmoneygithub Date: Fri, 27 Dec 2024 13:07:30 -0800 Subject: [PATCH 1/2] raise error when databricks index is not ready --- dspy/retrieve/databricks_rm.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dspy/retrieve/databricks_rm.py b/dspy/retrieve/databricks_rm.py index 249b3856d3..acb5c33b45 100644 --- a/dspy/retrieve/databricks_rm.py +++ b/dspy/retrieve/databricks_rm.py @@ -273,6 +273,11 @@ def forward( # Extracting the results items = [] + if "data_array" not in results["result"]: + raise ValueError( + "`data_array` not found in the results from the Databricks Vector Search Index. Please check if your " + "index is running." + ) for _, data_row in enumerate(results["result"]["data_array"]): item = {} for col_name, val in zip(col_names, data_row): From 31e66e6ce9849b8ea24c090376c34311034257cc Mon Sep 17 00:00:00 2001 From: chenmoneygithub Date: Fri, 27 Dec 2024 13:12:51 -0800 Subject: [PATCH 2/2] don't fail on non-existing data_array --- dspy/retrieve/databricks_rm.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/dspy/retrieve/databricks_rm.py b/dspy/retrieve/databricks_rm.py index acb5c33b45..0334154dd5 100644 --- a/dspy/retrieve/databricks_rm.py +++ b/dspy/retrieve/databricks_rm.py @@ -273,16 +273,12 @@ def forward( # Extracting the results items = [] - if "data_array" not in results["result"]: - raise ValueError( - "`data_array` not found in the results from the Databricks Vector Search Index. Please check if your " - "index is running." - ) - for _, data_row in enumerate(results["result"]["data_array"]): - item = {} - for col_name, val in zip(col_names, data_row): - item[col_name] = val - items += [item] + if "data_array" in results["result"]: + for _, data_row in enumerate(results["result"]["data_array"]): + item = {} + for col_name, val in zip(col_names, data_row): + item[col_name] = val + items += [item] # Sorting results by score in descending order sorted_docs = sorted(items, key=lambda x: x["score"], reverse=True)[: self.k]