Files
ComfyUI/app/assets/semantics/step.py
Simon Pinfold e7eb7832b9 Do not stamp past references the reset could not classify
A reference whose file is on disk but whose path is under no configured root
was skipped so that a missing extra_model_paths.yaml could not strip tags off
assets that were merely out of view. But the step still finished successfully
and the version was still stamped, so restoring the root repaired nothing: the
step never ran again, and no other path re-derives an existing reference's
loader_path -- the scan only builds specs for paths it has not seen, and the
enricher computes a loader path without writing it back. The guard turned
destroying the data into never repairing it.

A step now reports whether it finished its work, and an unfinished one is not
stamped. A file that is simply gone still does not count as unfinished; that is
the scan's business under its own missing semantics.

Two ordering fixes in the scan around the same call:

The walk is handed the seeder's pause-aware checkpoint rather than a
cancel-only check. The seeder is paused while a prompt runs, so a check that
ignores pause left the reset statting the whole asset table during generation
while the status reported PAUSED.

Cancellation is checked immediately after the reset instead of after the prune.
Cancelling during a long reprojection otherwise fell through into the prune and
temp reconciliation, doing state-mutating work on a scan that had been told to
stop.
2026-08-18 11:34:34 -07:00

32 lines
789 B
Python

from dataclasses import dataclass
from typing import Callable
InterruptCheck = Callable[[], bool]
@dataclass
class StepResult:
"""What a step did. A falsy ``complete`` withholds the stamp, so the step runs again."""
@property
def complete(self) -> bool:
return True
class SemanticsStepInterrupted(Exception):
"""A step stopped early on request.
Its partial work stands -- steps are idempotent, so a resumed run repeats it
harmlessly -- but the version is not stamped, so the step runs again.
"""
@dataclass(frozen=True)
class SemanticsStep:
"""``apply`` must be idempotent, and must raise SemanticsStepInterrupted rather than return early."""
version: int
description: str
apply: Callable[[InterruptCheck | None], StepResult]