Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update comfyui to dccca1 #190

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hordelib/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from hordelib.config_path import get_hordelib_path

COMFYUI_VERSION = "c5a369a33ddb622827552716d9b0119035a2e666"
COMFYUI_VERSION = "dccca1daa5af1954d55918f365e83a3331019549"
"""The exact version of ComfyUI version to load."""

REMOTE_PROXY = ""
Expand Down
16 changes: 15 additions & 1 deletion hordelib/horde.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ def _final_pipeline_adjustments(self, payload, pipeline_data):
),
)
continue

logger.debug(f"Found valid lora{verstext} {lora_name}")
if SharedModelManager.manager.compvis is None:
raise RuntimeError("Cannot use LORAs without a compvis loaded!")
Expand Down Expand Up @@ -783,7 +784,20 @@ def _inference(

# Call the inference pipeline
# logger.debug(payload)
images = self.generator.run_image_pipeline(pipeline_data, payload)
try:
images = self.generator.run_image_pipeline(pipeline_data, payload)
finally:
# This ensures that the lora failure list is flushed after each inference (even if it fails)
loras_failed = SharedModelManager.manager.get_lora_failures()

for lora in loras_failed:
faults.append(
GenMetadataEntry(
type=METADATA_TYPE.lora,
value=METADATA_VALUE.parse_failed,
ref=lora,
),
)

results = self._process_results(images)
ret_results = [
Expand Down
20 changes: 20 additions & 0 deletions hordelib/model_manager/hyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,26 @@ def models(self) -> dict:
of the model object and whether it was loaded with Loras.
"""

_lora_failures: list[str] = []

def add_lora_failure(self, lora_name: str) -> None:
"""Adds a Lora failure to the list of failures.

Args:
lora_name (str): The Lora name to add.
"""
self._lora_failures.append(lora_name)

def get_lora_failures(self) -> list[str]:
"""Returns the list of Lora failures.

Returns:
list[str]: The list of Lora failures.
"""
returned_failures = self._lora_failures.copy()
self._lora_failures = []
return returned_failures

def get_available_models(
self,
mm_include: Iterable[str | MODEL_CATEGORY_NAMES | type[BaseModelManager]] | None = None,
Expand Down
20 changes: 14 additions & 6 deletions hordelib/nodes/node_lora_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import folder_paths
from loguru import logger

from hordelib.shared_model_manager import SharedModelManager


class HordeLoraLoader:
def __init__(self):
Expand Down Expand Up @@ -62,12 +64,18 @@ def load_lora(self, model, clip, lora_name, strength_model, strength_clip):
self.loaded_lora = None
del temp

if lora is None:
lora = comfy.utils.load_torch_file(lora_path, safe_load=True)
self.loaded_lora = (lora_path, lora)

model_lora, clip_lora = comfy.sd.load_lora_for_models(model, clip, lora, strength_model, strength_clip)
return (model_lora, clip_lora)
try:
with logger.catch(reraise=True):
if lora is None:
lora = comfy.utils.load_torch_file(lora_path, safe_load=True)
self.loaded_lora = (lora_path, lora)

model_lora, clip_lora = comfy.sd.load_lora_for_models(model, clip, lora, strength_model, strength_clip)
return (model_lora, clip_lora)
except Exception as e:
logger.error(f"Failed to load lora {lora_name}: {e}")
SharedModelManager.manager.add_lora_failure(lora_name)
return (model, clip)


NODE_CLASS_MAPPINGS = {"HordeLoraLoader": HordeLoraLoader}
8 changes: 8 additions & 0 deletions tests/test_internal_comfyui_failures.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ def test_lora_failure(

with pytest.raises(RuntimeError, match="Pipeline failed to run"):
hordelib_instance.basic_inference_single_image(data)

shared_model_manager.manager.add_lora_failure(lora_GlowingRunesAI)

with pytest.raises(RuntimeError, match="Pipeline failed to run"):
hordelib_instance.basic_inference_single_image(data)

assert len(shared_model_manager.manager._lora_failures) == 0

finally:
del os.environ["FAILURE_TEST"]
assert os.getenv("FAILURE_TEST", False) is False
Loading