Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ web_custom_versions/
openapi.yaml
filtered-openapi.yaml
uv.lock
.comfy_environment
33 changes: 33 additions & 0 deletions comfy/deploy_environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import logging
import os

import folder_paths

logger = logging.getLogger(__name__)

_DEFAULT_DEPLOY_ENV = "local_git"
_ENV_FILENAME = ".comfy_environment"

_cached_value: str | None = None


def get_deploy_environment() -> str:
global _cached_value
if _cached_value is not None:
return _cached_value

env_file = os.path.join(folder_paths.base_path, _ENV_FILENAME)
try:
with open(env_file, encoding="utf-8") as f:
first_line = f.readline().strip()
value = "".join(c for c in first_line if 32 <= ord(c) < 127)
if value:
_cached_value = value
return _cached_value
except FileNotFoundError:
pass
except Exception as e:
logger.warning("Failed to read %s: %s", env_file, e)
Comment thread
Kosinkadink marked this conversation as resolved.
Outdated

_cached_value = _DEFAULT_DEPLOY_ENV
return _cached_value
Comment thread
Kosinkadink marked this conversation as resolved.
Outdated
3 changes: 3 additions & 0 deletions comfy_api_nodes/util/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from comfy_api.latest import IO
from server import PromptServer

from comfy.deploy_environment import get_deploy_environment

from . import request_logger
from ._helpers import (
default_base_url,
Expand Down Expand Up @@ -617,6 +619,7 @@ async def _monitor(stop_evt: asyncio.Event, start_ts: float):
payload_headers = {"Accept": "*/*"} if expect_binary else {"Accept": "application/json"}
if not parsed_url.scheme and not parsed_url.netloc: # is URL relative?
payload_headers.update(get_auth_header(cfg.node_cls))
payload_headers["X-Comfy-Env"] = get_deploy_environment()
if cfg.endpoint.headers:
Comment thread
Kosinkadink marked this conversation as resolved.
payload_headers.update(cfg.endpoint.headers)

Expand Down
Loading