Skip to content

Commit

Permalink
fix: calculating uptime kudos shouldn't crash scribe
Browse files Browse the repository at this point in the history
fixes #195
  • Loading branch information
db0 committed May 15, 2023
1 parent aec084c commit 5189b24
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
11 changes: 9 additions & 2 deletions worker/workers/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,19 @@ def check_running_job_status(self, job_thread, start_time, job):
self.bridge_data.stats_output_frequency
and (time.time() - self.last_stats_time) > self.bridge_data.stats_output_frequency
):
# Calculate uptime bonus (*6 as this calc is per 10 minutes of uptime)
bonus_per_hour = (50 + (len(self.model_manager.get_loaded_models_names()) * 2)) * 6
bonus_per_hour = self.get_uptime_kudos()
self.last_stats_time = time.time()
kph = bridge_stats.stats.get('kudos_per_hour', 0) + bonus_per_hour
logger.info(f"Estimated average kudos per hour: {kph}")

def get_uptime_kudos(self):
'''Returns the expected uptime kudos for this worker
This should be extended for each type of worker
'''
# *6 as this calc is per 10 minutes of uptime
return 50 * 6


def reload_data(self):
"""This is just a utility function to reload the configuration"""
self.bridge_data.reload_data()
Expand Down
3 changes: 3 additions & 0 deletions worker/workers/interrogation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ def reload_data(self):
super().reload_data()
self.bridge_data.check_models(self.model_manager)
self.bridge_data.reload_models(self.model_manager)

def get_uptime_kudos(self):
return 40 * 6
18 changes: 18 additions & 0 deletions worker/workers/stable_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from worker.jobs.stable_diffusion import StableDiffusionHordeJob
from worker.logger import logger
from worker.workers.framework import WorkerFramework
from worker.consts import KNOWN_INTERROGATORS, POST_PROCESSORS_HORDELIB_MODELS


class StableDiffusionWorker(WorkerFramework):
Expand Down Expand Up @@ -104,3 +105,20 @@ def reload_bridge_data(self):
trace = "".join(traceback.format_exception(type(err), err, err.__traceback__))
logger.trace(trace)
super().reload_bridge_data()

def get_uptime_kudos(self):
# *6 as this calc is per 10 minutes of uptime
available_models = self.model_manager.get_loaded_models_names()
# FIXME: pass MMs to exclude when get_loaded_models_names() updated in hordelib
for util_model in (
list(KNOWN_INTERROGATORS)
+ list(POST_PROCESSORS_HORDELIB_MODELS)
+ [
"LDSR",
"safety_checker",
]
):
if util_model in available_models:
available_models.remove(util_model)

return (50 + (len(self.model_manager.get_loaded_models_names()) * 2)) * 6

0 comments on commit 5189b24

Please sign in to comment.