Merge pull request #2031 from Zedai00/main

Update models.py to create models directory when its not present
This commit is contained in:
Tekky 2024-06-05 13:13:57 +01:00 committed by GitHub
commit 87a96ce0d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -37,8 +37,10 @@ def get_model_dir() -> str:
local_dir = os.path.dirname(os.path.abspath(__file__))
project_dir = os.path.dirname(os.path.dirname(local_dir))
model_dir = os.path.join(project_dir, "models")
if os.path.exists(model_dir):
return model_dir
if not os.path.exists(model_dir):
os.mkdir(model_dir)
return model_dir
def get_models() -> dict[str, dict]:
model_dir = get_model_dir()
@ -48,4 +50,4 @@ def get_models() -> dict[str, dict]:
else:
models = load_models()
save_models(file_path, models)
return models
return models