Skip to content

Commit

Permalink
feat: adds delete_adhoc_loras_over_limit()
Browse files Browse the repository at this point in the history
  • Loading branch information
db0 authored and tazlin committed Dec 11, 2024
1 parent 772fb9f commit a7e8d96
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions hordelib/model_manager/lora.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import copy
import glob
import hashlib
import json
Expand Down Expand Up @@ -960,6 +959,10 @@ def delete_unused_loras(self, timeout=0):
logger.warning(f"Expected to delete lora file {lora_filename} but it was not found.")
return loras_to_delete

def delete_adhoc_loras_over_limit(self):
while self.is_adhoc_cache_full():
self.delete_oldest_lora()

def delete_lora_files(self, lora_filename: str):
filename = os.path.join(self.model_folder_path, lora_filename)
if not os.path.exists(filename):
Expand Down Expand Up @@ -1044,7 +1047,7 @@ def reset_adhoc_loras(self):
self.save_cached_reference_to_disk()
logger.debug(
f"Finished lora reset. Added {len(self._adhoc_loras)} adhoc loras "
f"with a total size of {self.calculate_adhoc_loras_cache()}"
f"with a total size of {self.calculate_adhoc_loras_cache()}",
)

def get_lora_metadata(self, url: str) -> dict:
Expand Down

0 comments on commit a7e8d96

Please sign in to comment.