Skip to content

Commit

Permalink
Adding cache delete method for model details (#989)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumar-shivam-ranjan authored Oct 30, 2024
2 parents 8316571 + 838d543 commit daef898
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ads/aqua/extension/model_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,13 @@ def put(self, id):

enable_finetuning = input_data.get("enable_finetuning")
task = input_data.get("task")
app=AquaModelApp()
self.finish(
AquaModelApp().edit_registered_model(
app.edit_registered_model(
id, inference_container, enable_finetuning, task
)
)
app.clear_model_details_cache(model_id=id)


class AquaModelLicenseHandler(AquaAPIhandler):
Expand Down
16 changes: 16 additions & 0 deletions ads/aqua/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,22 @@ def clear_model_list_cache(
}
return res

def clear_model_details_cache(self, model_id):
"""
Allows user to clear model details cache item
Returns
-------
dict with the key used, and True if cache has the key that needs to be deleted.
"""
res = {}
logger.info(f"Clearing _service_model_details_cache for {model_id}")
with self._cache_lock:
if model_id in self._service_model_details_cache:
self._service_model_details_cache.pop(key=model_id)
res = {"key": {"model_id": model_id}, "cache_deleted": True}

return res

@staticmethod
def list_valid_inference_containers():
containers = list(
Expand Down

0 comments on commit daef898

Please sign in to comment.