Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: patch in lora cache size env var support #76

Merged
merged 4 commits into from
Oct 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions hordelib/model_manager/lora.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class DOWNLOAD_SIZE_CHECK(StrEnum):

TESTS_ONGOING = os.getenv("TESTS_ONGOING", "0") == "1"

AIWORKER_LORA_CACHE_SIZE_DEFAULT = 10 * 1024 # 10GB


class LoraModelManager(BaseModelManager):
LORA_DEFAULTS = "https://raw.githubusercontent.com/Haidra-Org/AI-Horde-image-model-reference/main/lora.json"
Expand All @@ -49,12 +51,20 @@ def __init__(
self,
download_reference=False,
allowed_top_lora_storage=10240 if not TESTS_ONGOING else 1024,
allowed_adhoc_lora_storage=1024,
allowed_adhoc_lora_storage=AIWORKER_LORA_CACHE_SIZE_DEFAULT,
download_wait=False,
):
self.max_adhoc_disk = allowed_adhoc_lora_storage
try:
AIWORKER_LORA_CACHE_SIZE = os.getenv("AIWORKER_LORA_CACHE_SIZE")
if AIWORKER_LORA_CACHE_SIZE is not None:
self.max_adhoc_disk = int(AIWORKER_LORA_CACHE_SIZE)
logger.debug(f"AIWORKER_LORA_CACHE_SIZE is {self.max_adhoc_disk}")
except (ValueError, TypeError):
self.max_adhoc_disk = AIWORKER_LORA_CACHE_SIZE_DEFAULT

self._max_top_disk = allowed_top_lora_storage

self.max_adhoc_disk = allowed_adhoc_lora_storage
self._data = None
self._next_page_url = None
self._mutex = threading.Lock()
Expand Down