[PR #140] feat(models): add model_provider, strict_mode and fallback_provider to run() #140

Open
opened 2026-10-31 22:01:44 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/comfy-python-sdk/pull/140
Author: @deepme987
Created: 9/10/2026
Status: 🔄 Open

Base: main ← Head: deep/model-provider-strict-mode-fallback


📝 Commits (1)

  • 4253a30 feat(models): add model_provider, strict_mode and fallback_provider to run()

📊 Changes

8 files changed (+289 additions, -16 deletions)

View changed files

📝 CHANGELOG.md (+12 -0)
📝 README.md (+30 -0)
📝 spec/router-openapi.yaml (+27 -0)
📝 src/comfy_low/transport.py (+52 -3)
📝 src/comfy_sdk/models.py (+42 -5)
📝 tests/conftest.py (+21 -8)
📝 tests/test_models_run.py (+99 -0)
📝 tests/test_models_run_retry.py (+6 -0)

📄 Description

Summary

  • Comfy Router's provider-selection surface (model_provider/strict_mode, renamed from comfy_provider/comfy_strict on 2026-09-10) and fallback_provider add three query params to POST /v2/models/{provider}/{model} — this SDK had none of them.
  • Adds model_provider, strict_mode and fallback_provider as optional keyword-only params on Models.run/AsyncModels.run, threaded through post_model_run and the sans-IO model_run_request builder. All three default to None, which omits the query param entirely — an existing caller's request is byte-for-byte unchanged.
  • fallback_provider has an inverted sense on the wire: Router defaults it ON, so only fallback_provider=False ever reaches the query string.
  • Fixes a pre-existing gap in the test stub's model-run route matcher, which never stripped a query string before matching the two path segments (nothing sent one before this PR).
  • Updates the vendored spec/router-openapi.yaml (new ModelProvider/StrictMode/FallbackProvider parameter components) so scripts/check_drift.py's contract stays honest, plus the README and CHANGELOG.

Companion server-side implementation: Comfy-Org/cloud#8538.

Test plan

  • uv run pytest -q — 726 passed, 4 pre-existing skips
  • uv run ruff check src/ tests/ — clean
  • uv run ruff format --check src/ tests/ — clean
  • uv run mypy src/ — clean
  • uv run python scripts/check_drift.py — clean (models/spec sync, router error types, bound route)
  • New tests: per-param wire assertions (model_provider, strict_mode true/false, fallback_provider false-only-on-wire, fallback_provider=True is a no-op), the async client, the sans-IO builder directly, and a full round trip still returning the provider's native payload

Summary by CodeRabbit

  • New Features

    • Added optional model provider selection for synchronous and asynchronous model runs.
    • Added strict-mode controls for native schema handling.
    • Added optional fallback-provider behavior, with parameters omitted unless configured.
    • Preserved existing defaults, retry behavior, idempotency, and result handling.
  • Documentation

    • Documented the new model-run options, defaults, provider selection, schema handling, and fallback behavior.
  • Tests

    • Added coverage for synchronous and asynchronous requests, query serialization, defaults, and fallback settings.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/comfy-python-sdk/pull/140 **Author:** [@deepme987](https://github.com/deepme987) **Created:** 9/10/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `deep/model-provider-strict-mode-fallback` --- ### 📝 Commits (1) - [`4253a30`](https://github.com/Comfy-Org/comfy-python-sdk/commit/4253a304104fcfd73e31c8f4f6bb7afdd822c0b4) feat(models): add model_provider, strict_mode and fallback_provider to run() ### 📊 Changes **8 files changed** (+289 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+12 -0) 📝 `README.md` (+30 -0) 📝 `spec/router-openapi.yaml` (+27 -0) 📝 `src/comfy_low/transport.py` (+52 -3) 📝 `src/comfy_sdk/models.py` (+42 -5) 📝 `tests/conftest.py` (+21 -8) 📝 `tests/test_models_run.py` (+99 -0) 📝 `tests/test_models_run_retry.py` (+6 -0) </details> ### 📄 Description ## Summary - Comfy Router's provider-selection surface (`model_provider`/`strict_mode`, renamed from `comfy_provider`/`comfy_strict` on 2026-09-10) and `fallback_provider` add three query params to `POST /v2/models/{provider}/{model}` — this SDK had none of them. - Adds `model_provider`, `strict_mode` and `fallback_provider` as optional keyword-only params on `Models.run`/`AsyncModels.run`, threaded through `post_model_run` and the sans-IO `model_run_request` builder. All three default to `None`, which omits the query param entirely — an existing caller's request is byte-for-byte unchanged. - `fallback_provider` has an inverted sense on the wire: Router defaults it ON, so only `fallback_provider=False` ever reaches the query string. - Fixes a pre-existing gap in the test stub's model-run route matcher, which never stripped a query string before matching the two path segments (nothing sent one before this PR). - Updates the vendored `spec/router-openapi.yaml` (new `ModelProvider`/`StrictMode`/`FallbackProvider` parameter components) so `scripts/check_drift.py`'s contract stays honest, plus the README and CHANGELOG. Companion server-side implementation: [Comfy-Org/cloud#8538](https://github.com/Comfy-Org/cloud/pull/8538). ## Test plan - [x] `uv run pytest -q` — 726 passed, 4 pre-existing skips - [x] `uv run ruff check src/ tests/` — clean - [x] `uv run ruff format --check src/ tests/` — clean - [x] `uv run mypy src/` — clean - [x] `uv run python scripts/check_drift.py` — clean (models/spec sync, router error types, bound route) - [x] New tests: per-param wire assertions (`model_provider`, `strict_mode` true/false, `fallback_provider` false-only-on-wire, `fallback_provider=True` is a no-op), the async client, the sans-IO builder directly, and a full round trip still returning the provider's native payload <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added optional model provider selection for synchronous and asynchronous model runs. * Added strict-mode controls for native schema handling. * Added optional fallback-provider behavior, with parameters omitted unless configured. * Preserved existing defaults, retry behavior, idempotency, and result handling. * **Documentation** * Documented the new model-run options, defaults, provider selection, schema handling, and fallback behavior. * **Tests** * Added coverage for synchronous and asynchronous requests, query serialization, defaults, and fallback settings. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/comfy-python-sdk#140
No description provided.