-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(saving without an index present) #508
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. include a message |
||
logger.warn( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be |
||
"Could not build index, saving without it. Run g.build_index() to build it later" | ||
) | ||
search = None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why aren't we raising? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we detect the expected-to-fail scenario ahead of time, skip building in that scenario, and still raise for unexpected errors? This seems to catch too many exn cases otherwise and thus is known-wrong.. |
||
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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a way for us to know whether to build the index or not vs just doing it, e.g., current form is unclear how to maintain and handle otherwise |
||
logger.exception(e) | ||
logger.warn("Could not build index, run g.build_index() to build it later") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why aren't we raising? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we detect the expected-to-fail scenario ahead of time, skip building in that scenario, and still raise for unexpected errors? This seems to catch too many exn cases otherwise and thus is known-wrong.. |
||
return cls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a specific exn we can zero in on here for the expected case to OK?