[PR #43] [MERGED] feat!: configure the base URL via COMFY_BASE_URL instead of a constructor argument #50

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

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/comfy-python-sdk/pull/43
Author: @wei-hai
Created: 8/11/2026
Status: ✅ Merged
Merged: 8/11/2026
Merged by: @wei-hai

Base: main ← Head: wei/be-6958-sdk-base-url-env-var


📝 Commits (4)

  • 95bd1ff feat!: configure the base URL via COMFY_BASE_URL, not a constructor argument
  • 6f4b204 fix: address review — reject malformed ports, document the migration
  • b8a2fcb fix: reject a base URL carrying a query or fragment
  • 3a8f21e test: stop mutating os.environ in the gateway fixture

📊 Changes

17 files changed (+284 additions, -128 deletions)

View changed files

📝 README.md (+35 -17)
📝 src/comfy_sdk/__init__.py (+7 -4)
📝 src/comfy_sdk/client.py (+56 -9)
📝 tests/conftest.py (+21 -3)
📝 tests/integration/test_gateway_e2e.py (+3 -3)
📝 tests/test_assets.py (+4 -4)
📝 tests/test_async.py (+13 -13)
📝 tests/test_auth_headers.py (+2 -2)
➕ tests/test_base_url_env.py (+103 -0)
📝 tests/test_content_redirect_security.py (+2 -2)
➖ tests/test_default_base_url.py (+0 -33)
📝 tests/test_download_and_workflows.py (+4 -4)
📝 tests/test_events.py (+5 -5)
📝 tests/test_get_download_url.py (+5 -5)
📝 tests/test_jobs.py (+18 -18)
📝 tests/test_sse_idle.py (+3 -3)
📝 tests/test_user_agent.py (+3 -3)

📄 Description

Comfy() / AsyncComfy() target Comfy Cloud; another deployment is selected with the COMFY_BASE_URL environment variable. The base-URL constructor parameter is removed, so an arbitrary endpoint is no longer part of the call surface.

Breaking: Comfy(base_url, api_key) → Comfy(api_key=...) + COMFY_BASE_URL. api_key is keyword-only now, so the old positional form raises TypeError instead of quietly reading a URL as a key.

The variable is read per construction (not at import), must be an http(s) URL, and unset-or-blank means Comfy Cloud.

Test suite: the server fixture points the SDK at the stub by setting the variable, so tests construct a bare Comfy(); an autouse fixture scrubs an ambient value so a developer's own shell can't aim the suite at a real deployment. That is most of the diff.

Scope: the public clients only. comfy_low (the documented escape hatch) still takes a base URL — it is what the clients build on.

Verified: ruff check, ruff format --check, mypy src, pytest (120 pass, 4 skipped).

Matching change in comfy-typescript-sdk keeps the two SDKs in lockstep.

Summary by CodeRabbit

  • New Features

    • Clients now use Comfy Cloud by default.
    • Select a self-hosted deployment with the COMFY_BASE_URL environment variable.
    • Base URL configuration is validated to accept only HTTP(S) addresses.
    • The base URL environment variable is publicly available for configuration.
    • API keys are provided as keyword arguments for synchronous and asynchronous clients.
  • Documentation

    • Updated setup, deployment, authentication, and async usage examples.
    • Clarified API-key requirements and cross-origin request restrictions.

🔄 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/43 **Author:** [@wei-hai](https://github.com/wei-hai) **Created:** 8/11/2026 **Status:** ✅ Merged **Merged:** 8/11/2026 **Merged by:** [@wei-hai](https://github.com/wei-hai) **Base:** `main` ← **Head:** `wei/be-6958-sdk-base-url-env-var` --- ### 📝 Commits (4) - [`95bd1ff`](https://github.com/Comfy-Org/comfy-python-sdk/commit/95bd1ff8fe783e03cc812f979be52bbfd757c2ce) feat!: configure the base URL via COMFY_BASE_URL, not a constructor argument - [`6f4b204`](https://github.com/Comfy-Org/comfy-python-sdk/commit/6f4b204f0601eb73e3c9ca263b9591f369af051e) fix: address review — reject malformed ports, document the migration - [`b8a2fcb`](https://github.com/Comfy-Org/comfy-python-sdk/commit/b8a2fcb4889e4585518edf533f593b58f1ba9154) fix: reject a base URL carrying a query or fragment - [`3a8f21e`](https://github.com/Comfy-Org/comfy-python-sdk/commit/3a8f21e5fa5a44121ce2d16eaa72c98478311a3b) test: stop mutating os.environ in the gateway fixture ### 📊 Changes **17 files changed** (+284 additions, -128 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+35 -17) 📝 `src/comfy_sdk/__init__.py` (+7 -4) 📝 `src/comfy_sdk/client.py` (+56 -9) 📝 `tests/conftest.py` (+21 -3) 📝 `tests/integration/test_gateway_e2e.py` (+3 -3) 📝 `tests/test_assets.py` (+4 -4) 📝 `tests/test_async.py` (+13 -13) 📝 `tests/test_auth_headers.py` (+2 -2) ➕ `tests/test_base_url_env.py` (+103 -0) 📝 `tests/test_content_redirect_security.py` (+2 -2) ➖ `tests/test_default_base_url.py` (+0 -33) 📝 `tests/test_download_and_workflows.py` (+4 -4) 📝 `tests/test_events.py` (+5 -5) 📝 `tests/test_get_download_url.py` (+5 -5) 📝 `tests/test_jobs.py` (+18 -18) 📝 `tests/test_sse_idle.py` (+3 -3) 📝 `tests/test_user_agent.py` (+3 -3) </details> ### 📄 Description `Comfy()` / `AsyncComfy()` target Comfy Cloud; another deployment is selected with the `COMFY_BASE_URL` environment variable. The base-URL constructor parameter is removed, so an arbitrary endpoint is no longer part of the call surface. **Breaking:** `Comfy(base_url, api_key)` → `Comfy(api_key=...)` + `COMFY_BASE_URL`. `api_key` is keyword-only now, so the old positional form raises `TypeError` instead of quietly reading a URL as a key. The variable is read per construction (not at import), must be an `http(s)` URL, and unset-or-blank means Comfy Cloud. Test suite: the `server` fixture points the SDK at the stub by setting the variable, so tests construct a bare `Comfy()`; an autouse fixture scrubs an ambient value so a developer's own shell can't aim the suite at a real deployment. That is most of the diff. Scope: the public clients only. `comfy_low` (the documented escape hatch) still takes a base URL — it is what the clients build on. Verified: `ruff check`, `ruff format --check`, `mypy src`, `pytest` (120 pass, 4 skipped). Matching change in `comfy-typescript-sdk` keeps the two SDKs in lockstep. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Clients now use Comfy Cloud by default. * Select a self-hosted deployment with the `COMFY_BASE_URL` environment variable. * Base URL configuration is validated to accept only HTTP(S) addresses. * The base URL environment variable is publicly available for configuration. * API keys are provided as keyword arguments for synchronous and asynchronous clients. * **Documentation** * Updated setup, deployment, authentication, and async usage examples. * Clarified API-key requirements and cross-origin request restrictions. <!-- 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>
bsakaguchi 2026-10-31 22:01:01 +00:00
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#50
No description provided.