From 6a30a133265dbb177f72c5ee2360b8ca89422f10 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Fri, 6 Jan 2023 16:57:59 -0300 Subject: [PATCH] Only create model directory if the optional field is set in SearchConfig --- src/search_type/text_search.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/search_type/text_search.py b/src/search_type/text_search.py index 5fd04470..816972cc 100644 --- a/src/search_type/text_search.py +++ b/src/search_type/text_search.py @@ -27,11 +27,12 @@ def initialize_model(search_config: TextSearchConfig): # Number of entries we want to retrieve with the bi-encoder top_k = 15 - # Convert model directory to absolute path - search_config.model_directory = resolve_absolute_path(search_config.model_directory) - - # Create model directory if it doesn't exist - search_config.model_directory.parent.mkdir(parents=True, exist_ok=True) + # If model directory is configured + if search_config.model_directory: + # Convert model directory to absolute path + search_config.model_directory = resolve_absolute_path(search_config.model_directory) + # Create model directory if it doesn't exist + search_config.model_directory.parent.mkdir(parents=True, exist_ok=True) # The bi-encoder encodes all entries to use for semantic search bi_encoder = load_model(