diff --git a/graphistry/text_utils.py b/graphistry/text_utils.py index 1d83cb7a4e..4a3e4f33fa 100644 --- a/graphistry/text_utils.py +++ b/graphistry/text_utils.py @@ -272,10 +272,16 @@ def search_graph( def save_search_instance(self, savepath): from joblib import dump # type: ignore # need to make this onnx or similar - - self.build_index() - search = self.search_index - del self.search_index # can't pickle Annoy + try: + self.build_index() + search = self.search_index + del self.search_index # can't pickle Annoy + except Exception as e: + logger.exception(e) + logger.warn( + "Could not build index, saving without it. Run g.build_index() to build it later" + ) + search = None dump(self, savepath) self.search_index = search # add it back logger.info(f"Saved: {savepath}") @@ -285,5 +291,9 @@ def load_search_instance(self, savepath): from joblib import load # type: ignore # need to make this onnx or similar cls = load(savepath) - cls.build_index() + try: + cls.build_index() + except Exception as e: + logger.exception(e) + logger.warn("Could not build index, run g.build_index() to build it later") return cls