Skip to content

Commit

Permalink
fix: refuse to start if no models loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
tazlin committed Oct 4, 2023
1 parent b1cafb9 commit 7b43fc7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
16 changes: 16 additions & 0 deletions horde_worker_regen/process_management/inference_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,22 @@ def __init__(
except Exception as e:
logger.critical(f"Failed to initialise HordeCheckpointLoader: {type(e).__name__} {e}")

if SharedModelManager.manager.compvis is None:
logger.critical("Failed to initialise SharedModelManager")
self.send_process_state_change_message(
process_state=HordeProcessState.PROCESS_ENDED,
info="Failed to initialise compvis in SharedModelManager",
)
return

if SharedModelManager.manager.compvis.available_models == 0:
logger.critical("No models available in SharedModelManager")
self.send_process_state_change_message(
process_state=HordeProcessState.PROCESS_ENDED,
info="No models available in SharedModelManager",
)
return

logger.info("HordeInferenceProcess initialised")

self.send_process_state_change_message(
Expand Down
11 changes: 11 additions & 0 deletions horde_worker_regen/process_management/process_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,17 @@ def __init__(
time.sleep(5)

def is_time_for_shutdown(self) -> bool:
if all(
inference_process.last_process_state == HordeProcessState.PROCESS_ENDING
or inference_process.last_process_state == HordeProcessState.PROCESS_ENDED
for inference_process in [
inference_process
for inference_process in self._process_map.values()
if inference_process.process_type == HordeProcessKind.INFERENCE
]
):
return True

if len(self.completed_jobs) > 0:
return False

Expand Down

0 comments on commit 7b43fc7

Please sign in to comment.