AashitaK commited on
Commit
5fa76e3
·
verified ·
1 Parent(s): f54029c

Update utils/file_utils.py

Browse files
Files changed (1) hide show
  1. utils/file_utils.py +16 -16
utils/file_utils.py CHANGED
@@ -154,24 +154,24 @@ def load_embeddings(database, database_filepath, embeddings_filepath):
154
  # Get the stored timestamp of the last database for which embeddings were generated
155
  timestamp_filepath = '/home/user/app/data/db_update_timestamp.txt'
156
  previous_timestamp = load_timestamp(timestamp_filepath)
157
- print("Prev timestamp", previous_timestamp)
158
- print("DB timestamp", database_timestamp)
159
- database_embeddings = load_pickle(embeddings_filepath)
160
- print("Embeddings loaded.")
161
 
162
- # # Check if the timestamp of the database file is different from the stored timestamp (DB_UPDATE_TIMESTAMP)
163
- # if database_timestamp == previous_timestamp:
164
- # # If the database file has not been updated, load the existing embeddings from the pickle file
165
- # database_embeddings = load_pickle(embeddings_filepath)
166
- # print("Embeddings loaded.")
167
- # else:
168
- # print("Embeddings updating.....")
169
- # # If the database file has been updated, generate new embeddings and save them to the embeddings file
170
- # database_embeddings = update_embeddings(database, embeddings_filepath)
171
 
172
- # # Update the stored timestamp
173
- # save_timestamp(database_timestamp, timestamp_filepath)
174
- # print("Embeddings updated.")
175
 
176
 
177
  return database_embeddings
 
154
  # Get the stored timestamp of the last database for which embeddings were generated
155
  timestamp_filepath = '/home/user/app/data/db_update_timestamp.txt'
156
  previous_timestamp = load_timestamp(timestamp_filepath)
157
+ # print("Prev timestamp", previous_timestamp)
158
+ # print("DB timestamp", database_timestamp)
159
+ # database_embeddings = load_pickle(embeddings_filepath)
160
+ # print("Embeddings loaded.")
161
 
162
+ # Check if the timestamp of the database file is different from the stored timestamp (DB_UPDATE_TIMESTAMP)
163
+ if database_timestamp == previous_timestamp:
164
+ # If the database file has not been updated, load the existing embeddings from the pickle file
165
+ database_embeddings = load_pickle(embeddings_filepath)
166
+ print("Embeddings loaded.")
167
+ else:
168
+ print("Embeddings updating.....")
169
+ # If the database file has been updated, generate new embeddings and save them to the embeddings file
170
+ database_embeddings = update_embeddings(database, embeddings_filepath)
171
 
172
+ # Update the stored timestamp
173
+ save_timestamp(database_timestamp, timestamp_filepath)
174
+ print("Embeddings updated.")
175
 
176
 
177
  return database_embeddings