Fixed model cache loader
Some checks reported errors
continuous-integration/drone/push Build was killed
Some checks reported errors
continuous-integration/drone/push Build was killed
This commit is contained in:
parent
be361a7c18
commit
d17ab9d401
@ -78,14 +78,25 @@ class ClassifierCache:
|
||||
|
||||
model_details = r.json()
|
||||
|
||||
if (not self._current_model_details) or (self._current_model_details['id'] != model_details['id']):
|
||||
logging.info(f"Model needs to be loaded (local: {self._current_model_details['id']} model service default: {model_details['id']})")
|
||||
if ('id' not in model_details) or not model_details['id']:
|
||||
raise KeyError("Model info is invalid!")
|
||||
|
||||
current_model_id = None
|
||||
if self._current_model_details:
|
||||
current_model_id = self._current_model_details['id']
|
||||
|
||||
if current_model_id != model_details['id']:
|
||||
logging.info(
|
||||
f"Model needs to be loaded (local: {current_model_id}; modelsvc def: {model_details['id']})"
|
||||
)
|
||||
# If the currently loaded model is not the default... then load it
|
||||
self._cleanup() # delete/unload everything
|
||||
self._download_and_load_model(model_details['files']['model'], model_details['files']['weights'])
|
||||
self._current_model_details = model_details
|
||||
else:
|
||||
logging.debug(f"Currently loaded model seems up to date ({self._current_model_details['id']} == {model_details['id']})")
|
||||
logging.debug(
|
||||
f"Currently loaded model seems up to date ({current_model_id} == {model_details['id']})"
|
||||
)
|
||||
|
||||
else:
|
||||
logging.debug("Cache is still valid. Not fetching model info")
|
||||
|
Loading…
Reference in New Issue
Block a user