diff --git a/core/dit_hooks.py b/core/dit_hooks.py index 1cdf1b5c..0a2a91a0 100644 --- a/core/dit_hooks.py +++ b/core/dit_hooks.py @@ -248,7 +248,10 @@ def target_rows(mod_segments, seq_len, device, stream): for _spec, provider in registry.current().providers("target_rows"): try: mask = provider(mod_segments, seq_len, device, stream) - except Exception: # noqa: BLE001 + except Exception as exc: # noqa: BLE001 + from . import log + log.once(f"provider:target_rows:{_spec.id}:{type(exc).__name__}", log.WARNING, f"target_rows provider {_spec.id}", + f"failed while answering -- {type(exc).__name__}: {exc}") # skipped, but the callers' "could not find the rows" now has a cause continue if mask is not None: return mask diff --git a/core/tests/test_registry.py b/core/tests/test_registry.py index f49b03c3..d0663db6 100644 --- a/core/tests/test_registry.py +++ b/core/tests/test_registry.py @@ -274,3 +274,19 @@ def test_a_provider_that_fails_in_a_new_way_is_said_again(): reg.ask("cap"); reg.ask("cap") said = [r["message"] for r in log.history() if "failed while answering" in r["message"]] assert len(said) == 2 and "ValueError" in said[0] and "MemoryError" in said[1] + + +def test_the_same_kind_of_failure_with_new_text_every_call_is_said_once(): + """The spam guard: a provider asked on every sampling step must not fill the log.""" + from core import log + from core.schema import validate + log._reset() + n = iter(range(100)) + + def noisy(): + raise ValueError(f"row {next(n)}") + reg = registry_mod.Registry() + reg.add(validate({"id": "noisy", "title": "N", "mount": "m", "provides": {"cap": noisy}}, source="a")) + for _ in range(30): + reg.ask("cap") + assert len([r for r in log.history() if "failed while answering" in r["message"]]) == 1 diff --git a/modules/sampling/modifiers/nodes.py b/modules/sampling/modifiers/nodes.py index 6d8eec1c..16096a43 100644 --- a/modules/sampling/modifiers/nodes.py +++ b/modules/sampling/modifiers/nodes.py @@ -276,7 +276,7 @@ class FunPackLoadModifiers(io.ComfyNode): known = registry_mod.current().specs for module_id in (settings or {}): if module_id not in known and module_id not in control_mod.RESERVED: - log.once(f"stale_module:{module_id}", log.WARNING, "FunPack Load Modifiers", + log.once(f"stale_module_load:{module_id}", log.WARNING, "FunPack Load Modifiers", f"saved settings for {module_id!r} ignored: no module with that id is loaded") for spec in ordered: values, said = schema_mod.check_values(