Enhance backend configuration and sanitization logic

- Updated the `recover_errored_backends` function to preserve `ExtraArgs` during backend reconfiguration, improving error recovery.
- Refined the `sanitize_backends_fds` function to prevent newline merging issues with bare `\\x` entries, ensuring correct FDS formatting.
- Enhanced the `configure_comfy_backend` function to accept and manage `ExtraArgs`, preventing loss of important configuration during recovery.
- Added tests to validate the new sanitization behavior and ensure that bare `\\x` entries remain intact, improving overall backend management.
This commit is contained in:
Leonid Pershin
2026-08-21 11:50:01 +03:00
parent 021feaa839
commit b9059cd275
3 changed files with 41 additions and 22 deletions
+11
View File
@@ -178,6 +178,17 @@ def test_sanitize_backends_fds_corruption(tmp_path, monkeypatch):
assert backends.read_text(encoding="utf-8") == "ExtraArgs: --use-sage-attention\n"
def test_sanitize_does_not_eat_newline_on_bare_empty(tmp_path, monkeypatch):
"""Bare FDS empty ``\\x`` must not match — ``\\s+`` would merge next key."""
mod = _load()
backends = tmp_path / "Backends.fds"
original = "\tExtraArgs: \\x\n\tStartScript: /mnt/swarm_data/dlbackend/ComfyUI/main.py\n"
backends.write_text(original, encoding="utf-8")
monkeypatch.setattr(mod, "BACKENDS", backends)
assert mod.sanitize_backends_fds() is False
assert backends.read_text(encoding="utf-8") == original
def test_ensure_absolute_start_script(tmp_path, monkeypatch):
mod = _load()
data = tmp_path