From 84c1fc701d6e833aa4d945bde135d8e4cdd41a0b Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Tue, 9 Aug 2022 21:01:14 +0300 Subject: [PATCH] Fix query timing variables from being referenced before assignment --- src/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.py b/src/main.py index f2bc7db9..ab36420c 100644 --- a/src/main.py +++ b/src/main.py @@ -69,10 +69,12 @@ def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None, r: Opti print(f'No query param (q) passed in API call to initiate search') return {} + # initialize variables device = torch.device("cuda:0") if torch.cuda.is_available() else torch.device("cpu") user_query = q results_count = n results = {} + query_start, query_end, collate_start, collate_end = None, None, None, None if (t == SearchType.Org or t == None) and model.orgmode_search: # query org-mode notes @@ -136,8 +138,10 @@ def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None, r: Opti collate_end = time.time() if verbose > 1: - print(f"Query took {query_end - query_start:.3f} seconds") - print(f"Collating results took {collate_end - collate_start:.3f} seconds") + if query_start and query_end: + print(f"Query took {query_end - query_start:.3f} seconds") + if collate_start and collate_end: + print(f"Collating results took {collate_end - collate_start:.3f} seconds") return results