Skip to content

fix(generate): skip local model validation when default_remote is set#4

Merged
aladac merged 1 commit into
masterfrom
feat/generate-respect-default-remote
May 20, 2026
Merged

fix(generate): skip local model validation when default_remote is set#4
aladac merged 1 commit into
masterfrom
feat/generate-respect-default-remote

Conversation

@aladac
Copy link
Copy Markdown
Member

@aladac aladac commented May 20, 2026

Symptom

$ tsr generate -m obsessiveCompulsive_v20.safetensors "a cat on a table"
Model 'obsessiveCompulsive_v20.safetensors' not available on ComfyUI host
(looked in checkpoints/ — 2 entries)
Did you mean:
  flux_dev.safetensors

…even though config has default_remote = "runpod" and the model exists on the pod.

Root cause

Two validation gates in generate() / _run_generation() used the raw remote CLI flag instead of the resolved remote URL:

line guard
cli.py:1083 if model and not remote:
cli.py:1403 if model and not json_output and not remote:

When -r is omitted but default_remote is set in config, both treat the run as local and call _validate_model_availableget_loaded_models() against the local [comfyui].url (often a stale LAN address or empty). The actual dispatch ~100 lines later DOES respect default_remote, so the request would have worked if validation hadn't fired first.

Fix

Both gates now use do_resolve_remote(remote) — returns the resolved URL when default_remote is set even if -r was omitted, so the local validation is skipped and the server-side validator on the remote tensors API takes over. Matches the intent already documented in the comment block: "Skipped in --json mode and for remote dispatches (server already validates)."

Also dedupes the do_resolve_remote import in _run_generation — moved to top of function instead of inline mid-body.

Validation

  • uv run pytest tests/ -x → 374 passed
  • uv run ruff check tensors/cli.py → All checks passed
  • uv run ruff format --check tensors/cli.py → already formatted
  • uv run mypy tensors/cli.py → no issues
  • End-to-end: tsr generate -m obsessiveCompulsive_v20.safetensors "a cat on a table" -o /tmp/cat.png from chi@fuji (no -r flag) → 1024×1024 PNG written, dispatched through pod's tensors API.

'tsr generate -m <model> ...' without an explicit -r/--remote flag was
running _validate_model_available() against the local [comfyui] url
even when config.toml had default_remote pointing at a different host.
On a typical operator setup (default_remote = 'runpod', local comfyui
url stale or empty) this fails with 'Model X not available on ComfyUI
host (looked in checkpoints/ — 2 entries)' even though the model
exists on the remote and would be reachable for the actual dispatch
a few hundred lines later.

Root cause: two validation gates used the raw 'remote' parameter
(CLI flag only) instead of the resolved remote URL:
  - generate(): pre-fanout validation for --parallel-queue path
  - _run_generation(): per-call validation

Both now use do_resolve_remote(remote), which returns the resolved
URL when default_remote is set even if -r was omitted. The server-
side validator on the remote tensors API still catches missing
models on the remote host — matches the intent already documented
in the comment block.
@aladac aladac merged commit 7144b7a into master May 20, 2026
3 checks passed
@aladac aladac deleted the feat/generate-respect-default-remote branch May 20, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants