From bac528d4cb8e015c4e7d983a5b82904d171e6d89 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Jun 2023 11:50:40 -0500 Subject: [PATCH] expose job_timeout in settings tab --- scripts/spartan/UI.py | 12 ++++++++++-- scripts/spartan/Worker.py | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/spartan/UI.py b/scripts/spartan/UI.py index 2e6194b..6a3e37a 100644 --- a/scripts/spartan/UI.py +++ b/scripts/spartan/UI.py @@ -63,9 +63,12 @@ class UI: return 'No active jobs!', worker_status - def save_btn(self, thin_client_mode): + def save_btn(self, thin_client_mode, job_timeout): self.world.thin_client_mode = thin_client_mode logger.debug(f"thin client mode is now {thin_client_mode}") + job_timeout = int(job_timeout) + self.world.job_timeout = job_timeout + logger.debug(f"job timeout is now {job_timeout} seconds") # end handlers @@ -107,8 +110,13 @@ class UI: info="Only generate images using remote workers. There will be no previews when enabled.", value=self.world.thin_client_mode ) + job_timeout = gradio.Number( + label='Job timeout', value=self.world.job_timeout, + info="Seconds until a worker is considered too slow to be assigned an" + "equal share of the total request. Longer than 2 seconds is recommended." + ) save_btn = gradio.Button(value='Save') - save_btn.click(fn=self.save_btn, inputs=[thin_client_cbx]) + save_btn.click(fn=self.save_btn, inputs=[thin_client_cbx, job_timeout]) return root diff --git a/scripts/spartan/Worker.py b/scripts/spartan/Worker.py index 534e210..130fa9a 100644 --- a/scripts/spartan/Worker.py +++ b/scripts/spartan/Worker.py @@ -368,8 +368,8 @@ class Worker: self.response_time = time.time() - start variance = ((eta - self.response_time) / self.response_time) * 100 - logger.debug(f"\nWorker '{self.uuid}'s ETA was off by {variance:.2f}%.\n") - logger.debug(f"Predicted {eta:.2f}s. Actual: {self.response_time:.2f}s\n") + logger.debug(f"\nWorker '{self.uuid}'s ETA was off by {variance:.2f}%.\n" + f"Predicted {eta:.2f}s. Actual: {self.response_time:.2f}s\n") # if the variance is greater than 500% then we ignore it to prevent variation inflation if abs(variance) < 500: