Skip to content

Commit

Permalink
Add a status logger in modules.shared
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Jul 3, 2023
1 parent e430344 commit 522a8b9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys
import threading
import time
import logging

import gradio as gr
import torch
Expand All @@ -18,6 +19,8 @@
from ldm.models.diffusion.ddpm import LatentDiffusion
from typing import Optional

log = logging.getLogger(__name__)

demo = None

parser = cmd_args.parser
Expand Down Expand Up @@ -144,12 +147,15 @@ def wait_for_server_command(self, timeout: Optional[float] = None) -> Optional[s
def request_restart(self) -> None:
self.interrupt()
self.server_command = "restart"
log.info("Received restart request")

def skip(self):
self.skipped = True
log.info("Received skip request")

def interrupt(self):
self.interrupted = True
log.info("Received interrupt request")

def nextjob(self):
if opts.live_previews_enable and opts.show_progress_every_n_steps == -1:
Expand Down Expand Up @@ -189,8 +195,11 @@ def begin(self, job: str = "(unknown)"):
self.time_start = time.time()
self.job = job
devices.torch_gc()
log.info("Starting job %s", job)

def end(self):
duration = time.time() - self.time_start
log.info("Ending job %s (%.2f seconds)", self.job, duration)
self.job = ""
self.job_count = 0

Expand Down

0 comments on commit 522a8b9

Please sign in to comment.