mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-04-20 23:42:36 +08:00
Merge 574b117f8c into 138571da95
This commit is contained in:
commit
8ad39145cd
1
.gitignore
vendored
1
.gitignore
vendored
@ -24,3 +24,4 @@ web_custom_versions/
|
|||||||
openapi.yaml
|
openapi.yaml
|
||||||
filtered-openapi.yaml
|
filtered-openapi.yaml
|
||||||
uv.lock
|
uv.lock
|
||||||
|
.comfy_environment
|
||||||
|
|||||||
33
comfy/deploy_environment.py
Normal file
33
comfy/deploy_environment.py
Normal file
@ -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)
|
||||||
|
|
||||||
|
_cached_value = _DEFAULT_DEPLOY_ENV
|
||||||
|
return _cached_value
|
||||||
@ -19,6 +19,8 @@ from comfy import utils
|
|||||||
from comfy_api.latest import IO
|
from comfy_api.latest import IO
|
||||||
from server import PromptServer
|
from server import PromptServer
|
||||||
|
|
||||||
|
from comfy.deploy_environment import get_deploy_environment
|
||||||
|
|
||||||
from . import request_logger
|
from . import request_logger
|
||||||
from ._helpers import (
|
from ._helpers import (
|
||||||
default_base_url,
|
default_base_url,
|
||||||
@ -617,6 +619,7 @@ async def _request_base(cfg: _RequestConfig, expect_binary: bool):
|
|||||||
payload_headers = {"Accept": "*/*"} if expect_binary else {"Accept": "application/json"}
|
payload_headers = {"Accept": "*/*"} if expect_binary else {"Accept": "application/json"}
|
||||||
if not parsed_url.scheme and not parsed_url.netloc: # is URL relative?
|
if not parsed_url.scheme and not parsed_url.netloc: # is URL relative?
|
||||||
payload_headers.update(get_auth_header(cfg.node_cls))
|
payload_headers.update(get_auth_header(cfg.node_cls))
|
||||||
|
payload_headers["X-Comfy-Env"] = get_deploy_environment()
|
||||||
if cfg.endpoint.headers:
|
if cfg.endpoint.headers:
|
||||||
payload_headers.update(cfg.endpoint.headers)
|
payload_headers.update(cfg.endpoint.headers)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user