Skip to content

Commit

Permalink
Added function call
Browse files Browse the repository at this point in the history
Called the trim_model_entries function in upsert_model to delete models before inserting new ones.
  • Loading branch information
Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed Dec 11, 2023
1 parent 6ad61f6 commit 9d749f9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions emission/storage/modifiable/builtin_model_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ def upsert_model(self, key:str, model: ecwb.WrapperBase):
"""
logging.debug("upsert_doc called with key %s" % key)
entry = ecwe.Entry.create_entry(self.user_id, key, model)
## TODO: Cleanup old/obsolete models
# Cleaning up older models, before inserting new model
self.trim_model_entries(key)
logging.debug("Inserting entry %s into model DB" % entry)
ins_result = edb.get_model_db().insert_one(entry)
## TODO: Cleanup old/obsolete models
return ins_result.inserted_id

def get_current_model(self, key:str) -> Optional[Dict]:
Expand Down Expand Up @@ -60,7 +62,6 @@ def trim_model_entries(self, key:str):
find_query = {"user_id": self.user_id, "metadata.key": key}
result_it = edb.get_model_db().find(find_query).sort("metadata.write_ts", -1)
result_list = list(result_it)
print(len(result_list))

if current_model_count >= K_MODEL_COUNT:
# Specify the last or minimum timestamp of Kth model entry
Expand Down

0 comments on commit 9d749f9

Please sign in to comment.