tidy(download): _download_job -> _multifile_job

This commit is contained in:
psychedelicious 2024-06-03 10:15:53 +10:00
parent c58ac1e80d
commit aa9695e377
2 changed files with 7 additions and 7 deletions

View File

@ -162,7 +162,7 @@ class ModelInstallJob(BaseModel):
) )
# internal flags and transitory settings # internal flags and transitory settings
_install_tmpdir: Optional[Path] = PrivateAttr(default=None) _install_tmpdir: Optional[Path] = PrivateAttr(default=None)
_download_job: Optional[MultiFileDownloadJob] = PrivateAttr(default=None) _multifile_job: Optional[MultiFileDownloadJob] = PrivateAttr(default=None)
_exception: Optional[Exception] = PrivateAttr(default=None) _exception: Optional[Exception] = PrivateAttr(default=None)
def set_error(self, e: Exception) -> None: def set_error(self, e: Exception) -> None:

View File

@ -278,7 +278,7 @@ class ModelInstallService(ModelInstallServiceBase):
"""Cancel the indicated job.""" """Cancel the indicated job."""
job.cancel() job.cancel()
self._logger.warning(f"Cancelling {job.source}") self._logger.warning(f"Cancelling {job.source}")
if dj := job._download_job: if dj := job._multifile_job:
self._download_queue.cancel_job(dj) self._download_queue.cancel_job(dj)
def prune_jobs(self) -> None: def prune_jobs(self) -> None:
@ -514,9 +514,9 @@ class ModelInstallService(ModelInstallServiceBase):
self._signal_job_completed(job) self._signal_job_completed(job)
def _set_error(self, install_job: ModelInstallJob, excp: Exception) -> None: def _set_error(self, install_job: ModelInstallJob, excp: Exception) -> None:
download_job = install_job._download_job multifile_download_job = install_job._multifile_job
if download_job and any( if multifile_download_job and any(
x.content_type is not None and "text/html" in x.content_type for x in download_job.download_parts x.content_type is not None and "text/html" in x.content_type for x in multifile_download_job.download_parts
): ):
install_job.set_error( install_job.set_error(
InvalidModelConfigException( InvalidModelConfigException(
@ -748,7 +748,7 @@ class ModelInstallService(ModelInstallServiceBase):
submit_job=False, # Important! Don't submit the job until we have set our _download_cache dict submit_job=False, # Important! Don't submit the job until we have set our _download_cache dict
) )
self._download_cache[multifile_job.id] = install_job self._download_cache[multifile_job.id] = install_job
install_job._download_job = multifile_job install_job._multifile_job = multifile_job
files_string = "file" if len(remote_files) == 1 else "files" files_string = "file" if len(remote_files) == 1 else "files"
self._logger.info(f"Queueing model install: {source} ({len(remote_files)} {files_string})") self._logger.info(f"Queueing model install: {source} ({len(remote_files)} {files_string})")
@ -875,7 +875,7 @@ class ModelInstallService(ModelInstallServiceBase):
def _signal_job_downloading(self, job: ModelInstallJob) -> None: def _signal_job_downloading(self, job: ModelInstallJob) -> None:
if self._event_bus: if self._event_bus:
assert job._download_job is not None assert job._multifile_job is not None
assert job.bytes is not None assert job.bytes is not None
assert job.total_bytes is not None assert job.total_bytes is not None
self._event_bus.emit_model_install_download_progress(job) self._event_bus.emit_model_install_download_progress(job)