mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-04-20 06:29:09 +00:00
feat: add get_execution_environment() API for managed deployments
Adds a simple API that lets custom nodes detect whether they are running in a local, cloud, or remote environment. Managed deployments set the COMFY_EXECUTION_ENVIRONMENT env var; the default is "local". This enables node authors to implement graceful degradation - for example, skipping model downloads when models are pre-provisioned, or disabling features that require local hardware.
This commit is contained in:
@@ -1453,3 +1453,22 @@ def normalize_image_embeddings(embeds, embeds_info, scale_factor):
|
||||
start_idx = info["index"]
|
||||
end_idx = start_idx + info["size"]
|
||||
embeds[:, start_idx:end_idx, :] /= scale_factor
|
||||
|
||||
|
||||
_VALID_ENVIRONMENTS = {"local", "cloud", "remote"}
|
||||
|
||||
def get_execution_environment():
|
||||
"""Return the current execution environment.
|
||||
|
||||
Reads the COMFY_EXECUTION_ENVIRONMENT environment variable. Managed
|
||||
deployments (e.g. Comfy Cloud) set this variable so that custom nodes
|
||||
can adapt their behaviour at runtime — for example, skipping model
|
||||
downloads when models are pre-provisioned.
|
||||
|
||||
Returns:
|
||||
str: One of "local" (default), "cloud", or "remote".
|
||||
"""
|
||||
value = os.environ.get("COMFY_EXECUTION_ENVIRONMENT", "local").lower().strip()
|
||||
if value not in _VALID_ENVIRONMENTS:
|
||||
return "local"
|
||||
return value
|
||||
|
||||
Reference in New Issue
Block a user