Compare commits

...

3 Commits

Author SHA1 Message Date
cd4afa2e89 add missing import 2024-04-14 22:52:18 -04:00
d5c6d3428f add a time.sleep() to unittest 2024-04-14 22:44:25 -04:00
9a03bc69bf added a more verbose assert to catch unittest error 2024-04-14 21:53:03 -04:00
2 changed files with 9 additions and 1 deletions

View File

@ -270,7 +270,7 @@ class DownloadQueueService(DownloadQueueServiceBase):
job.dest.parent.mkdir(parents=True, exist_ok=True)
job.download_path = job.dest
assert job.download_path
assert job.download_path is not None
# Don't clobber an existing file. See commit 82c2c85202f88c6d24ff84710f297cfc6ae174af
# for code that instead resumes an interrupted download.
@ -280,6 +280,9 @@ class DownloadQueueService(DownloadQueueServiceBase):
# append ".downloading" to the path
in_progress_path = self._in_progress_path(job.download_path)
# catch rare race condition that is appearing in unit tests.
assert in_progress_path.parent.exists(), f"Directory doesn't exist! in_progress_path={in_progress_path}; parent={in_progress_path.parent}"
# signal caller that the download is starting. At this point, key fields such as
# download_path and total_bytes will be populated. We call it here because the might
# discover that the local file is already complete and generate a COMPLETED status.

View File

@ -3,6 +3,7 @@ Test the model installer
"""
import platform
import time
import uuid
from pathlib import Path
from typing import Any, Dict
@ -255,6 +256,10 @@ def test_huggingface_download(mm2_installer: ModelInstallServiceBase, mm2_app_co
assert isinstance(bus, EventServiceBase)
assert store is not None
# test hypothesis that there is a race condition between
# creating temporary directory and downloading into it.
time.sleep(2)
job = mm2_installer.import_model(source)
job_list = mm2_installer.wait_for_installs(timeout=10)
assert len(job_list) == 1