Skip to content

Commit

Permalink
Missing imports and self keyword
Browse files Browse the repository at this point in the history
Added import for logging.
Added self parameter to pass reference to current instance object.
  • Loading branch information
Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed Nov 9, 2023
1 parent 408cad3 commit 7d5b5d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions emission/core/get_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import pymongo
import os
import json
import logging

try:
config_file = open('conf/storage/db.conf')
Expand Down
8 changes: 4 additions & 4 deletions emission/storage/modifiable/builtin_model_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ def __init__(self, user_id):
self.user_query = {"user_id": self.user_id} # UUID is mandatory for this version
self.current_model = None

def _get_model():
def _get_model(self):
return self.current_model

def _set_model(model):
def _set_model(self, model):
self.current_model = model

def upsert_model(self, key:str, model: ecwb.WrapperBase):
Expand All @@ -41,7 +41,7 @@ def get_current_model(self, key:str) -> Optional[Dict]:
:return: the most recent database entry for this key
"""
find_query = {"user_id": self.user_id, "metadata.key": key}
result_it = _get_model()
result_it = self._get_model()
if result_it == None:
logging.debug("Started model load in builtin_model_storage.get_current_model()...")
result_it = edb.get_model_db().find(find_query).sort("metadata.write_ts", -1).limit(1)
Expand All @@ -50,7 +50,7 @@ def get_current_model(self, key:str) -> Optional[Dict]:
# everything below this point is identical
# but it is also fairly trivial, so I am not sure it is worth pulling
# out into common code at this point
_set_model(result_it)
self._set_model(result_it)
logging.debug("Finished model load in builtin_model_storage.get_current_model()...")
logging.debug("Fetched model in builtin_model_storage.get_current_model()...")
result_list = list(result_it)
Expand Down

0 comments on commit 7d5b5d2

Please sign in to comment.