fix type mismatches in download_manager service

This commit is contained in:
Lincoln Stein
2023-10-04 08:58:49 -04:00
parent de90d4068b
commit 16ec7a323b
3 changed files with 13 additions and 13 deletions

View File

@ -139,13 +139,13 @@ class DownloadQueueService(DownloadQueueServiceBase):
) -> DownloadJobBase: # noqa D102
event_handlers = event_handlers or []
if self._event_bus:
event_handlers.append([self._event_bus.emit_model_download_event]) # BUG! This is not a valid method call
event_handlers = [*event_handlers, self._event_bus.emit_model_event]
return self._queue.create_download_job(
source,
destdir,
filename,
start,
access_token,
source=source,
destdir=destdir,
filename=filename,
start=start,
access_token=access_token,
event_handlers=event_handlers,
)
@ -165,16 +165,16 @@ class DownloadQueueService(DownloadQueueServiceBase):
return self._queue.cancel_all_jobs()
def start_job(self, job: DownloadJobBase): # noqa D102
return self._queue.start_job(id)
return self._queue.start_job(job)
def pause_job(self, job: DownloadJobBase): # noqa D102
return self._queue.pause_job(id)
return self._queue.pause_job(job)
def cancel_job(self, job: DownloadJobBase): # noqa D102
return self._queue.cancel_job(id)
return self._queue.cancel_job(job)
def change_priority(self, job: DownloadJobBase, delta: int): # noqa D102
return self._queue.change_priority(id, delta)
return self._queue.change_priority(job, delta)
def join(self): # noqa D102
return self._queue.join()

View File

@ -291,11 +291,11 @@ class EventServiceBase:
payload=dict(queue_id=queue_id),
)
def emit_model_event(self, job: DownloadJobBase):
def emit_model_event(self, job: DownloadJobBase) -> None:
"""Emit event when the status of a download/install job changes."""
logger = InvokeAILogger.get_logger()
progress = 100 * (job.bytes / job.total_bytes) if job.total_bytes > 0 else 0
logger.info(f"Dispatch model_event for job {job.id}, status={job.status.value}, progress={progress:5.2f}%")
logger.debug(f"Dispatch model_event for job {job.id}, status={job.status.value}, progress={progress:5.2f}%")
self.dispatch( # use dispatch() directly here because we are not a session event.
event_name="model_event", payload=dict(job=job)
)

View File

@ -476,7 +476,7 @@ class ModelInstall(ModelInstallBase):
if not path.exists():
new_path = path
counter += 1
self._logger.warning('Use shutil.move(), not Path.replace() here; hash before and after move')
self._logger.warning("Use shutil.move(), not Path.replace() here; hash before and after move")
# BUG! This won't work across filesystems.
# Rehash before and after moving.
return old_path.replace(new_path)