From ccb58bf431518a43a18496d06df93a50c520a2cf Mon Sep 17 00:00:00 2001 From: Tony Salomone Date: Thu, 19 Dec 2024 15:52:41 -0500 Subject: [PATCH] Don't crash if model download percentage update fails. --- transformerlab/shared/download_huggingface_model.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/transformerlab/shared/download_huggingface_model.py b/transformerlab/shared/download_huggingface_model.py index ef291e2..ab087e7 100644 --- a/transformerlab/shared/download_huggingface_model.py +++ b/transformerlab/shared/download_huggingface_model.py @@ -199,8 +199,13 @@ def check_disk_size(model_is_downloaded: Event): db = sqlite3.connect( f"{WORKSPACE_DIR}/llmlab.sqlite3", isolation_level=None) - db.execute( - "UPDATE job SET job_data=json_set(job_data, '$.downloaded', ?), progress=? WHERE id=?", (cache_size_growth, progress, job_id)) + try: + db.execute( + "UPDATE job SET job_data=json_set(job_data, '$.downloaded', ?), progress=? WHERE id=?", (cache_size_growth, progress, job_id)) + except sqlite3.OperationalError: + # Bit of a hack: We were having DB lock errors and this update isn't crucial + # So for now just skip if something goes wrong. + print(f"Failed to update download progress in DB ({progress}%). Skipping.") db.close() print(f"flag: {model_is_downloaded.is_set()}")