Refactor ComfyUI installation script to improve Python environment handling

- Replaced direct calls to `venv/bin/pip` with `python -m pip` to avoid execution errors on network mounts and improve compatibility.
- Introduced a new function `find_comfy_python` to locate the appropriate Python executable for ComfyUI installations.
- Updated the `pip_install_sage` function to utilize the new Python handling, enhancing installation reliability.
- Added tests to verify the new behavior of Python environment detection and installation processes, ensuring robustness.
This commit is contained in:
Leonid Pershin
2026-08-21 10:01:42 +03:00
parent 3e0a51cac4
commit 26f3be6e96
3 changed files with 190 additions and 21 deletions
+98
View File
@@ -0,0 +1,98 @@
# Project Review — 2026-08-21 (4)
Фокус: скрытые логические инверсии / wait-forever / billing (как idle≠running).
## Prior Reviews Summary
> Based on `2026-08-21-review-3`, `review-2`, `review-1`.
### Still Open (carried forward)
None.
### Resolved Since Last Review
None newly verified in this pass (prior reviews already all `[x]`).
---
## Phase 1: Code Quality
### SOLID
No issues found.
### Performance
No issues found beyond existing network-disk `du` / walk costs (acceptable).
### Correctness & Bugs
1. **Bug (critical)** — idle-killer treats SwarmUI `backend_status=empty` as not busy — `src/gpu_rent/remote/idle_killer.py` `swarm_busy()`. During first Comfy install (1540+ min) status can stay `empty`/`unknown` with empty queue; after grace the idle clock can delete the VM mid-install. Same class as treating wrong Swarm status as “done”.
2. **Bug (critical)** — Ollama pull marker expires at 45m while pull timeout is 7200s — `src/gpu_rent/remote/idle_killer.py` `llm_busy()` + `src/gpu_rent/remote/ollama_pull.py`. Marker timestamp is written once and never refreshed; after 45m killer clears it and may stop GPU during a long pull.
3. **Bug (critical)**`seed_autocomplete` can overwrite entire `Settings.fds``src/gpu_rent/provision.py` `seed_autocomplete()`. If meta exists without `settings_applied=true`, `put_text` replaces Settings with only AutoComplete stub — wipes `IsInstalled` / other settings.
4. **Bug (high)**`wait_backend_idle` treats SwarmUI `idle` as forever BUSY with no wake — `src/gpu_rent/ready.py`. After auto-suspend, backends report `idle` (cannot generate) and never become `running` without a wake; `up` can burn the full timeout.
5. **Bug (high)**`install_swarm_comfy` skip path still labels Swarm `idle` as “already Idle” — `src/gpu_rent/remote/install_swarm_comfy.py` `main()`. Misleading; should skip because backends exist, then align with wake/`running` wait.
6. **Bug (high)** — local tunnel verify forces OK on TCP-only — `src/gpu_rent/ready.py` `verify_stack_local()`. If `GET /` and API fail, still `ok=True` with `TCP :port open` — marks tunnel ready when SwarmUI is dead.
7. **Bug (high)** — torch without CUDA polls 600s — `src/gpu_rent/remote/stack_env_probe.py` + `verify_gpu_env`. Instant-fail covers driver/libcuda/empty dlbackend, but not “torch imported, cuda=False” (CPU wheel wont heal).
8. **Bug (high)** — perf tune execs `venv/bin/pip``OSError: Exec format error``src/gpu_rent/remote/tune_swarm_perf.py` `pip_install_sage()`. Observed on live up; OSError not caught → script exit 1; sageattention missing. **Fixing in this session via `python -m pip`.**
9. **Bug (medium)** — access card / open use `resolve_llm_runtime` (notes override) but tunnel uses cfg only — `access_card.py` vs `tunnel.py`. Can advertise Ollama URLs with no forward.
10. **Bug (medium)**`status` tunnel check only probes SwarmUI local port — `cli.py`. llm-only looks like “туннель нет”.
11. **Bug (medium)** — tunnel Nova poll soft-fail returns fake `ACTIVE``tunnel.py` `_poll_nova()`. Masks DELETED/ERROR.
### Code Quality
No separate issues beyond the above.
---
## Phase 2: Logical Consistency
### Domain & Application Layer
No issues found.
### Data Flow
See #9 (cfg vs notes for LLM runtime).
### State Management
See #1#2 (busy markers / status semantics).
### Consistency
SwarmUI status vocabulary (`running` / `idle` / `empty` / `loading`) was inconsistent across wait vs killer; `running`=ready is fixed, remaining gaps in #1/#4/#5.
---
## Phase 3: UI/UX
### Usability
Access card correctly deferred until tunnel (recent change). Mid-up wait messages improved.
### Visual & Consistency
No issues found.
### Interaction & Feedback
Perf tune failure was noisy traceback then continued — should be WARN without stack (addressed with OSError catch + `-m pip`).
### Accessibility
N/A (CLI).
---
## Tasks
- [ ] 1. [Bug] Treat SwarmUI `empty` (and likely `disabled` during provision) as busy in idle-killer — `src/gpu_rent/remote/idle_killer.py` `swarm_busy`
- [ ] 2. [Bug] Refresh `.gpu-rent-ollama-pulling` during pull and/or raise stale max-age ≥ pull timeout (7200s) — `src/gpu_rent/remote/idle_killer.py` + `ollama_pull.py`
- [ ] 3. [Bug] Never overwrite full `Settings.fds` in autocomplete seed — merge AutoComplete only — `src/gpu_rent/provision.py` `seed_autocomplete`
- [ ] 4. [Bug] On wait, wake suspended backends or accept healthy path when status=`idle` after install; dont burn 2400s — `src/gpu_rent/ready.py` `wait_backend_idle`
- [ ] 5. [Bug] Fix `install_swarm_comfy` skip wording/logic for `idle` vs backends-present — `src/gpu_rent/remote/install_swarm_comfy.py`
- [ ] 6. [Bug] `verify_stack_local`: do not mark SwarmUI ok on TCP-only when HTTP/API fail — `src/gpu_rent/ready.py`
- [ ] 7. [Bug] Fail-fast when Comfy torch imports but `cuda=False``stack_env_probe.py` / `verify_gpu_env`
- [x] 8. [Bug] Perf tune: use `python -m pip` (not `venv/bin/pip`) and catch OSError — `src/gpu_rent/remote/tune_swarm_perf.py`
- [ ] 9. [Logic] Single source of truth for LLM runtime in access card vs tunnel — `access_card.py` / `tunnel.py`
- [ ] 10. [UX] `status` should probe ports from `tunnel_forwards(cfg)``cli.py`
- [ ] 11. [Bug] Tunnel Nova soft-fail must not fake ACTIVE forever — `tunnel.py` `_poll_nova`